* Convert a gitleaks rule ID (kebab-case) to a human-readable label. * e.g., "github-pat" → "GitHub PAT", "aws-access-token" → "AWS Access Token"
(ruleId: string)
| 241 | * e.g., "github-pat" → "GitHub PAT", "aws-access-token" → "AWS Access Token" |
| 242 | */ |
| 243 | function ruleIdToLabel(ruleId: string): string { |
| 244 | // Words where the canonical capitalization differs from title case |
| 245 | const specialCase: Record<string, string> = { |
| 246 | aws: 'AWS', |
| 247 | gcp: 'GCP', |
| 248 | api: 'API', |
| 249 | pat: 'PAT', |
| 250 | ad: 'AD', |
| 251 | tf: 'TF', |
| 252 | oauth: 'OAuth', |
| 253 | npm: 'NPM', |
| 254 | pypi: 'PyPI', |
| 255 | jwt: 'JWT', |
| 256 | github: 'GitHub', |
| 257 | gitlab: 'GitLab', |
| 258 | openai: 'OpenAI', |
| 259 | digitalocean: 'DigitalOcean', |
| 260 | huggingface: 'HuggingFace', |
| 261 | hashicorp: 'HashiCorp', |
| 262 | sendgrid: 'SendGrid', |
| 263 | } |
| 264 | return ruleId |
| 265 | .split('-') |
| 266 | .map(part => specialCase[part] ?? capitalize(part)) |
| 267 | .join(' ') |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Scan a string for potential secrets. |
no test coverage detected