Skip to content

fix(driver): shlex-split --cflags so spaced defines survive - #12

Open
MarkAtwood wants to merge 2 commits into
masterfrom
fix/sbom-driver-cflags-shlex
Open

fix(driver): shlex-split --cflags so spaced defines survive#12
MarkAtwood wants to merge 2 commits into
masterfrom
fix/sbom-driver-cflags-shlex

Conversation

@MarkAtwood

Copy link
Copy Markdown

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 build-configuration evidence recorded in the SBOM. Now uses shlex.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.

sameehj and others added 2 commits July 23, 2026 15:54
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).
Copilot AI review requested due to automatic review settings July 24, 2026 00:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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() in share/sbom-driver.py from str.split() to shlex.split(), and fail fast on malformed quoting.
  • Add a regression unit test ensuring a spaced -D value 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants