In this article
- Why legacy COBOL and Bash need their own audit
- Where AI-assisted analysis helps most
- Where static analysis and AI both miss the dependencies
- Security blind spots in old COBOL and Bash code
- A pre-modernization audit checklist
- Which to pick first: the modernization path
- Frequently asked questions
- Can AI fully automate COBOL modernization?
- Does ShellCheck analyze COBOL?
- Is the NIST Secure Software Development Framework final?
- Do Bash scripts need a software bill of materials?
AI legacy code modernization is now a practical project for teams that still run COBOL batch jobs and Bash operations scripts. The useful first step is not a rewrite. It is an audit that shows what the code does, what it depends on and where it can fail. This guide covers how AI-assisted code analysis fits into that audit, where it stops, and which security blind spots to check before any migration starts.
Why legacy COBOL and Bash need their own audit
COBOL and Bash fail in different places, so one generic scanner is not enough. COBOL programs often share state through files, copybooks and job streams. Bash scripts depend on the shell, the operating system and the environment of the machine that runs them. Map both kinds of dependency before any code is translated.
Many organizations keep both languages for good reasons. COBOL still carries core batch processing in banks, insurers and government agencies, and Bash often ties backups, deployments and scheduled jobs together around it. Sonar’s July 2026 analysis of COBOL describes the pressure plainly: the engineers who wrote these systems are retiring, and much of the knowledge exists only in the code. Sonar, citing Reuters, gives the scale as an estimated $3 trillion in daily commerce and about 220 billion lines of code in production, and it notes that those figures are estimates from 2017.
A useful audit answers four questions. What does each program or script do? Which inputs and outputs does it touch? Which other components does it call or wait for? What breaks if it changes? The answers become the input for every later decision, including whether to rehost, refactor, rewrite or replace.
Scope matters as much as depth. A nightly COBOL run and the Bash wrapper that starts it form one operational unit, even when they sit in different repositories or on different hosts. Audit them together, or the dependency map will be wrong from the first day.
The audit also needs a named owner for each finding. Legacy systems often have no current owner, so the first deliverable should be a register that lists who approves changes to each program, script and job. Without that register, an AI-generated summary has nowhere to go and nobody to check it.
Where AI-assisted analysis helps most
AI-assisted analysis helps most when it explains code that nobody on the team can read quickly. Sonar argues that the most valuable use of AI on COBOL is explaining old code rather than writing new code, such as extracting business rules from an undocumented paragraph. Verify that output against the running system.
Anthropic describes a similar use for COBOL in its February 2026 article. The workflow maps call paths across large codebases and documents how modules depend on one another, including relationships that span many files. Rocket Software markets its COBOL Analyzer as static code analysis enriched by generative AI insights, with natural-language questions about the code through a chat interface. Both are vendor descriptions. Check them in a pilot on your own code before relying on any capability claim.
For Bash, AI tools are most useful for reading long scripts, summarizing what each function does and flagging the commands that touch production systems. A summary is a map for the reviewer. It is not a verdict on whether the script is correct.
A practical way to use these tools is to ask narrow questions. Which paragraphs change the customer balance? Which scripts call this job? Which files does this function delete? A narrow question produces an answer that a reviewer can check against the code in minutes. A broad request such as “modernize this system” produces plausible text that is hard to verify.
Keep a record of each question and answer in the audit file. The record shows which findings came from the tool, which a person confirmed, and which were rejected. That trail matters later, if a migrated rule behaves differently from the original.
Where static analysis and AI both miss the dependencies
Static analysis follows calls well, but it often misses coupling that runs through shared data. Anthropic’s February 2026 article names shared data structures, file operations and initialization sequences as dependencies that static analysis tends to miss. Treat a code-derived dependency map as a starting point, not the final inventory.
These hidden links matter most in COBOL, where two programs can exchange state through a file that neither one names as an interface. Bash has the same problem in a different form. A script that reads a file produced by a scheduled job, or that sources a shared configuration file, creates a dependency that no call graph shows. Ask the people who run the jobs, read the scheduler configuration, and list every file path that the code reads and writes.
Runtime evidence closes part of the gap. Scheduler logs, job histories and file listings show which paths are used in practice, including paths the code never names directly. Compare those records with the dependency map and investigate every difference before choosing a path.
Record what the map cannot show. If a process depends on a manual step, such as an operator who copies a file each month, write that down as a known gap. Gaps like this tend to surface only after cutover, so they belong in the plan from the start.
Security blind spots in old COBOL and Bash code
Legacy code often carries security debt that nobody has written down. The usual blind spots are unsupported components, credentials stored in scripts or job parameters, and unchecked input. CISA’s July 30, 2026 guidance on open source software covers risk management across the full lifecycle, including vulnerability management and software bills of materials.
Three blind spots deserve a specific check:
- Unsupported runtimes and tools. A compiler, runtime or shell that no longer receives patches keeps working, so nobody schedules its replacement. List each version and its support status.
- Secrets in code and job setup. Passwords and API keys often sit in Bash variables, job control parameters or copied configuration files. Search every script and job definition, then move the values to a managed secret store.
- Unquoted variables and unchecked input. Bash scripts that expand variables without quotes, or pass file names without checks, can break on unexpected input. ShellCheck is an open-source GPLv3 tool that gives warnings and suggestions for bash and sh scripts. Its GitHub releases page lists v0.11.0 as the latest stable version.
NIST’s Secure Software Development Framework is the other reference to use. Revision 1 of SP 800-218, which describes version 1.2 of the framework, was published as an initial public draft on December 17, 2025, with comments due January 30, 2026. The NIST page still labels it as a draft, so cite it as a draft until a final version is published.
Access control is the fourth area, and it is easy to skip. Batch jobs often run under a shared service account, and Bash scripts sometimes run with broad privileges inherited from an earlier setup. Record which account runs each job, what that account can reach, and whether a narrower account can do the same work.
Logging needs the same attention. A project that changes the job runner should keep a record of who ran what and when. If the old system wrote logs to a local file that nobody reads, decide where those records go before the switch, not after it.
A pre-modernization audit checklist
Run the audit in this order before a migration plan is approved. Start with the inventory, then map the dependencies, then check security, and only then choose a path. Each step feeds the next, so the checklist doubles as the plan for the first sprint.
- ☐ Inventory every COBOL program, copybook, job definition and Bash script, with its owner and its last run date.
- ☐ Map each file, database table, queue and environment variable that every program or script reads or writes.
- ☐ Record the schedule and any upstream job that must finish first.
- ☐ Run ShellCheck on every Bash script and log each warning as fixed or accepted, with a reason.
- ☐ Search source code and job parameters for credentials, then rotate and remove them.
- ☐ Build a software bill of materials for runtimes, compilers and libraries.
- ☐ Flag every component with no vendor support or no patch path.
- ☐ Have a domain owner confirm each business rule that an AI tool extracted.
- ☐ Define the comparison check that shows old and new behavior match before any cutover.
Treat the checklist as a gate. A program with an open item on the dependency map, an unchecked credential or no named owner does not move into the modernization queue. Gates like this slow the first month, but they keep problems out of the migration work.
Which to pick first: the modernization path
Choose the modernization path after the audit, not before it. Anthropic’s article lists four approaches: rehost, refactor, rewrite and replace. An audit that finds heavy hidden coupling usually points to a slower path, while a small, well-documented script may be replaced directly.
Three answers decide the path. How many hidden dependencies did the audit find? How many people can still explain the code? Can the security gaps be closed where the code runs today? If the dependency map is large and the original owners have left, rehosting or refactoring behind stable interfaces keeps the business running while the knowledge is recovered. If the code is small and the business rules are documented, replacement is simpler.
Mixed estates are common. A reasonable plan might rehost the COBOL batch runtime first, refactor the shared file layouts behind stable interfaces, and replace the Bash wrappers once their callers are mapped. Each step lowers the risk of the next one. The sequence should follow the dependency map.
Keep the decision record with the audit. For each program or script, write the chosen path, the evidence behind it and the person who approved it. That record answers the question an auditor or a new engineer will ask first: why was this done this way?
Frequently asked questions
Teams usually raise the same questions in the first review: whether AI can do the migration alone, what ShellCheck covers, what status the NIST framework has, and whether scripts need a software bill of materials. The short answers are below, and each one points to a source in the table.
Can AI fully automate COBOL modernization?
No, not on its own. AI tools can speed up reading and documenting code, but a domain owner still has to confirm the business rules, and the migrated system still has to be compared with the running one. Sonar’s July 2026 analysis puts the hard question as who verifies what the AI produces.
Does ShellCheck analyze COBOL?
No. ShellCheck targets sh and Bash scripts. COBOL needs a COBOL-aware analyzer, and the vendor pages in the sources table describe the options.
Is the NIST Secure Software Development Framework final?
Not as far as the NIST page shows. SP 800-218 Revision 1 is labeled an initial public draft, and the page lists the comment deadline as January 30, 2026. Check the NIST publications page before citing a final version.
Do Bash scripts need a software bill of materials?
A software bill of materials is useful wherever a script pulls in packages, modules or binaries. CISA’s July 2026 guidance treats SBOM use as part of managing open source risk. For a script that only calls operating system tools, list those tools and their versions in the same inventory.



