Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork1.7k
Feat/Passing multiple arguments to dir#1750
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
PR is currently WIP. There is still some testing necessary if the changes have any impact on the core functionalities (e.g. passing config file path, gitleaks-ignore-path etc.) I am happy for any volunteer that reviews the changes and tests Detector functionalities. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is a good base.
I have a few suggestions to streamline the approach a bit. You can apply this withgit apply patch.txt
:patch.txt
cmd/directory.go Outdated
var allFindings []report.Finding | ||
start := time.Now() | ||
findingsMap := make(map[string]report.Finding) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What's the purpose of this map? Wouldn't it technically change the behaviour of how things are reported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
From my point of view the behavior itself would not change. The only reason for creating the map is to remove redundant findings by overriding them with the same fingerprint. Otherwise the report would not be accurate anymore when e.g. scanning a root directory with a child directory.
You can test this by scanning the./testdata
directory with./testdata/repos/nogit
as additional argument.
cmd/directory.go Outdated
for _, finding := range findings { | ||
findingsMap[finding.Fingerprint] = finding | ||
} | ||
detector = det |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is an unfortunate consequence ofconfiguring report output underDetector
. I don't know if there's a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I see your point. In general, more testing is required from my end as new Detector structs will be initialized for each directory. This basically has an impact on all cli flag that you pass in.
Will think about a better way, ideally there is only one Detector initialized that stores all flags with e.g. absolute paths for config files etc
Can you elaborate? It sounds like the results are the same?
|
Update Test Case 1
Test Case 2
Even with passing a custom toml I haven't noticed any issues with the changes. Since the value of config flag is the only one used to setup the gitleaks config I assume that the changes made within this MR do not have an impact on how the detector is initialized. To-Do Test and adjust the logging while initializing new detectors. You can see e.g. in Output from scanning 2 directories: gitleaks dir testdata/config testdata/repos -c gitleaks-test.toml -l debug ○ │╲ │ ○ ○ ░ ░ gitleaks10:38PM DBG using github.com/wasilibs/go-re2 regex engine10:38PM DBG using gitleaks config gitleaks-test.toml from`--config`10:38PM DBG found .gitleaksignore file: .gitleaksignore10:38PM DBG using github.com/wasilibs/go-re2 regex engine10:38PM DBG using gitleaks config gitleaks-test.toml from`--config`10:38PM DBG found .gitleaksignore file: .gitleaksignore10:38PM DBG Skipping symlink path=testdata/repos/symlinks/file_symlink/symlinked_id_ed2551910:38PM INF scanned~17007 bytes (17.01 KB)in 52.9ms10:38PM WRN leaks found: 2 |
recreator66 commentedMar 17, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@rgmz I have adopted your approach to initialize the config once while iterating over the args (= directories). In addition, I enhanced the logging within the PR is ready for review |
@rgmz is this PR still relevant? |
UnknownPlatypus commentedApr 19, 2025
Does the current state of the pr allows doing If so it's still very relevant to me to be able to fix the
|
@UnknownPlatypus yes the current state allows doing |
Uh oh!
There was an error while loading.Please reload this page.
Description:
Closes#1727
Checklist: