openai.go 685 B

12345678910111213141516171819202122232425
  1. package rules
  2. import (
  3. "github.com/zricethezav/gitleaks/v8/cmd/generate/secrets"
  4. "github.com/zricethezav/gitleaks/v8/config"
  5. )
  6. func OpenAI() *config.Rule {
  7. // define rule
  8. r := config.Rule{
  9. RuleID: "openai-api-key",
  10. Description: "Found an OpenAI API Key, posing a risk of unauthorized access to AI services and data manipulation.",
  11. Regex: generateUniqueTokenRegex(`sk-[a-zA-Z0-9]{20}T3BlbkFJ[a-zA-Z0-9]{20}`, true),
  12. Keywords: []string{
  13. "T3BlbkFJ",
  14. },
  15. }
  16. // validate
  17. tps := []string{
  18. generateSampleSecret("openaiApiKey", "sk-"+secrets.NewSecret(alphaNumeric("20"))+"T3BlbkFJ"+secrets.NewSecret(alphaNumeric("20"))),
  19. }
  20. return validate(r, tps, nil)
  21. }