fix(driver): shlex-split --cflags so spaced defines survive - #12
Open
MarkAtwood wants to merge 2 commits into
Open
fix(driver): shlex-split --cflags so spaced defines survive#12MarkAtwood wants to merge 2 commits into
MarkAtwood 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.
This was referenced Jul 24, 2026
sameehj
force-pushed
the
master
branch
4 times, most recently
from
July 24, 2026 14:09
3ab77f9 to
9bdf5b7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.