Skip to content

Bannerbear Detector V2 #4222

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

Merged

Conversation

shahzadhaider1
Copy link
Contributor

@shahzadhaider1 shahzadhaider1 commented Jun 13, 2025

Description:

This pull request introduces a new V2 detector for Bannerbear API keys. The new version adds support for modern key formats and implements live API verification to eliminate false positives.

Implementation Details

  • New V2 Detector: A new bannerbearv2 detector was created to house the updated logic.
  • Precise Regex: The detector uses the pattern \b(bb_(?:pr|ma)_[a-f0-9]{30})\b to accurately identify both key formats.
  • API Verification: A verification function calls the GET /v2/auth endpoint.
    • A 200 OK response validates a Project API Key.
    • A 400 Bad Request with a specific error message validates a Master API Key, in line with the official API documentation.
  • Keywords: Added bannerbear, bb_pr_, and bb_ma_ to the keyword list for efficient scanning.

Testing

To ensure correctness and reliability, this change includes:

  • Pattern Tests: Tests validating the regex against positive and negative samples.
  • Integration Tests: Live API tests confirming the verification logic for valid Project keys and invalid keys.

Closes OSS-143

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

bannerbear-detector-tests

@shahzadhaider1 shahzadhaider1 requested review from a team as code owners June 13, 2025 13:17
@shahzadhaider1 shahzadhaider1 force-pushed the feat/OSS-143-banner-bear-v2 branch from c87f902 to fdaaacc Compare June 13, 2025 13:20
@shahzadhaider1 shahzadhaider1 force-pushed the feat/OSS-143-banner-bear-v2 branch from fdaaacc to b8285a3 Compare June 13, 2025 13:23
@shahzadhaider1 shahzadhaider1 self-assigned this Jun 13, 2025
@shahzadhaider1 shahzadhaider1 requested a review from abmussani June 19, 2025 03:59

// docs: https://developers.bannerbear.com/
func (s Scanner) verifyBannerBear(ctx context.Context, client *http.Client, key string) (bool, map[string]string, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://api.bannerbear.com/v2/auth", http.NoBody)
Copy link
Contributor

Choose a reason for hiding this comment

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

We are using same API to verify V1 and V2 secret types. Why are we not using same function in both versions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kashifkhan0771 The V2 verification function includes specific logic to differentiate between Project and Master API keys. Since this additional processing is not required for V1 keys (although we could still use the same function, which would make things complex), I decided against merging them to keep the V1 verifier clean and straightforward.

Copy link
Contributor

@amanfcp amanfcp left a comment

Choose a reason for hiding this comment

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

LGTM!

@shahzadhaider1 shahzadhaider1 merged commit bb47e8f into trufflesecurity:main Jun 24, 2025
13 checks passed
@shahzadhaider1 shahzadhaider1 deleted the feat/OSS-143-banner-bear-v2 branch June 24, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants