rules/private_key.ts

keyshade · packages/secret-scan/src/rules/private_key.ts · typescript · MPL-2.0
security, tag:knn-classified

Exports regex patterns to detect private key headers in text for security scanning.

// 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'

// eslint-disable-next-line @typescript-eslint/naming-convention
export default function private_key(): RegExp[] {
  return [
    /BEGIN DSA PRIVATE KEY/,
    /BEGIN EC PRIVATE KEY/,
    /BEGIN OPENSSH PRIVATE KEY/,
    /BEGIN PGP PRIVATE KEY BLOCK/,
    /BEGIN PRIVATE KEY/,
    /BEGIN RSA PRIVATE KEY/,
    /BEGIN SSH2 ENCRYPTED PRIVATE KEY/,
    /PuTTY-User-Key-File-2/
  ]
}

const testcase: TestCase[] = [
  {
    i

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

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

Get a free API key