Skip to content

fix(security): nosec B108 on SPIRE socket path in spiffe.py - #264

Merged
imran-siddique merged 6 commits into
mainfrom
fix/bandit-b108-spiffe
Jun 8, 2026
Merged

imran-siddique merged 6 commits into
mainfrom
fix/bandit-b108-spiffe

Conversation

@imran-siddique

Copy link
Copy Markdown
Member

Summary

  • bandit B108 was flagging /tmp/spire-agent/public/api.sock in spiffe.py:26 as a hardcoded temp directory (CWE-377)
  • This path is the SPIRE Workload API standard Unix domain socket location — it is not a temp file created by this code; it is a pre-existing socket managed by the SPIRE agent process
  • Added # nosec B108 with an inline justification comment

Root cause

The security scan step in the CI test matrix job runs bandit before pytest. When bandit exits non-zero on B108, the step fails and the entire job fails. Because fail-fast is true by default, the matrix strategy then cancels all other platform/version jobs — making it look like tests are failing everywhere when bandit is the actual culprit.

Test plan

  • CI security scan passes with bandit B108 suppressed
  • All test matrix jobs (3.11/3.12/3.13 × ubuntu/macos/windows) complete without cancellation
  • No new bandit findings introduced

🤖 Generated with Claude Code

imran-siddique and others added 6 commits June 8, 2026 13:06
The /tmp/spire-agent/public/api.sock path is the SPIRE Workload API
standard Unix domain socket location. It is not a temp file created
by this code -- it is a pre-existing socket managed by the SPIRE
agent process. B108 is a false positive here.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…x.py

Both calls use urllib.request.Request objects with explicit HTTPS endpoints,
not raw URL strings. Bandit B310 fires because it cannot statically resolve
the Request object's scheme, making these false positives.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add per-file-ignores for T201 (intentional prints in benchmarks and soak scripts)
- Move _CLAIM_SEQUENCE global after imports in session/manager.py to fix E402
- Combine nested ifs in sev_snp.py (SIM102)
- Remove unused X509Svid import in spiffe.py (F401)
- Collapse nested with statements in test_low_batch_186_187_191_194.py (SIM117)
- Remove unnecessary assignment before return in test_tee_dev_mode_freeze.py (RET504)
- All ruff auto-fixable issues resolved via ruff --fix (64 files touched)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- manager.py: access PolicyBundle attributes via PolicyStore.bundle property
  (PolicyStore wraps PolicyBundle; bundle_hash and manifest live on the inner object)
- benchmarks.py: add Iterator[None] return type to _quiet() contextmanager
- benchmarks.py: use TEEProvider.SOFTWARE_ONLY enum value instead of bare string

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
PolicyStore exposes bundle_hash and manifest via the .bundle property,
not as direct attributes. Update _make_ctx() mocks to use
policy_bundle.bundle.bundle_hash and policy_bundle.bundle.manifest.version.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
socket.AF_UNIX is absent from Windows mypy stubs. The code already has a
try/except AttributeError guard, so this is a known platform difference.
Added type: ignore[attr-defined] and a warn_unused_ignores = false mypy
override so Linux CI does not reject the suppress comment as unused.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@imran-siddique
imran-siddique merged commit 5a1fcf3 into main Jun 8, 2026
8 checks passed
@imran-siddique
imran-siddique deleted the fix/bandit-b108-spiffe branch July 29, 2026 23:19
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.

1 participant