mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-30 13:14:22 +01:00
feat: add artifactory reference token and api key detection (#1906)
* feat: add artifactory reference token and api key detection * fix: match word boundary, add false positive tests * fix: increase minimum entropy and fix tests
This commit is contained in:
1 parent
bf380d4767
commit
a044b815b3
3 files changed
+74
No files matched your search
@@ -35,6 +35,8 @@ func main() {
|
|||||||
rules.AlgoliaApiKey(),
|
rules.AlgoliaApiKey(),
|
||||||
rules.AlibabaAccessKey(),
|
rules.AlibabaAccessKey(),
|
||||||
rules.AlibabaSecretKey(),
|
rules.AlibabaSecretKey(),
|
||||||
|
rules.ArtifactoryApiKey(),
|
||||||
|
rules.ArtifactoryReferenceToken(),
|
||||||
rules.AsanaClientID(),
|
rules.AsanaClientID(),
|
||||||
rules.AsanaClientSecret(),
|
rules.AsanaClientSecret(),
|
||||||
rules.Atlassian(),
|
rules.Atlassian(),
|
||||||
|
|||||||
@@ -0,0 +1,58 @@
|
|||||||
|
package rules
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/config"
|
||||||
|
"github.com/zricethezav/gitleaks/v8/regexp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ArtifactoryApiKey() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "artifactory-api-key",
|
||||||
|
Description: "Detected an Artifactory api key, posing a risk unauthorized access to the central repository.",
|
||||||
|
Regex: regexp.MustCompile(`\bAKCp[A-Za-z0-9]{69}\b`),
|
||||||
|
Entropy: 4.5,
|
||||||
|
Keywords: []string{"AKCp"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
"artifactoryApiKey := \"AKCp" + secrets.NewSecret(utils.AlphaNumeric("69")) + "\"",
|
||||||
|
}
|
||||||
|
// false positives
|
||||||
|
fps := []string{
|
||||||
|
`lowEntropy := AKCpXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
||||||
|
"wrongStart := \"AkCp" + secrets.NewSecret(utils.AlphaNumeric("69")) + "\"",
|
||||||
|
"wrongLength := \"AkCp" + secrets.NewSecret(utils.AlphaNumeric("59")) + "\"",
|
||||||
|
"partOfAlongUnrelatedBlob gYnkgAkCp" + secrets.NewSecret(utils.AlphaNumeric("69")) + "VyZSB2",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ArtifactoryReferenceToken() *config.Rule {
|
||||||
|
// define rule
|
||||||
|
r := config.Rule{
|
||||||
|
RuleID: "artifactory-reference-token",
|
||||||
|
Description: "Detected an Artifactory reference token, posing a risk of impersonation and unauthorized access to the central repository.",
|
||||||
|
Regex: regexp.MustCompile(`\bcmVmd[A-Za-z0-9]{59}\b`),
|
||||||
|
Entropy: 4.5,
|
||||||
|
Keywords: []string{"cmVmd"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate
|
||||||
|
tps := []string{
|
||||||
|
"artifactoryRefToken := \"cmVmd" + secrets.NewSecret(utils.AlphaNumeric("59")) + "\"",
|
||||||
|
}
|
||||||
|
// false positives
|
||||||
|
fps := []string{
|
||||||
|
`lowEntropy := cmVmdXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX`,
|
||||||
|
"wrongStart := \"cmVMd" + secrets.NewSecret(utils.AlphaNumeric("59")) + "\"",
|
||||||
|
"wrongLength := \"cmVmd" + secrets.NewSecret(utils.AlphaNumeric("49")) + "\"",
|
||||||
|
"partOfAlongUnrelatedBlob gYnkgcmVmd" + secrets.NewSecret(utils.AlphaNumeric("59")) + "VyZSB2",
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.Validate(r, tps, fps)
|
||||||
|
}
|
||||||
@@ -129,6 +129,20 @@ regex = '''(?i)[\w.-]{0,50}?(?:alibaba)(?:[ \t\w.-]{0,20})[\s'"]{0,3}(?:=|>|:{1,
|
|||||||
entropy = 2
|
entropy = 2
|
||||||
keywords = ["alibaba"]
|
keywords = ["alibaba"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
id = "artifactory-api-key"
|
||||||
|
description = "Detected an Artifactory api key, posing a risk unauthorized access to the central repository."
|
||||||
|
regex = '''\bAKCp[A-Za-z0-9]{69}\b'''
|
||||||
|
entropy = 4.5
|
||||||
|
keywords = ["akcp"]
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
id = "artifactory-reference-token"
|
||||||
|
description = "Detected an Artifactory reference token, posing a risk of impersonation and unauthorized access to the central repository."
|
||||||
|
regex = '''\bcmVmd[A-Za-z0-9]{59}\b'''
|
||||||
|
entropy = 4.5
|
||||||
|
keywords = ["cmvmd"]
|
||||||
|
|
||||||
[[rules]]
|
[[rules]]
|
||||||
id = "asana-client-id"
|
id = "asana-client-id"
|
||||||
description = "Discovered a potential Asana Client ID, risking unauthorized access to Asana projects and sensitive task information."
|
description = "Discovered a potential Asana Client ID, risking unauthorized access to Asana projects and sensitive task information."
|
||||||
|
|||||||
Reference in new issue
Block a user