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

Improving GoogleApiKeyValidator #229

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Src/Plugins/Security/SEC101_003.GoogleApiKeyValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ protected override string IsValidDynamicHelper(ref string fingerprintText,
const string Deleted = "RequestDenied: This API project was not found. This API project may have been deleted or may not be authorized to use this API. You may need to enable the API under APIs in the console).";
const string KeyNotAuthorized = "RequestDenied: This API key is not authorized to use this service or API.";
const string ProjectNotAuthorized = "RequestDenied: This API project is not authorized to use this API.";
const string IpNotAuthorized = "RequestDenied: This IP, site or mobile application is not authorized to use this API key.";
Copy link
Member

Choose a reason for hiding this comment

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

IpNotAuthorized [](start = 25, length = 15)

This is not the right change. 'NoMatch' indicates a false positive. Both these conditions indicate that we did in fact find a match and that the key was actually secured in some way. We can't take this change, we can discuss more offline.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could add Pass to the ValidationState and in the SearchSkimmer, if we get a pass, we change the kind to pass as well. Should we leave error as warning or should we change as well?


In reply to: 578522731 [](ancestors = 578522731)

const string Invalid = "RequestDenied: The provided API key is invalid.";
const string Expired = "RequestDenied: The provided API key is expired.";
const string RefererRestricted = "RequestDenied: API keys with referer restrictions cannot be used with this API";

var fingerprint = new Fingerprint(fingerprintText);

Expand Down Expand Up @@ -108,6 +110,8 @@ protected override string IsValidDynamicHelper(ref string fingerprintText,
}

case Invalid:
case IpNotAuthorized:
case RefererRestricted:
{
return nameof(ValidationState.NoMatch);
}
Expand Down