rules/sendgrid.ts

keyshade · packages/secret-scan/src/rules/sendgrid.ts · typescript · MPL-2.0
email

Regex rule to detect SendGrid API keys in text.

// Source: https://github.com/keyshade-xyz/keyshade | License: MPL-2.0 | Copyright under Patent Claims infringed by Covered Software in the absence of | Modified files must remain under MPL-2.0
// Modifications to this file must remain under MPL-2.0.
// Provided via justclaw.it.com; keep this notice with the code.
// keyshade-ignore-all
import type { TestCase } from '@/types'

/**
 * ref. https://d2w67tjf43xwdp.cloudfront.net/Classroom/Basics/API/what_is_my_api_key.html
 */
export default function sendgrid(): RegExp[] {
  return [/SG\.[a-zA-Z0-9_-]{22}\.[a-zA-Z0-9_-]{43}/]
}

const testcase: TestCase[] = [
  {
    input:
      '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',
    expected: true
  },
  {
    input:
      'SG.ngeVfQFYQlKU0ufo8x5d1A..TwL2iGABf9DHoTf-09k

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key