Skip to content

Fix is_secret three-state check and use [[ ]] in detect_secrets_baseline.sh - #158

Merged
jordanpadams merged 9 commits into
mainfrom
fix/secrets-detection-is-secret-check
Aug 5, 2026
Merged

Fix is_secret three-state check and use [[ ]] in detect_secrets_baseline.sh#158
jordanpadams merged 9 commits into
mainfrom
fix/secrets-detection-is-secret-check

Conversation

@jordanpadams

Copy link
Copy Markdown
Member

Summary

Ports two fixes from NASA-PDS/s3-browser-cloudfront#193 (per review by @nutjob4life) to the Python template.

Changes

1. is_secret three-state fix

The is_secret field in a detect-secrets baseline is effectively three-state:

  • Absent — finding has not been audited yet
  • true — audited and confirmed as a real secret
  • false — audited and marked as a false positive

The previous Check 1 only caught unaudited findings (absent is_secret). A confirmed real secret (is_secret: true) would silently pass. This PR splits Check 1 into two separate checks:

  • Check 1: Fail if any finding has not been audited (is_secret absent)
  • Check 2: Fail if any audited finding is a confirmed real secret (is_secret: true)
  • Check 3: (renumbered) Fail if net-new secrets are found vs the baseline

2. [ ][[ ]]

All single-bracket [ ] conditionals replaced with double-bracket [[ ]] to satisfy SonarCloud.

AI Assistance Disclosure

  • AI generated substantial portions of this code

Estimated % of code influenced by AI: 90%


🤖 Generated with Claude Code

- Add separate Check 2 for confirmed real secrets (is_secret: True),
  distinct from unaudited findings (is_secret absent); addresses the
  edge case where confirmed secrets would not cause a CI failure
- Replace all [ ] conditionals with [[ ]] to satisfy SonarCloud
- Renumber former Check 2 (new secrets scan) to Check 3

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordanpadams
jordanpadams requested a review from a team as a code owner August 3, 2026 16:21
jordanpadams and others added 8 commits August 3, 2026 09:25
Restructure into named functions with clear responsibilities:
- find_detect_secrets: locates the binary
- build_exclude_args: assembles --exclude-files flags
- baseline_fingerprints / baselines_match: clean baseline comparison
  using a heredoc Python block instead of inline escaped one-liners
- count_findings: shared helper for unaudited/confirmed checks
- check_unaudited_findings, check_confirmed_secrets, check_new_secrets:
  each check is its own function with a descriptive name
- run_ci_checks: top-level that reads like a table of contents
- case statement replaces if/elif chain for the entry point

Also adds set -euo pipefail, named constants for BASELINE and
BASELINE_IGNORE, inline comments on each GLOBAL_EXCLUDES entry,
and a usage guard for unknown arguments.

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

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Avoids blocking .github/workflows/ and other .github/ paths from
secrets scanning. Suggested by @nutjob4life in PR review.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Single-quoted trap deferred expansion of scratch until after RETURN,
at which point bash 5.1 (ubuntu-latest) had already unset the local,
triggering set -u unbound-variable error. Double-quoting expands the
path at trap-registration time while scratch is still in scope.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add exclusions for Python build/cache artifacts (__pycache__, compiled
files, packaging outputs), env template files (.env.example etc.), and
editor/IDE directories (.vscode, .idea, .sublime-*) that commonly
trigger false positives but never contain real secrets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordanpadams
jordanpadams merged commit 0cd2cae into main Aug 5, 2026
3 checks passed
@jordanpadams
jordanpadams deleted the fix/secrets-detection-is-secret-check branch August 5, 2026 16:53
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