Skip to content

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

Merged
jordanpadams merged 7 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#105
jordanpadams merged 7 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 Java 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 and others added 2 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>

@nutjob4life nutjob4life left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Code delta: ✓
Approval: ✅
Caveat: based on visual inspection only
Note: the \.git.* regex might work better as '(^|/)\.git/' so .github/* gets scanned too

jordanpadams and others added 4 commits August 4, 2026 10:15
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>
Adds IDE directories (.vscode, .eclipse, .idea, .settings, .metadata),
Java IDE project files (.iml, .classpath, .launch, etc.), Maven/Gradle
internals, and compiled output extensions to prevent detect-secrets from
scanning generated or editor-owned files that cannot contain real secrets.

Also adds .envrc to .gitignore to prevent local direnv files from being
tracked.

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

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@jordanpadams
jordanpadams merged commit 2f313f7 into main Aug 5, 2026
5 checks passed
@jordanpadams
jordanpadams deleted the fix/secrets-detection-is-secret-check branch August 5, 2026 16:34
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.

2 participants