Skip to content

Fail secrets baselines on unreadable files or scan errors - #314

Open
shin4141 wants to merge 2 commits into
temporalio:mainfrom
shin4141:codex/fix-secrets-baseline-errors
Open

shin4141 wants to merge 2 commits into
temporalio:mainfrom
shin4141:codex/fix-secrets-baseline-errors

Conversation

@shin4141

Copy link
Copy Markdown

Summary

  • stop both secrets-baseline walks when a file cannot be read or scanned
  • preserve the underlying error while adding the affected file path
  • cover create/update scan failures and read failures with regression tests

Previously, either failure was returned as nil from the walk callback, so the command could persist a baseline built from an unknown subset of files and still report success.

Fixes #309.

Verification

  • go test ./internal/cli/cmd -count=1
  • go test -race ./internal/cli/cmd -run 'TestBaselineWalksReturnScanErrors|TestScanBaselineFileReturnsReadErrors' -count=1
  • go vet ./internal/cli/cmd
  • go build -o /private/tmp/v36-deputy-bin .
  • go test ./... -count=1: all packages passed except internal/ignore; its two date-dependent failures reproduce unchanged at base commit 65f6eb9

Implementation and regression tests were prepared with Codex and reviewed against the final diff.

@shin4141
shin4141 requested a review from picatz as a code owner August 14, 2026 23:13
@CLAassistant

CLAassistant commented Aug 14, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b41cf031d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +442 to +444
content, err := fs.ReadFile(rootFS, path)
if err != nil {
return nil, fmt.Errorf("reading %s: %w", path, err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Skip directory symlinks before reading them

When the target contains a symlink to a directory, fs.WalkDir reports the symlink itself as a non-directory entry, so both walkers pass it here; fs.ReadFile then follows the link and returns an EISDIR error. Propagating that error makes both baseline create and baseline update fail on otherwise valid repositories containing directory symlinks, whereas these entries were previously skipped after the failed read. Detect and skip directory symlinks or other non-file entries before treating read failures as fatal.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Confirmed and fixed in 40f9645.

fs.WalkDir exposed the directory symlink as a non-directory entry, and the new focused test failed on both create and update with reading target-link: ... is a directory before the fix.

Both walkers now skip entries with known non-regular mode bits (d.Type()&fs.ModeType != 0) before calling fs.ReadFile. Regular files still reach scanBaselineFile, so genuine read failures and scanner failures remain fail-closed. TestBaselineWalksSkipDirectorySymlinks creates an actual directory symlink and covers both baseline paths while asserting the scanner is not called.

Verification:

  • focused baseline regressions: pass
  • go test ./internal/cli/cmd -count=1: pass
  • focused -race: pass
  • go vet ./internal/cli/cmd: pass
  • go build: pass
  • bounded go test ./... -count=1: all packages pass except the same two date-dependent internal/ignore failures previously reproduced unchanged at base commit 65f6eb9.

Copy link
Copy Markdown
Author

@codex address that feedback

Please handle the directory-symlink/non-file false-positive identified in the review without weakening the original fail-closed repair. Preserve the intended distinction: routine non-file entries may be skipped when structurally expected, but genuine read/scan failures on files must remain loud. Add focused regression coverage for the symlink/non-file case, rerun the prior verification set, and keep unrelated behavior unchanged.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

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.

Secrets baseline silently omits files it cannot read or scan, then reports a complete baseline

2 participants