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

Add Bitbucket enumeration support #37

Open
Coruscant11 opened this issue Mar 4, 2023 · 5 comments
Open

Add Bitbucket enumeration support #37

Coruscant11 opened this issue Mar 4, 2023 · 5 comments
Assignees
Labels
content discovery Related to enumerating or specifying content to scan enhancement New feature or request help wanted Extra attention is needed integration Related to integration with other systems

Comments

@Coruscant11
Copy link
Contributor

Hello,
Since my company is actually working with Bitbucket, I would be glad to work in order to add the same features for Github to Bitbucket. For example listing Bitbucket project repositories, listing user repositories, and ensure that each feature of noseyparker is working on it.

I could take inspiration from the existing code for Github and make a Bitbucket version.
Why not GitLab too in the future?
😄

@bradlarsen bradlarsen added the enhancement New feature or request label Mar 6, 2023
@bradlarsen
Copy link
Collaborator

Hello again @Coruscant11 :)

Yes, having support for enumerating repositories from Bitbucket would be welcome.

I'm not all that familiar with Bitbucket. It looks like they have a cloud-hosted offering as well as self-hosted options. Which type of deployment is most relevant to you? I would start with getting that working.

I took a quick look at things, and have some high-level notes and pointers for you:

  • In Nosey Parker, the GitHub repository enumeration code is used in just two places currently: in the scan command, and in the github command. In both cases, the high-level wrapper function is noseyparker::github::enumerate_repo_urls, which is a synchronous API that takes the set of requested users/orgs as input and simply returns a vector of repo URLs. Internally, it uses async functions, but that's all hidden for now.

  • I didn't see an existing Bitbucket API library on crates.io, so building something simple for the Bitbucket APIs you need using the reqwest libraryis a reasonable path. (That's what I ended up doing for GitHub support, because the existing octocrab library was pretty big and didn't actually support the APIs I needed.)

  • Nosey Parker's GitHub support has a ClientBuilder, used to specify how to initialize an actual Client object that makes the API requests. You could introduce similar types in a new bitbucket module.

  • Nosey Parker's GitHub code only currently supports bearer token-based authentication. In Bitbucket, it looks like many different authentication schemes are supported, though it looks like in the examples that simpler bearer token-based authentication should work. I'd start with that, unless your use case needs something different.

  • In Nosey Parker, if someone wants to use a GitHub token, they must specify it via the NP_GITHUB_TOKEN environment variable. You could introduce a similar NP_BITBUCKET_TOKEN variable.

  • It looks like this Bitbucket API endpoint may be the most relevant. It can take filter parameters to restrict the scope to particular users or workspaces. (A "workspace" is a Bitbucket version of a GitHub organization?)

  • The pagination in Bitbucket responses seems to use the same kind of mechanism as GitHub's APIs, so you could probably adapt Nosey Parker's GitHub code for that. Specifically, this and this.

  • Nosey Parker's GitHub support detects and reports rate-limiting failures, but currently makes no attempt to retry failing requests.

@bradlarsen
Copy link
Collaborator

Again, I'm happy to answer any questions you may have about this!

@Coruscant11
Copy link
Contributor Author

Great answer as always!

Yes, the main goal would be to allow people to also scan their private Bitbucket server. Like in my case for my company. Normally, the cloud and the self-hosted has the same API scheme, so just giving the Bitbucket URL to Nosey Parker should be enough.
As you said, we only need to call the API in order to find the git url, and reqwest should do the work perfectly.

We can generate authentication token with Bitbucket, and I think that it should be the way to use authentication on tools like scanners. Users should use read-only tokens for this kind of stuff and that is why I think that only supporting bearer token-based authentication is a good thing.

I will try to work on it and keep you updated if I need something!
Thank you so much 😃

@bradlarsen bradlarsen added the content discovery Related to enumerating or specifying content to scan label Apr 5, 2023
@bradlarsen bradlarsen changed the title Add Bitbucket support Add Bitbucket enumeration support Apr 19, 2023
@bradlarsen bradlarsen added the integration Related to integration with other systems label Jun 14, 2023
@Coruscant11
Copy link
Contributor Author

Hello, sorry I was quite busy the past months. I will work on this issue very soon 😄

@bradlarsen
Copy link
Collaborator

No problem at all :)

@bradlarsen bradlarsen added the help wanted Extra attention is needed label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content discovery Related to enumerating or specifying content to scan enhancement New feature or request help wanted Extra attention is needed integration Related to integration with other systems
Projects
None yet
Development

No branches or pull requests

2 participants