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

initial support for bare repositories #1499

Merged

Conversation

savely-krasovsky
Copy link
Contributor

This PR adds support for bare repositories. It's especially useful to use with pre-receive hooks. Currently it's a draft, at least because go-git has a bug in upstream which doesn't allow to scan incoming commits in pre-receive hooks.

@CLAassistant
Copy link

CLAassistant commented Jul 15, 2023

CLA assistant check
All committers have signed the CLA.

@savely-krasovsky savely-krasovsky marked this pull request as ready for review July 15, 2023 15:11
@savely-krasovsky savely-krasovsky requested review from a team as code owners July 15, 2023 15:11
@savely-krasovsky
Copy link
Contributor Author

go-git changes also under review currently: go-git/go-git#812

go.mod Outdated Show resolved Hide resolved
@zricethezav
Copy link
Collaborator

Adding Draft label until the issue with go-git has been resolved

@zricethezav zricethezav changed the title feat: initial support for bare repositories DRAFT: initial support for bare repositories Jul 17, 2023
…f os.Environ

Signed-off-by: Savely Krasovsky <savely@krasovs.ky>
Signed-off-by: Savely Krasovsky <savely@krasovs.ky>
@savely-krasovsky
Copy link
Contributor Author

@zricethezav go-git team has merged my fix. In my opinion gitparse_test.go has not full .git repository tests. We need fixtures with usual and bare repos to test against them.

README.md Outdated Show resolved Hide resolved
@savely-krasovsky
Copy link
Contributor Author

savely-krasovsky commented Jul 21, 2023

Oh, go-git team have just released v5.8.0 with my fix, merged changes to go.mod and go.sum accordingly.

@dustin-decker
Copy link
Contributor

I just merged go-git v5.8.1 into TruffleHog @L11R

@savely-krasovsky
Copy link
Contributor Author

@dustin-decker nice! Can someone from your team review it again? I fixed issues with doc and dependencies.

@zricethezav zricethezav changed the title DRAFT: initial support for bare repositories initial support for bare repositories Aug 2, 2023
@zricethezav zricethezav added pkg/engine PRs and Issues related to the `engine` package pkg/sources PRs and Issues related to the `sources` package enhancement labels Aug 2, 2023
Copy link
Collaborator

@mcastorina mcastorina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement! I spot-tested the changes locally and it didn't scan the bare repository. Did I do something wrong?

» git clone --bare https://github.com/trufflesecurity/test_keys /tmp/test_keys.git
Cloning into bare repository '/tmp/test_keys.git'...
remote: Enumerating objects: 13, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 9
Receiving objects: 100% (13/13), done.
» ./trufflehog --no-update git --bare file:///tmp/test_keys.git
🐷🔑🐷  TruffleHog. Unearth your secrets. 🐷🔑🐷

2023-08-03T08:55:14-05:00       info-0  trufflehog      finished scanning       {"chunks": 0, "bytes": 0, "verified_secrets": 0, "unverified_secrets": 0}

Additionally, I had to update pkg/engine/git.go as the automatic merge caused a Go compilation error.

@savely-krasovsky
Copy link
Contributor Author

@mcastorina I guess the problem relates to recent git scan refactoring. Will research

…rk with the latest master

Signed-off-by: Savely Krasovsky <savely@krasovs.ky>
@savely-krasovsky
Copy link
Contributor Author

@mcastorina I've prepared a new patch, now it should work again. It was definitively after merging this: #1518

Copy link
Collaborator

@mcastorina mcastorina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, nice work!

@mcastorina mcastorina merged commit d062834 into trufflesecurity:main Aug 3, 2023
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement pkg/engine PRs and Issues related to the `engine` package pkg/sources PRs and Issues related to the `sources` package
Development

Successfully merging this pull request may close these issues.

None yet

5 participants