fix(build): more reliably ignore node_modules in secret scanner#7012
Draft
fix(build): more reliably ignore node_modules in secret scanner#7012
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Some current problems: - We currently ignore any path that has `node_modules` in its name, even if it's just a substring or if it's not a directory - We ignore `node_modules` if the substring `node_modules` is found in the user's `.gitignore`, even if it's a substring or targets a different `node_modules` - If `base` does not resolve to the repository root, we won't locate a `.gitignore` - We ignore nested `.gitignore` files, so we match against an incomplete `.gitignore` list. (A little fringe, but true)
645b23d to
e4bd18a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If there's no
.gitignorepresent or ifbaseresolves to a path that isn't the root of the project, we'll scannode_modulesfor secrets. Looking at the notes on the current implementation, I think the intention here is really to only scannode_modulesdirectories that are vendored into the repository by the user.This change updates the scanner to only scan
node_modulesonly if we're positive that that the user has vendored theirnode_modulesdirectory (or director_ies_, I guess).Other little problems I noticed with the current implementation that this fixes:
node_modulesin its name, even if it's just a substring or if it's not a directorynode_modulesif the substringnode_modulesis found in the user's.gitignore, even if it's a substring or targets a differentnode_modules.gitignorefiles, so we may be matching against an incomplete.gitignorelistbasedoes not resolve to the repository root, we won't locate a.gitignore. (I don't know if this is actually happening currently--I'd need to confirm with a repro.)