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

Improve Github repository scan to include remote dangling commits #2494

Open
mota-lhd opened this issue Feb 21, 2024 · 5 comments
Open

Improve Github repository scan to include remote dangling commits #2494

mota-lhd opened this issue Feb 21, 2024 · 5 comments

Comments

@mota-lhd
Copy link

mota-lhd commented Feb 21, 2024

Please review the Community Note before submitting

Description

Sometimes we also have some dangling commits on branches (merged or not) and these dangling commits contain sensitive information.

Preferred Solution

We want to

  • identify dangling commits on Github repository branches
  • run detectors on Github dangling commits

Additional Context

References

@rgmz
Copy link
Contributor

rgmz commented Feb 21, 2024

Related to #1918?

@mota-lhd mota-lhd changed the title Improve Github repository scan to include remote dangling commits and closed pull-requests Improve Github repository scan to include remote dangling commits Feb 21, 2024
@mota-lhd
Copy link
Author

Related to #1918?

part of it yes ; the dangling commits parts is not in #1918. This happens when for example somebody forces push on a remote branch.

@rgmz
Copy link
Contributor

rgmz commented Feb 21, 2024

I didn't think it was possible to access dangling commits from GitHub (e.g., GitHub retains "removed" commits but if you run git clone and then git reflog you will not see them.) Do you have an example?

@mota-lhd
Copy link
Author

yes, Github does not have an API to list remote dangling commits but there are some ways to get them.

  • get all commits in the repository through GraphQL and filter out commits that are related to pull-requests.
  • get all force-push events within a PR and try to fetch commits from that force-push commit.

long-running jobs, I agree, but worth it to unearth some juicy secrets :)

@MickaelFontes
Copy link

Hello @rgmz 👋 !

I have an example here (https://github.com/MickaelFontes/dangling-finder/blob/2e5c6e94cd5c4835a5e775c51715d45a57f0c5c2/dangling_finder/listing.py#L49-L78) to query for dangling commits created by a force push in a pull request.
(It takes some time to get the full list of force-pushed references on a big repo ~8 minutes or a repo with ~ 20k PR)

That's at least one straightforward way to find some dangling commits, since we can't directly ask for a list of all dangling commits.

There must be some other effective ways to find other dangling commits, but I'm still looking for them 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants