-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Added detector for JFrog Artifactory Reference Tokens #4684
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
base: main
Are you sure you want to change the base?
Added detector for JFrog Artifactory Reference Tokens #4684
Conversation
| for token := range uniqueTokens { | ||
| for url := range uniqueUrls { | ||
| if invalidHosts.Exists(url) { | ||
| delete(uniqueUrls, url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any value with deleting the url from uniqueUrls. Also it might lead to unexpected behaviors if we mutate the slice we're looping over.
mustansir14
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| for url := range uniqueUrls { | ||
| if invalidHosts.Exists(url) { | ||
| delete(uniqueUrls, url) | ||
| continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map mutation during iteration causes missed token-URL combinations
Medium Severity
The delete(uniqueUrls, url) call modifies the uniqueUrls map while iterating over it in a nested loop. When multiple tokens exist, the first token that encounters a URL in invalidHosts removes it from uniqueUrls, causing all subsequent tokens to skip that URL entirely. This results in missed token-URL combinations. The deletion is also unnecessary since invalidHosts.Exists(url) already handles filtering on each iteration.
Summary
Adds a new detector for JFrog Artifactory Reference Tokens. Unlike JWT tokens (which start with
eyJ), reference tokens are base64-encoded strings with a predictable structure:When base64-encoded, this always produces a token starting with
cmVmdGtu.Detection
Regex pattern:
cmVmdGtu(8 chars): base64 encoding of "reftkn"Keyword:
cmVmdGtuVerification
Tokens are verified against the JFrog Access API:
This endpoint returns token metadata if valid. Available since Artifactory 7.53.1.
Response handling:
References
Checklist:
make test-community)?make lintthis requires golangci-lint)?