cohere.go 1020 B

1234567891011121314151617181920212223242526272829303132
  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 CohereAPIToken() *config.Rule {
  8. // define rule
  9. r := config.Rule{
  10. RuleID: "cohere-api-token",
  11. Description: "Identified a Cohere Token, posing a risk of unauthorized access to AI services and data manipulation.",
  12. Regex: utils.GenerateSemiGenericRegex([]string{"cohere", "CO_API_KEY"}, `[a-zA-Z0-9]{40}`, false),
  13. Entropy: 4,
  14. Keywords: []string{
  15. "cohere",
  16. "CO_API_KEY",
  17. },
  18. }
  19. // validate
  20. tps := []string{
  21. utils.GenerateSampleSecret("cohere", secrets.NewSecret(`[a-zA-Z0-9]{40}`)),
  22. // https://github.com/cohere-ai/cohere-go/blob/abe8044073ed498ffbb206a602d03c2414b64512/client/client.go#L38C30-L38C40
  23. `export CO_API_KEY=` + secrets.NewSecret(`[a-zA-Z0-9]{40}`),
  24. }
  25. fps := []string{
  26. `CO_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx`,
  27. }
  28. return utils.Validate(r, tps, fps)
  29. }