mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 12:14:22 +01:00
28 lines
1.1 KiB
Go
28 lines
1.1 KiB
Go
package rules
|
|
|
|
import (
|
|
"github.com/zricethezav/gitleaks/v8/cmd/generate/config/utils"
|
|
"github.com/zricethezav/gitleaks/v8/config"
|
|
)
|
|
|
|
func Sonar() *config.Rule {
|
|
// define rule
|
|
r := config.Rule{
|
|
Description: "Uncovered a Sonar API token, potentially compromising software vulnerability scanning and code security.",
|
|
RuleID: "sonar-api-token",
|
|
Regex: utils.GenerateSemiGenericRegex([]string{"sonar[_.-]?(login|token)"}, utils.AlphaNumericExtended("40"), true),
|
|
Keywords: []string{"sonar"},
|
|
}
|
|
|
|
// validate
|
|
tps := utils.GenerateSampleSecrets("sonar", "12345678ABCDEFH1234567890ABCDEFH12345678")
|
|
tps = append(tps,
|
|
`const SONAR_LOGIN = "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
|
|
`SONAR_LOGIN := "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
|
|
`SONAR.LOGIN ::= "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
|
|
`SONAR.LOGIN :::= "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
|
|
`SONAR.LOGIN ?= "12345678ABCDEFH1234567890ABCDEFH12345678"`, // gitleaks:allow
|
|
)
|
|
return utils.Validate(r, tps, nil)
|
|
}
|