mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 05:04:22 +01:00
fix(rules): add entropy (#1580)
This commit is contained in:
1 parent
9152eaa57a
commit
8cfa6b2e43
5 files changed
+108
-45
No files matched your search
@@ -9,24 +9,34 @@ import (
|
||||
func InfracostAPIToken() *config.Rule {
|
||||
// define rule
|
||||
r := config.Rule{
|
||||
// Human readable description of the rule
|
||||
RuleID: "infracost-api-token",
|
||||
Description: "Detected an Infracost API Token, risking unauthorized access to cloud cost estimation tools and financial data.",
|
||||
|
||||
// Unique ID for the rule
|
||||
RuleID: "infracost-api-token",
|
||||
|
||||
// Regex capture group for the actual secret
|
||||
|
||||
// Regex used for detecting secrets. See regex section below for more details
|
||||
Regex: utils.GenerateUniqueTokenRegex(`ico-[a-zA-Z0-9]{32}`, true),
|
||||
|
||||
// Keywords used for string matching on fragments (think of this as a prefilter)
|
||||
Keywords: []string{"ico-"},
|
||||
Regex: utils.GenerateUniqueTokenRegex(`ico-[a-zA-Z0-9]{32}`, false),
|
||||
Entropy: 3,
|
||||
Keywords: []string{"ico-"},
|
||||
}
|
||||
|
||||
// validate
|
||||
tps := []string{
|
||||
utils.GenerateSampleSecret("ico", "ico-"+secrets.NewSecret("[A-Za-z0-9]{32}")),
|
||||
` variable {
|
||||
name = "INFRACOST_API_KEY"
|
||||
secret_value = "ico-mlCr1Mn3SRcRiZMObUZOTHLcgtH2Lpgt"
|
||||
is_secret = true
|
||||
}`,
|
||||
// TODO: New format with longer keys?
|
||||
// ` headers = {
|
||||
//'X-Api-Key': 'ico-EeDdSfctrmjD14f45f45te5gJ7l6lw4o6M36sXT62a6',
|
||||
//'Content-Type': 'application/json',
|
||||
//}`,
|
||||
}
|
||||
return utils.Validate(r, tps, nil)
|
||||
fps := []string{
|
||||
// Low entropy
|
||||
`ico-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
||||
// Invalid
|
||||
`http://assets.r7.com/assets/media_box_tv_tres_colunas/video_box.ico-7a388b69018576d24b59331fd60aab0c.png`,
|
||||
`https://explosivelab.notion.site/Pianificazione-Nerdz-Ng-pubblico-1bc826ecc0994dd8915be97fc3489cde?pvs=74`,
|
||||
`http://ece252-2.uwaterloo.ca:2540/image?q=gAAAAABdHkoqb9ZaJ3q4dlzEvTgG9WYwKcD9Aw7OUXeFicO-5M5IdNDjHBpKw7KBK3nCVqtuga4yzUaFEpJn8BqA1LzZprIJBw==`,
|
||||
}
|
||||
return utils.Validate(r, tps, fps)
|
||||
}
|
||||
Reference in new issue
Block a user