Skip to content

Add working tree state to build provenance - #420

Open
maggo83 wants to merge 8 commits into
cryptoadvance:masterfrom
maggo83:report-working-tree-state
Open

maggo83 wants to merge 8 commits into
cryptoadvance:masterfrom
maggo83:report-working-tree-state

Conversation

@maggo83

@maggo83 maggo83 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Dependency

Depends on #419 and must be reviewed/merged after it. This branch is based directly on #419 commit f9f825367a3d697fe5dedc50cfbcf15867ad0890.

Until #419 merges, GitHub will also show its changes in this PR. The intended follow-up diff is:

f9f825367a3d697fe5dedc50cfbcf15867ad0890..b663942

Summary

Add a separate working-tree state to developer build provenance without changing the embedded commit SHA.

  • emit Clean or Modified for developer checkouts
  • count tracked, staged, and non-ignored untracked changes, including initialized nested submodules
  • emit unknown when Git is unavailable and in reproducible builds
  • show known state as Working tree: Clean/Modified in firmware details

Ignored build products remain excluded through Git's normal ignore rules. The state is informational and does not claim that the binary is reproducible from the identified checkout.

Validation

  • focused provenance tests: 7 passed
  • complete native suite: 83 passed
  • diagnostics and whitespace checks passed
  • built and flashed STM32F469 firmware reporting Modified; confirmed on-device
  • built and flashed a disposable committed snapshot reporting Clean; confirmed on-device
  • programmer verification and independent immutable-region readback passed for both images

Restore repository, branch, and full commit metadata for developer builds while keeping release output deterministic. Pass reproducible mode explicitly through Make instead of ambient environment variables, and remove redundant historical documentation.
@netlify

netlify Bot commented Sep 4, 2026

Copy link
Copy Markdown

Deploy Preview for specter-diy-docs ready!

Name Link
🔨 Latest commit 4c2a3f2
🔍 Latest deploy log https://app.netlify.com/projects/specter-diy-docs/deploys/6a9ec168556cd300085e115e
😎 Deploy Preview https://deploy-preview-420--specter-diy-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

maggo83 and others added 2 commits September 4, 2026 18:11
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Schnuartz

Copy link
Copy Markdown
Contributor

@al-munazzim can you review?

@al-munazzim al-munazzim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the working-tree provenance follow-up. I ran the focused embed_git_info tests directly from the test module on this PR: 7 tests passed.\n\nThe explicit Clean/Modified/unknown working-tree field addresses the misleading-commit concern without changing the embedded commit SHA, and the tests cover ignored files, untracked files, and initialized nested submodule modifications. This should make developer-build provenance more accurate while keeping reproducible builds unknown/stable. No blocker from me.

Address review feedback on cryptoadvance#419: remote.origin.url may contain
credentials (https://<token>@github.com/..., https://user:pass@...)
which would be frozen into firmware and shown on the About screen.

- strip userinfo from https/http/ssh/git scheme URLs via regex
- allow only https/http/ssh/git schemes and scp-like user@host:path
  syntax; reject file:// and other protocols as well as bare local
  paths (which leak developer machine paths/usernames)
- fail closed to 'unknown' for malformed URLs (e.g. multiple @ in
  netloc after stripping)
- drop the rev-parse --show-toplevel fallback in discover_repository()
  for the same reason
@maggo83
maggo83 force-pushed the report-working-tree-state branch from b663942 to a31b033 Compare September 7, 2026 11:37
URL schemes are case-insensitive (RFC 3986), so HTTPS://... must not be
rejected as unknown. Extract the scheme via regex and compare it
lowercased against the allowlist.

Also fail fast in the test helper load_embed_git_info() if the module
spec or loader cannot be created, instead of raising AttributeError
later.
@maggo83
maggo83 force-pushed the report-working-tree-state branch from a31b033 to 74259cb Compare September 7, 2026 11:48
Token- and credential-looking literals (ghp_secret123, user:pass@...)
trigger secret-scanner heuristics and tooling redaction even though
they are fake. Replace them with clearly synthetic placeholders
(SECRET-TOKEN, PASSWORD, CRED, user:<password>@host) that exercise the
same code paths without matching credential patterns.
@maggo83
maggo83 force-pushed the report-working-tree-state branch from 74259cb to 3362251 Compare September 7, 2026 13:26
The scp-like user@host:path form has no credential field, but the user
part can still carry PII (emails, internal usernames) which would be
frozen into firmware verbatim. Fail closed to 'unknown' unless the
user is the standard 'git' login used by GitHub/GitLab and other
major hosting services.
Detect clean or modified developer checkouts, including nested submodules, while keeping reproducible and no-Git builds unknown. Show the result in the device firmware details.
@maggo83
maggo83 force-pushed the report-working-tree-state branch from 3362251 to 4c2a3f2 Compare September 7, 2026 13:51
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