-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add algolia key support #866
Merged
zricethezav
merged 3 commits into
gitleaks:master
from
SimonGurney:add-algolia-key-support
May 25, 2022
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: add algolia key to generator
- Loading branch information
commit f3df0c5ae3fd840710973cbb463abfcbe0b1f44d
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package rules | ||
|
||
import ( | ||
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets" | ||
"github.com/zricethezav/gitleaks/v8/config" | ||
) | ||
|
||
func AlgoliaApiKey() *config.Rule { | ||
// define rule | ||
r := config.Rule{ | ||
Description: "Algolia API Key", | ||
RuleID: "algolia-api-key", | ||
Regex: generateUniqueTokenRegex(`[a-z0-9]{32}`), | ||
Keywords: []string{"algolia"}, | ||
} | ||
|
||
// validate | ||
tps := []string{ | ||
"algolia_key := " + secrets.NewSecret(hex("32")), | ||
} | ||
return validate(r, tps, nil) | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@SimonGurney this should use generateSemiGenericRegex since the algolia token does not have any unique prefix/suffix that is part of the rule. This will slightly change the generated regular expression.
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.
hmmm, I thought the opposite was true... It has no unique suffix/prefix so would use the unique token regex rather than generateSemiGenericRegex which wants unique identifiers?
I must have misread it.
I can't compile the go to test, I'll have to leave it you
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.
Using the
generateUniqueTokenRegex
means the regular expression can be less strict as there are uniquely identifiable patterns within the token. UsinggenerateSemiGenericRegex
means that the token follows a generic api token format like a 32 alphanumeric character sequence in this case.No worries, this functionality isn't really documented anywhere and is a work in progress. The config generation
cmd
was really just a forcing function for me to finally get the default gitleaks rules in order.I can merge this as is then update the code so you get contribution credit if you'd like
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.
Sounds like a plan 👍