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

Fix/saucelabs detector #3696

Merged

Conversation

kashifkhan0771
Copy link
Contributor

@kashifkhan0771 kashifkhan0771 commented Nov 29, 2024

Description:

This PR fixes the SauceLabs detector. It fixes the username pattern and overall logic.

Checklist:

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

@kashifkhan0771 kashifkhan0771 requested a review from a team as a code owner November 29, 2024 17:15
pkg/detectors/saucelabs/saucelabs.go Outdated Show resolved Hide resolved
@@ -91,3 +78,30 @@ func (s Scanner) Type() detectorspb.DetectorType {
func (s Scanner) Description() string {
return "A service for cross browser testing, API keys can create and access tests from potentially sensitive internal websites"
}

func verifySauceLabKey(ctx context.Context, client *http.Client, userName, key string) (bool, error) {
req, err := http.NewRequestWithContext(ctx, "GET", "https://api.eu-central-1.saucelabs.com/team-management/v1/teams", nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

What about us-west and us-east?

Copy link
Contributor Author

@kashifkhan0771 kashifkhan0771 Dec 2, 2024

Choose a reason for hiding this comment

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

I thought about that and the solution I have on my mind is to search for base URL in chunk, if found use that else used a fixed one. What do you think? Earlier we were only using one.
Also during testing I noticed that if we hit a URL which we do not have access to with valid token it gives us 403 and if token is incorrect we get 401.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rgmz can you check now? If current approach looks ok to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's probably fine. I did something similar here.

In theory, I think you're supposed to use CloudProvider / EndpointCustomizer / EndpointSetter; I have no clue how tf to actually use them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that is to provide users the functionality to pass their own custom endpoints for the application/software vs using the default cloud endpoint. Here we have only three fix endpoints to choose from. Correct me @mcastorina If I am wrong about the usage of EndpointCustomizer.

@zricethezav zricethezav merged commit 3f85b16 into trufflesecurity:main Dec 2, 2024
13 checks passed
@kashifkhan0771 kashifkhan0771 deleted the fix/saucelabs-detector branch December 3, 2024 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants