openai.go 797 B

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