Uh oh!
There was an error while loading. Please reload this page.
fix(driver): shlex-split --cflags so spaced defines survive - #12
fix(driver): shlex-split --cflags so spaced defines survive#12MarkAtwood wants to merge 2 commits into
Conversation
Signed-off-by: Sameeh Jubran <sameeh@wolfssl.com>
capture_macros tokenised CFLAGS with str.split(), so a define with a quoted spaced value (-DBANNER="a b") was torn into '-DBANNER="a' + 'b"' and the tail dropped -- silently corrupting the captured build configuration recorded in the SBOM. Use shlex.split (failing loudly on an unbalanced quote) so such a define stays a single token. Adds a capture_macros regression test (guarded on a host compiler).
There was a problem hiding this comment.
Pull request overview
This PR fixes SBOM build-evidence capture by correctly tokenizing --cflags using shell-style parsing so quoted, space-containing -D macro values (e.g., -DWG_BANNER="a b c") survive as a single compiler argument instead of being silently corrupted.
Changes:
- Switch
capture_macros()inshare/sbom-driver.pyfromstr.split()toshlex.split(), and fail fast on malformed quoting. - Add a regression unit test ensuring a spaced
-Dvalue reaches the compiler intact (skips cleanly if no host C compiler is available).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_sbom.py | Adds a host-compiler-gated regression test verifying spaced -D macro values are preserved through capture_macros(). |
| share/sbom-driver.py | Uses shlex.split() for --cflags parsing and exits with a clear error on unbalanced quotes to avoid silent SBOM evidence corruption. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3ab77f9 to
9bdf5b7CompareMarkAtwood
commented
Aug 13, 2026
Closing. shlex is a net regression here, and the splitter is the wrong layer to fix this at. Measured against the actual Neither wins. Each fixes one class of input by breaking the other, and The real defect is upstream of the splitter. Fix: add Not urgent. The only spaced define in wolfBoot today is Follow-up: master's |
capture_macrostokenised CFLAGS withstr.split(), so a define with a quoted spaced value (-DBANNER="a b") was torn into-DBANNER="a+b"and the tail dropped — silently corrupting the build-configuration evidence recorded in the SBOM. Now usesshlex.split(failing loudly on an unbalanced quote) so the define stays a single token.Regression test added to
test_sbom.py(guarded on a host compiler): asserts-DWG_BANNER="a b c"reaches the compiler intact as#define WG_BANNER a b c. Independent of the other open review PRs.Addresses SBOM-gpex.8.