Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to exclude a folder? #39

Closed
hopewise opened this issue Feb 22, 2017 · 3 comments
Closed

How to exclude a folder? #39

hopewise opened this issue Feb 22, 2017 · 3 comments

Comments

@hopewise
Copy link

How would I exclude a folder in the scan?

@mtdowling
Copy link
Contributor

You can add an "allowed" pattern that excludes specific directories via the regular expression. The lines scanned when filtering out allowed patterns is formatted as follows:

filename:line:text

Where filename is the matched file (e.g., ./foo/bar.txt), line is a line number (e.g., 124), and text is the line of the file that matched one of your prohibited patterns (e.g., "this is the text").

You can add an allowed pattern that can filter out directories and files using regular expressions. This will exclude all matches in "somedirectory/name":

git secrets --add --allowed '^\./somedirectory/name:.*'

@olbrew
Copy link

olbrew commented Dec 28, 2017

I'm a bit stuck here. I have a dependency in the node_modules directory which is causing a lot of false positives. However I change or update your example it doesn't work for me. Using your regex adapted to ^\./directory/relative/to/root:.*' still gives errors in the specified directory.
Ideally I want to exclude all all node_modules directories and all subdirectories occurring anywhere in my project. A simple regex such as '*node_modules/*' looks like it should do the job but it doesn't work either. Anyone an idea of how to solve this?

@dizzersee
Copy link

dizzersee commented Feb 12, 2020

@olbrew Did you solve the issue?

// edit

I managed to get it work like that:
allowed = dir/file:.*

Adding that in .git/config under [secrets] worked, it ignores all matches in the file.

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

No branches or pull requests

4 participants