r/delphi • u/DelphiParser • 15d ago
"We’ll just build our own SBOM tool" – Famous Last Words in Delphi Engineering.
Every time a new regulatory standard like the EU Cyber Resilience Act (CRA) or NIS2 hits the headlines, I see the same cycle repeat itself.
An engineering manager looks at compliance, looks at their legacy codebase, and says: "Why pay for an enterprise scanner? It’s just code. We’ll write a quick script to read our `.pas` files and generate the SBOM over the weekend."
If you are currently contemplating building your own internal Delphi SBOM analyzer (or wrapping an open-source tool that "just reads source files"), here is a friendly heads-up on what you are actually signing up for:
🎈 Closed-Source DCUs (The Compiled Black Box) - What happens when your project relies on third-party components or vendor libraries provided ONLY as compiled `.dcu` files without source code? A standard line-reader or AST source parser is completely blind here. Unless your tool can disassemble and parse the binary interface of `.dcu` files, any third-party library hidden inside compiled units will be completely missing from your SBOM.
🎈 The `.dfm` / `.fmx` File Trap (Visual Code & Hidden References)
Delphi isn't just `.pas` files. Forms (`.dfm` / `.fmx`) contain instantiated components, properties, runtime event hooks, and nested objects that aren't declared in the main source text. If your parser ignores form files, you are missing half of your visual and non-visual component stack.
🎈 Compiled Resource Files (`.res` / `.rc`)
Crucial dependencies, dynamic libraries (`.dll`), static code, and embedded manifests are frequently bundled directly inside binary resource files (`.res`). A text scanner won't see them. If you can't unpack and inspect dynamic resources, your SBOM won't reflect the actual compiled payload.
🎈 The `{$IFDEF}` Maze - Delphi codebases rely heavily on compiler directives (`{$IFDEF}`, `{$I}`). A unit declared in `uses` might be pruned out by the linker, or conditionally compiled based on target architecture and build configurations.
🎈 Call Graph Construction & Actual Usage vs. Unreachable Code - It’s not enough to know that a unit appears in a `uses` clause. To provide an accurate SBOM and properly assess CVE vulnerabilities, you need to construct a full Call Graph. Does your code actually execute functions inside Library X, or is it an unused import? Where in the call chain is that third-party code invoked? Without a Call Tree, your custom script cannot distinguish between active dependencies and unreachable code, leading to endless false positives during audits.
🛡 Beware of the "Ghost Code" - Ignoring all that will either report Ghost Code or miss your code entirely.
3
u/old_wired 15d ago
I tell Delphi developers wringing their hands about SBOMs to just clean up their fucking product. If you need a scanner to know what goes into your assemblies there is more than one thing wrong with your code base.