-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Scan commit metadata #2713
Scan commit metadata #2713
Conversation
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 cool! I never would have guessed that secrets could leak out in the author email.
// Scan the commit metadata. | ||
// See https://github.com/trufflesecurity/trufflehog/issues/2683 | ||
var ( | ||
metadata = s.sourceMetadataFunc("", email, fullHash, when, remoteURL, 0) |
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.
Can we use a magic constant filename to signal to users that the chunk came from commit metadata? I'm a little worried that a missing filename might confuse people.
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.
We could do something obvious like COMMIT
. I will mention that empty filename is currently how this is handled elsewhere, e.g., comments
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.
Ah, if this isn't a new approach I'm less concerned about it, but it still seems like if it's low-hanging fruit we might as well grab it while we're here. I'll leave the decision on fruit height up to you.
6de32aa
to
76d5cb5
Compare
76d5cb5
to
e4f4af8
Compare
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.
@@ -22,7 +22,7 @@ import ( | |||
|
|||
const ( | |||
// defaultDateFormat is the standard date format for git. | |||
defaultDateFormat = "Mon Jan 02 15:04:05 2006 -0700" | |||
defaultDateFormat = "Mon Jan 2 15:04:05 2006 -0700" |
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 believe this is a bug as git log
appears to use d
and not dd
formatting. It's unclear if or how frequently this failure occurred, as the logging in isDateLine
/isAuthorDateLine
was level 2.
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.
cool stuff!
// Scan the commit metadata. | ||
// See https://github.com/trufflesecurity/trufflehog/issues/2683 | ||
var ( | ||
metadata = s.sourceMetadataFunc("", email, fullHash, when, remoteURL, 0) |
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.
Ah, if this isn't a new approach I'm less concerned about it, but it still seems like if it's low-hanging fruit we might as well grab it while we're here. I'll leave the decision on fruit height up to you.
Linting issues seem to be carried over from #2643. https://github.com/trufflesecurity/trufflehog/actions/runs/8802614804 |
@rosecodym Any idea what might be causing the
Edit: perhaps a slight mishap causing the commit to have a |
@rgmz should we revert this until we can figure out what's going on? |
Perhaps. The specific error seems to be caused by the test logic (commit + - + file); it's unclear whether that's indicative of an actual issue. trufflehog/pkg/sources/git/git_test.go Lines 249 to 251 in 81a9c81
I think it's caused by the commit metadata being sent, which is introducing new chunks that aren't accounted for. trufflehog/pkg/sources/git/git_test.go Lines 182 to 184 in 81a9c81
|
Ok, I'm going to revert. Thanks for catching this so early! |
This reverts commit 81a9c81.
This is a follow-up to #2713 that fixes the strange test error. As suspected, the failure was caused by additional diffs not being included in the test's expected data.
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [trufflesecurity/trufflehog](https://togithub.com/trufflesecurity/trufflehog) | action | minor | `v3.74.0` -> `v3.75.0` | --- ### Release Notes <details> <summary>trufflesecurity/trufflehog (trufflesecurity/trufflehog)</summary> ### [`v3.75.0`](https://togithub.com/trufflesecurity/trufflehog/releases/tag/v3.75.0) [Compare Source](https://togithub.com/trufflesecurity/trufflehog/compare/v3.74.0...v3.75.0) #### What's Changed - \[chore] - update buffer metrics by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2737](https://togithub.com/trufflesecurity/trufflehog/pull/2737) - fix(deps): update module github.com/aws/aws-sdk-go to v1.51.28 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2741](https://togithub.com/trufflesecurity/trufflehog/pull/2741) - chore(deps): update golangci/golangci-lint-action action to v5 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2744](https://togithub.com/trufflesecurity/trufflehog/pull/2744) - Scan commit metadata by [@​rgmz](https://togithub.com/rgmz) in [https://github.com/trufflesecurity/trufflehog/pull/2713](https://togithub.com/trufflesecurity/trufflehog/pull/2713) - Fix SQL Server detector tests by [@​rosecodym](https://togithub.com/rosecodym) in [https://github.com/trufflesecurity/trufflehog/pull/2716](https://togithub.com/trufflesecurity/trufflehog/pull/2716) - Revert "Scan commit metadata" by [@​rosecodym](https://togithub.com/rosecodym) in [https://github.com/trufflesecurity/trufflehog/pull/2747](https://togithub.com/trufflesecurity/trufflehog/pull/2747) - \[bug] - Refactor newDiff constructor to avoid double initialization of contentWriter by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2742](https://togithub.com/trufflesecurity/trufflehog/pull/2742) - \[chore] - update buffered file writer metric by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2740](https://togithub.com/trufflesecurity/trufflehog/pull/2740) - \[refactor] - lazy buffer retrieval by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2745](https://togithub.com/trufflesecurity/trufflehog/pull/2745) - \[chore] Remove broken test by [@​mcastorina](https://togithub.com/mcastorina) in [https://github.com/trufflesecurity/trufflehog/pull/2748](https://togithub.com/trufflesecurity/trufflehog/pull/2748) - \[bug] - fix buffer size metric by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2749](https://togithub.com/trufflesecurity/trufflehog/pull/2749) - \[bug] - Fix the metric for buffered file writer writes by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2750](https://togithub.com/trufflesecurity/trufflehog/pull/2750) - fix(deps): update module github.com/aws/aws-sdk-go to v1.51.29 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2751](https://togithub.com/trufflesecurity/trufflehog/pull/2751) - update integration logos by [@​dustin-decker](https://togithub.com/dustin-decker) in [https://github.com/trufflesecurity/trufflehog/pull/2752](https://togithub.com/trufflesecurity/trufflehog/pull/2752) - fix(deps): update module github.com/aws/aws-sdk-go to v1.51.30 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2756](https://togithub.com/trufflesecurity/trufflehog/pull/2756) - \[chore] - add additional binary extension by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2760](https://togithub.com/trufflesecurity/trufflehog/pull/2760) - pkg: fix function names in comment by [@​mountcount](https://togithub.com/mountcount) in [https://github.com/trufflesecurity/trufflehog/pull/2761](https://togithub.com/trufflesecurity/trufflehog/pull/2761) - \[chore] - ignore pbix and vsdx files by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2762](https://togithub.com/trufflesecurity/trufflehog/pull/2762) - fix(deps): update module github.com/aws/aws-sdk-go to v1.51.31 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2763](https://togithub.com/trufflesecurity/trufflehog/pull/2763) - Scan commit metadata by [@​rgmz](https://togithub.com/rgmz) in [https://github.com/trufflesecurity/trufflehog/pull/2754](https://togithub.com/trufflesecurity/trufflehog/pull/2754) - \[bug] - Correctly set metrics for enumerated orgs by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2757](https://togithub.com/trufflesecurity/trufflehog/pull/2757) - \[chore ] -Update ignore extensions by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2764](https://togithub.com/trufflesecurity/trufflehog/pull/2764) - \[chore] Add some happy path logs to GitLab by [@​mcastorina](https://togithub.com/mcastorina) in [https://github.com/trufflesecurity/trufflehog/pull/2765](https://togithub.com/trufflesecurity/trufflehog/pull/2765) - Fix Git source test by [@​rgmz](https://togithub.com/rgmz) in [https://github.com/trufflesecurity/trufflehog/pull/2767](https://togithub.com/trufflesecurity/trufflehog/pull/2767) - \[feat] - buffered file reader by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2731](https://togithub.com/trufflesecurity/trufflehog/pull/2731) - \[feat] - Add ReadFrom method to BufferedFileWriter by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2759](https://togithub.com/trufflesecurity/trufflehog/pull/2759) - fix(deps): update module google.golang.org/protobuf to v1.34.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2766](https://togithub.com/trufflesecurity/trufflehog/pull/2766) - \[bug] - Improve BufferedFileReader Close Behavior by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2768](https://togithub.com/trufflesecurity/trufflehog/pull/2768) - fixes calendly api key regex by [@​ankushgoel27](https://togithub.com/ankushgoel27) in [https://github.com/trufflesecurity/trufflehog/pull/2368](https://togithub.com/trufflesecurity/trufflehog/pull/2368) - Expose detector-specific false positive logic by [@​rosecodym](https://togithub.com/rosecodym) in [https://github.com/trufflesecurity/trufflehog/pull/2743](https://togithub.com/trufflesecurity/trufflehog/pull/2743) - Detector-Fix: Reintroduce Cloudflareglobalapikey by [@​ankushgoel27](https://togithub.com/ankushgoel27) in [https://github.com/trufflesecurity/trufflehog/pull/2101](https://togithub.com/trufflesecurity/trufflehog/pull/2101) - Detector-Competition-Fix - fixed the alchemy detector regex by [@​ankushgoel27](https://togithub.com/ankushgoel27) in [https://github.com/trufflesecurity/trufflehog/pull/1821](https://togithub.com/trufflesecurity/trufflehog/pull/1821) - fix(deps): update module github.com/aws/aws-sdk-go to v1.51.32 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2769](https://togithub.com/trufflesecurity/trufflehog/pull/2769) - fix(deps): update module google.golang.org/api to v0.177.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/trufflesecurity/trufflehog/pull/2770](https://togithub.com/trufflesecurity/trufflehog/pull/2770) - \[chore] - update imports by [@​ahrav](https://togithub.com/ahrav) in [https://github.com/trufflesecurity/trufflehog/pull/2772](https://togithub.com/trufflesecurity/trufflehog/pull/2772) - adds build version to finished scanning log by [@​zricethezav](https://togithub.com/zricethezav) in [https://github.com/trufflesecurity/trufflehog/pull/2773](https://togithub.com/trufflesecurity/trufflehog/pull/2773) - Update rabbitmq.go regex detect amqps protocol by [@​NikhilPanwar](https://togithub.com/NikhilPanwar) in [https://github.com/trufflesecurity/trufflehog/pull/2609](https://togithub.com/trufflesecurity/trufflehog/pull/2609) - fix for infinite recursion in Postman var sub by [@​zricethezav](https://togithub.com/zricethezav) in [https://github.com/trufflesecurity/trufflehog/pull/2780](https://togithub.com/trufflesecurity/trufflehog/pull/2780) #### New Contributors - [@​mountcount](https://togithub.com/mountcount) made their first contribution in [https://github.com/trufflesecurity/trufflehog/pull/2761](https://togithub.com/trufflesecurity/trufflehog/pull/2761) **Full Changelog**: trufflesecurity/trufflehog@v3.74.0...v3.75.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/matter-labs/vault-auth-tee). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMzEuMCIsInVwZGF0ZWRJblZlciI6IjM3LjMzMS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
Description:
This fixes #2683. It scans the commit author, committer (which is typically
GitHub <noreply@github.com>
for GitHub, but can be different), and message.Admittedly, this implementation is a bit of guess-work and may not be the best way.
Checklist:
make test-community
)?make lint
this requires golangci-lint)?