Warn when secret files are excluded from the push - #1
Conversation
|
Hey David, this is the follow-up to the review we did over email. I pulled v0.3.8 and went through it from source. The TLS change is exactly right: the default dial verifies against the system roots now, and the insecure path is gated behind INSECURE_VERIFY with a stderr warning, so it can't happen by accident in prod. I also confirmed the broadened secret exclusion (.pem/.key/.p12/.pfx/.netrc on top of .env) and the --help port matching :50052. Build, vet, and the race test suite are green on my end. This PR is the small "maybe worth a warning" bit from that thread. The secret exclusion works, but it's silent, so you don't find out a .env was withheld unless you go looking. It adds a one-line notice listing the secret files a push kept out, only the ones that weren't already gitignored. No rush, and feel free to close it if you'd rather handle the UX differently. I still owe you a live deploy for round two once I get to it. |
davidchua
left a comment
There was a problem hiding this comment.
Sorry for the late review! Thanks @somaz94 for the PR!
Thanks for this! I think the intention is correct, we should surface up to the user when files are implicitly removed that are not part of .fyraignore.
Happy to merge it in but just two general comments for changes.
- I think we should send the warning into stderr instead of stdout.
- Not blocking, but I think we should extract the dir pruning list now that there are more than one methods that is using the same logic.
Super appreciate the PR 🙇
| // deploy. Printed before the TUI starts (which renders inline) so it stays | ||
| // visible on both the interactive and non-interactive paths. | ||
| ignorer, _ := loadIgnoreFile(".") | ||
| warnSkippedSecrets(os.Stdout, skippedSecretFiles(".", ignorer)) |
There was a problem hiding this comment.
I think we should use os.Stderr instead of os.Stdout here to keep to the convention that warnings belong to Stderr.
This would also allow us to keep stdout clean for users who might want to pipe their fyra push output into their CI/CD.
There was a problem hiding this comment.
Done. Moved the notice to os.Stderr so stdout stays clean for piping into CI/CD.
| if d.Name() == ".git" || d.Name() == "node_modules" { | ||
| return filepath.SkipDir | ||
| } |
There was a problem hiding this comment.
Just a small nitpick, this same rule lives in shouldSkip's isDir branch (push.go:202). Today they agree.
The hazard is what happens when they don't: if someone later adds .next/ or vendor/ to shouldSkip and forgets this function, the warning will start naming secrets inside directories that would never have shipped.
We might want to abstract this out, like a pruneDir() so there's only one definition of directories to skip.
There was a problem hiding this comment.
Extracted the skip list into a pruneDir() helper and pointed both shouldSkip and skippedSecretFiles at it, so they can't drift. Added a small TestPruneDir to lock the shared list.
6fa78ec to
5fc4822
Compare
|
Rebased on latest |
|
Hi @davidchua — friendly ping on this one. Both review points are addressed: the warning now goes to stderr instead of stdout, and the directory prune list is extracted into a Happy to make any further changes if something still looks off. |
Following up on the review David and I did over email.
pushalready hard-excludes secret files (.env*,.pem,.key,.p12,.pfx,.netrc) so they can't be published, which is great, but it does it silently. This adds a one-line notice listing the secret files that were withheld, so you can tell at a glance that a sensitive file was kept out of the deploy (and why it's missing, if you expected it to ship).Only secrets that would otherwise have shipped are listed. Files already excluded via
.fyraignorearen't repeated, and.git/node_modulesaren't descended into.Example:
Implementation: extracted the existing secret-name check into an
isSecretFilepredicate (shouldSkipcalls it, no behavior change) and added a pre-push scan that reports the withheld files on both the interactive and non-interactive paths.Validation (local):
go build,go vetpassCGO_ENABLED=1 go test -race ./...passes, including new tests forisSecretFile,skippedSecretFiles, andwarnSkippedSecrets