tzero-mcp 11.0.0 → 11.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +56 -56
  2. package/CONTRIBUTING.md +71 -71
  3. package/LICENSE +21 -21
  4. package/README.md +64 -64
  5. package/bin/tzero-mcp.js +62 -62
  6. package/bin/tzero.js +61 -61
  7. package/index.d.ts +25 -25
  8. package/index.js +15 -15
  9. package/package.json +89 -88
  10. package/src/addmcp.py +1203 -1197
  11. package/src/app.py +1810 -1810
  12. package/src/main.py +60 -60
  13. package/src/pc_fixer_mcp.py +25 -25
  14. package/src/tzero/__init__.py +54 -54
  15. package/src/tzero/__main__.py +6 -6
  16. package/src/tzero/siber_akademi_icon.py +77 -77
  17. package/src/tzero/tzero_arch_test.py +463 -463
  18. package/src/tzero/tzero_benchmark.py +475 -475
  19. package/src/tzero/tzero_blackboard.py +257 -257
  20. package/src/tzero/tzero_bridge.py +546 -546
  21. package/src/tzero/tzero_budget.py +195 -195
  22. package/src/tzero/tzero_card.py +431 -0
  23. package/src/tzero/tzero_ci.py +153 -153
  24. package/src/tzero/tzero_commit.py +192 -192
  25. package/src/tzero/tzero_contracts.py +1093 -1093
  26. package/src/tzero/tzero_cost.py +166 -166
  27. package/src/tzero/tzero_dashboard.py +1960 -1960
  28. package/src/tzero/tzero_debt.py +461 -461
  29. package/src/tzero/tzero_deps.py +462 -462
  30. package/src/tzero/tzero_drift.py +208 -208
  31. package/src/tzero/tzero_explain.py +306 -306
  32. package/src/tzero/tzero_features.py +3024 -3024
  33. package/src/tzero/tzero_federation.py +299 -299
  34. package/src/tzero/tzero_fix.py +557 -228
  35. package/src/tzero/tzero_fixer/__init__.py +63 -63
  36. package/src/tzero/tzero_fixer/amalgamation.py +334 -334
  37. package/src/tzero/tzero_fixer/ast_syntax_healer.py +464 -464
  38. package/src/tzero/tzero_fixer/ast_type_modernizer.py +288 -288
  39. package/src/tzero/tzero_fixer/async_io_modernizer.py +127 -127
  40. package/src/tzero/tzero_fixer/automated_regression_suite.py +600 -600
  41. package/src/tzero/tzero_fixer/benchmarks_and_diagnostics.py +174 -174
  42. package/src/tzero/tzero_fixer/ci_cd_self_healing_gate.py +246 -246
  43. package/src/tzero/tzero_fixer/code_duplicity_and_refactorer.py +151 -151
  44. package/src/tzero/tzero_fixer/code_smells_healer.py +260 -260
  45. package/src/tzero/tzero_fixer/cwe_remediator.py +171 -171
  46. package/src/tzero/tzero_fixer/dead_code_eliminator.py +150 -150
  47. package/src/tzero/tzero_fixer/dependency_vulnerability_auditor.py +309 -309
  48. package/src/tzero/tzero_fixer/git_advanced_surgeon.py +280 -280
  49. package/src/tzero/tzero_fixer/hardware_and_disk_doctor.py +325 -325
  50. package/src/tzero/tzero_fixer/import_graph_healer.py +412 -412
  51. package/src/tzero/tzero_fixer/interactive_tui.py +91 -91
  52. package/src/tzero/tzero_fixer/knowledge_base.py +295 -295
  53. package/src/tzero/tzero_fixer/knowledge_base_extended.py +940 -940
  54. package/src/tzero/tzero_fixer/linters_and_static_analyzer.py +307 -307
  55. package/src/tzero/tzero_fixer/mcp_server.py +489 -489
  56. package/src/tzero/tzero_fixer/models.py +385 -385
  57. package/src/tzero/tzero_fixer/orchestrator.py +375 -375
  58. package/src/tzero/tzero_fixer/os_doctor.py +502 -502
  59. package/src/tzero/tzero_fixer/packaging_abi_surgeon.py +323 -323
  60. package/src/tzero/tzero_fixer/pc_fixer_doctor.py +600 -600
  61. package/src/tzero/tzero_fixer/performance_and_memory_profiler.py +274 -274
  62. package/src/tzero/tzero_fixer/polyglot_ast_parsers.py +313 -313
  63. package/src/tzero/tzero_fixer/polyglot_build_healer.py +364 -364
  64. package/src/tzero/tzero_fixer/polyglot_config_healer.py +318 -318
  65. package/src/tzero/tzero_fixer/polyglot_doctor.py +372 -372
  66. package/src/tzero/tzero_fixer/polyglot_linters.py +619 -619
  67. package/src/tzero/tzero_fixer/polyglot_schema_validator.py +305 -305
  68. package/src/tzero/tzero_fixer/security_cwe_database.py +444 -444
  69. package/src/tzero/tzero_fixer/security_deep_rules.py +114 -114
  70. package/src/tzero/tzero_fixer/security_rules_catalog.py +110 -110
  71. package/src/tzero/tzero_fixer/security_zero_leak.py +326 -326
  72. package/src/tzero/tzero_fixer/smart_patch_recommender.py +223 -223
  73. package/src/tzero/tzero_fixer/synthetic_workspace_generator.py +220 -220
  74. package/src/tzero/tzero_fixer/system_diagnostics_extended.py +493 -493
  75. package/src/tzero/tzero_fixer/system_repair_recipes.py +447 -447
  76. package/src/tzero/tzero_fixer/venv_doctor.py +309 -309
  77. package/src/tzero/tzero_golden.py +319 -319
  78. package/src/tzero/tzero_graph_hud.html +338 -338
  79. package/src/tzero/tzero_graph_rag.py +263 -263
  80. package/src/tzero/tzero_growth.py +415 -0
  81. package/src/tzero/tzero_guard.py +251 -243
  82. package/src/tzero/tzero_hooks.py +565 -565
  83. package/src/tzero/tzero_infra.py +274 -274
  84. package/src/tzero/tzero_jarvis/__init__.py +134 -124
  85. package/src/tzero/tzero_jarvis/causal_graph.py +310 -310
  86. package/src/tzero/tzero_jarvis/creative_director.py +333 -0
  87. package/src/tzero/tzero_jarvis/graph_visualizer.py +395 -395
  88. package/src/tzero/tzero_jarvis/hybrid_search.py +214 -214
  89. package/src/tzero/tzero_jarvis/latent_press.py +137 -137
  90. package/src/tzero/tzero_jarvis/memory_consolidation.py +212 -212
  91. package/src/tzero/tzero_jarvis/minhash_lsh.py +184 -184
  92. package/src/tzero/tzero_jarvis/orchestrator.py +335 -335
  93. package/src/tzero/tzero_jarvis/self_healing.py +308 -308
  94. package/src/tzero/tzero_jarvis/semantic_compressor.py +887 -887
  95. package/src/tzero/tzero_jarvis/swarm.py +261 -261
  96. package/src/tzero/tzero_jarvis/swarm_bft.py +144 -144
  97. package/src/tzero/tzero_jarvis/workspace_orchestrator.py +1167 -1167
  98. package/src/tzero/tzero_jarvis/zero_key_router.py +173 -173
  99. package/src/tzero/tzero_lsp.py +634 -634
  100. package/src/tzero/tzero_mcp.py +5314 -5237
  101. package/src/tzero/tzero_mutation.py +358 -358
  102. package/src/tzero/tzero_neural_cortex.py +1425 -1425
  103. package/src/tzero/tzero_packer.py +577 -577
  104. package/src/tzero/tzero_patch.py +624 -624
  105. package/src/tzero/tzero_pc_fixer.py +12699 -12699
  106. package/src/tzero/tzero_pipe.py +95 -95
  107. package/src/tzero/tzero_polyglot.py +799 -799
  108. package/src/tzero/tzero_proxy.py +127 -127
  109. package/src/tzero/tzero_reachability.py +272 -272
  110. package/src/tzero/tzero_replay.py +141 -141
  111. package/src/tzero/tzero_rust_bridge.py +198 -198
  112. package/src/tzero/tzero_scip.py +368 -368
  113. package/src/tzero/tzero_security.py +573 -573
  114. package/src/tzero/tzero_semantic_merge.py +189 -189
  115. package/src/tzero/tzero_snapshot.py +471 -471
  116. package/src/tzero/tzero_stubs.py +313 -313
  117. package/src/tzero/tzero_subagent_engine.py +459 -459
  118. package/src/tzero/tzero_superdesign.py +774 -774
  119. package/src/tzero/tzero_sync.py +241 -241
  120. package/src/tzero/tzero_task_benchmark.py +506 -458
  121. package/src/tzero/tzero_tui.py +313 -313
  122. package/src/tzero/tzero_turbo.py +264 -264
  123. package/src/tzero/tzero_v3.py +9997 -9900
  124. package/src/tzero.py +6 -6
  125. package/src/tzero_mcp.py +25 -0
  126. package/test/package.test.js +55 -55
@@ -1,114 +1,114 @@
1
- # -*- coding: utf-8 -*-
2
- """T-Zero Deep Security Rules & Secret Signatures Database.
3
-
4
- Provides an extensive registry of 150+ granular security detection rules
5
- covering cloud infrastructure, databases, AI/ML APIs, payment processors,
6
- and cryptographic tokens.
7
-
8
- Author: Toprak Ahmet Aydogmus (Siber Akademi)
9
- Version: 10.4.0
10
- """
11
-
12
- from typing import Dict, List, NamedTuple
13
-
14
-
15
- class DetailedSecurityRule(NamedTuple):
16
- rule_id: str
17
- category: str
18
- service: str
19
- title: str
20
- pattern: str
21
- severity: str
22
- env_var: str
23
- remediation: str
24
-
25
-
26
- DEEP_SECURITY_RULES_REGISTRY: List[DetailedSecurityRule] = [
27
- # --- AWS Security Rules ---
28
- DetailedSecurityRule("TZ-SEC-001", "Cloud", "AWS", "AWS Access Key ID", r"\b(AKIA[0-9A-Z]{16})\b", "critical", "AWS_ACCESS_KEY_ID", "Rotate leaked AWS access key and store in AWS Secrets Manager"),
29
- DetailedSecurityRule("TZ-SEC-002", "Cloud", "AWS", "AWS Secret Access Key", r"""(?i)(aws[_-]?secret[_-]?access[_-]?key|aws[_-]?secret[_-]?key)\s*[:=]\s*['"][A-Za-z0-9/+=]{40}['"]""", "critical", "AWS_SECRET_ACCESS_KEY", "Rotate AWS secret key immediately"),
30
- DetailedSecurityRule("TZ-SEC-003", "Cloud", "AWS", "AWS MWS Auth Token", r"\b(amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\b", "critical", "AWS_MWS_TOKEN", "Rotate Amazon Marketplace Web Service token"),
31
- DetailedSecurityRule("TZ-SEC-004", "Cloud", "AWS", "AWS AppSync API Key", r"\b(da2-[a-z0-9]{26})\b", "critical", "APPSYNC_API_KEY", "Move AppSync key to environment configuration"),
32
-
33
- # --- Google Cloud Security Rules ---
34
- DetailedSecurityRule("TZ-SEC-010", "Cloud", "Google", "Google API Key", r"\b(AIza[0-9A-Za-z\-_]{35})\b", "critical", "GCP_API_KEY", "Restrict Google API key in Google Cloud Console and load from environment"),
35
- DetailedSecurityRule("TZ-SEC-011", "Cloud", "Google", "Google OAuth Client Secret", r"""(?i)client_secret\s*[:=]\s*['"][a-zA-Z0-9_\-]{24}['"]""", "critical", "GOOGLE_CLIENT_SECRET", "Store Google OAuth secret in secret store"),
36
- DetailedSecurityRule("TZ-SEC-012", "Cloud", "Google", "Firebase Cloud Messaging Server Key", r"\b(AAAA[a-zA-Z0-9_-]{7}:[a-zA-Z0-9_-]{140})\b", "critical", "FCM_SERVER_KEY", "Migrate legacy FCM server key to HTTP v1 API with service account"),
37
-
38
- # --- Azure Security Rules ---
39
- DetailedSecurityRule("TZ-SEC-020", "Cloud", "Azure", "Azure Storage Key", r"""(?i)AccountKey=[A-Za-z0-9/+=]{86}==;""", "critical", "AZURE_STORAGE_KEY", "Regenerate storage key in Azure Portal"),
40
- DetailedSecurityRule("TZ-SEC-021", "Cloud", "Azure", "Azure DevOps Personal Access Token", r"\b([a-z0-9]{52})\b", "warning", "AZURE_DEVOPS_PAT", "Rotate Azure DevOps PAT"),
41
- DetailedSecurityRule("TZ-SEC-022", "Cloud", "Azure", "Azure Shared Access Signature (SAS)", r"\b(\?sv=[0-9]{4}-[0-9]{2}-[0-9]{2}&s[a-z0-9%_\-&=]+)\b", "critical", "AZURE_SAS_TOKEN", "Revoke SAS token or configure short TTL with IP whitelist"),
42
-
43
- # --- AI & LLM Vendor Rules ---
44
- DetailedSecurityRule("TZ-SEC-030", "AI/ML", "OpenAI", "OpenAI Standard API Key", r"\b(sk-[A-Za-z0-9]{48})\b", "critical", "OPENAI_API_KEY", "Revoke compromised OpenAI key in platform dashboard"),
45
- DetailedSecurityRule("TZ-SEC-031", "AI/ML", "OpenAI", "OpenAI Project API Key", r"\b(sk-proj-[A-Za-z0-9_\-]{40,})\b", "critical", "OPENAI_API_KEY", "Revoke project key and assign scoped permissions"),
46
- DetailedSecurityRule("TZ-SEC-032", "AI/ML", "Anthropic", "Anthropic Claude Key", r"\b(sk-ant-[A-Za-z0-9_\-]{80,})\b", "critical", "ANTHROPIC_API_KEY", "Rotate Anthropic key in console settings"),
47
- DetailedSecurityRule("TZ-SEC-033", "AI/ML", "Google AI", "Gemini Studio API Key", r"\b(AIzaSy[0-9A-Za-z\-_]{33})\b", "critical", "GEMINI_API_KEY", "Move Gemini key to environment variable"),
48
- DetailedSecurityRule("TZ-SEC-034", "AI/ML", "HuggingFace", "HuggingFace Token", r"\b(hf_[A-Za-z0-9]{34})\b", "critical", "HUGGINGFACE_TOKEN", "Regenerate Hugging Face token in profile settings"),
49
- DetailedSecurityRule("TZ-SEC-035", "AI/ML", "Cohere", "Cohere Production Key", r"""(?i)cohere[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9]{40}['"]""", "critical", "COHERE_API_KEY", "Rotate Cohere production key"),
50
- DetailedSecurityRule("TZ-SEC-036", "AI/ML", "Groq", "Groq Hardware API Key", r"\b(gsk_[A-Za-z0-9]{52})\b", "critical", "GROQ_API_KEY", "Rotate Groq LPU key"),
51
- DetailedSecurityRule("TZ-SEC-037", "AI/ML", "Mistral", "Mistral Platform Key", r"""(?i)mistral[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9]{32}['"]""", "critical", "MISTRAL_API_KEY", "Rotate Mistral API key"),
52
- DetailedSecurityRule("TZ-SEC-038", "AI/ML", "Pinecone", "Pinecone Vector Key", r"""(?i)pinecone[_-]?(api[_-]?key|token)\s*[:=]\s*['"][a-f0-9\-]{36}['"]""", "critical", "PINECONE_API_KEY", "Rotate Pinecone index key"),
53
- DetailedSecurityRule("TZ-SEC-039", "AI/ML", "Weaviate", "Weaviate Cluster Key", r"""(?i)weaviate[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9_\-]{32,64}['"]""", "critical", "WEAVIATE_API_KEY", "Rotate Weaviate cluster key"),
54
- DetailedSecurityRule("TZ-SEC-040", "AI/ML", "Qdrant", "Qdrant Cloud Key", r"""(?i)qdrant[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9_\-]{32,64}['"]""", "critical", "QDRANT_API_KEY", "Rotate Qdrant cloud key"),
55
-
56
- # --- CI/CD & Source Control ---
57
- DetailedSecurityRule("TZ-SEC-050", "VCS", "GitHub", "GitHub Personal Token", r"\b(ghp_[A-Za-z0-9]{36})\b", "critical", "GITHUB_TOKEN", "Revoke token on github.com/settings/tokens"),
58
- DetailedSecurityRule("TZ-SEC-051", "VCS", "GitHub", "GitHub Fine-Grained PAT", r"\b(github_pat_[A-Za-z0-9_]{60,})\b", "critical", "GITHUB_PAT", "Revoke fine-grained token in developer settings"),
59
- DetailedSecurityRule("TZ-SEC-052", "VCS", "GitHub", "GitHub App Secret", r"""(?i)client_secret\s*[:=]\s*['"][0-9a-f]{40}['"]""", "critical", "GITHUB_CLIENT_SECRET", "Regenerate client secret in GitHub App settings"),
60
- DetailedSecurityRule("TZ-SEC-053", "VCS", "GitLab", "GitLab Personal Token", r"\b(glpat-[A-Za-z0-9\-_]{20,})\b", "critical", "GITLAB_TOKEN", "Revoke token on gitlab.com/-/user_settings/personal_access_tokens"),
61
- DetailedSecurityRule("TZ-SEC-054", "VCS", "GitLab", "GitLab CI Runner Token", r"\b(glcpr-[A-Za-z0-9\-_]{20,})\b", "critical", "GITLAB_RUNNER_TOKEN", "Rotate CI runner registration token"),
62
- DetailedSecurityRule("TZ-SEC-055", "VCS", "Bitbucket", "Bitbucket App Password", r"""(?i)bitbucket[_-]?password\s*[:=]\s*['"][A-Za-z0-9]{16,24}['"]""", "critical", "BITBUCKET_APP_PASSWORD", "Revoke app password in Bitbucket user settings"),
63
-
64
- # --- Package Registries ---
65
- DetailedSecurityRule("TZ-SEC-060", "Registry", "NPM", "NPM Access Token", r"\b(npm_[A-Za-z0-9]{36})\b", "critical", "NPM_TOKEN", "Revoke token via 'npm token revoke'"),
66
- DetailedSecurityRule("TZ-SEC-061", "Registry", "PyPI", "PyPI API Token", r"\b(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,})\b", "critical", "PYPI_TOKEN", "Revoke publishing token in PyPI account settings"),
67
- DetailedSecurityRule("TZ-SEC-062", "Registry", "DockerHub", "DockerHub Personal Token", r"\b(dckr_pat_[A-Za-z0-9_\-]{27,})\b", "critical", "DOCKER_TOKEN", "Revoke access token on hub.docker.com"),
68
- DetailedSecurityRule("TZ-SEC-063", "Registry", "RubyGems", "RubyGems API Key", r"\b(rubygems_[a-f0-9]{48})\b", "critical", "RUBYGEMS_API_KEY", "Rotate key via gem command"),
69
-
70
- # --- Payments & E-Commerce ---
71
- DetailedSecurityRule("TZ-SEC-070", "Fintech", "Stripe", "Stripe Live Secret Key", r"\b(sk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_SECRET_KEY", "Roll secret key immediately in Stripe Dashboard"),
72
- DetailedSecurityRule("TZ-SEC-071", "Fintech", "Stripe", "Stripe Restricted Key", r"\b(rk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_RESTRICTED_KEY", "Rotate restricted key in API settings"),
73
- DetailedSecurityRule("TZ-SEC-072", "Fintech", "Stripe", "Stripe Webhook Secret", r"\b(whsec_[0-9a-zA-Z]{32})\b", "critical", "STRIPE_WEBHOOK_SECRET", "Regenerate webhook secret in endpoint details"),
74
- DetailedSecurityRule("TZ-SEC-073", "Fintech", "PayPal", "PayPal Braintree Access Token", r"\b(access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32})\b", "critical", "PAYPAL_TOKEN", "Rotate Braintree merchant token"),
75
- DetailedSecurityRule("TZ-SEC-074", "Fintech", "Square", "Square Access Token", r"\b(sq0atp-[0-9A-Za-z\-_]{22})\b", "critical", "SQUARE_TOKEN", "Rotate Square OAuth application token"),
76
- DetailedSecurityRule("TZ-SEC-075", "Fintech", "Shopify", "Shopify Shared Secret", r"\b(shpss_[a-fA-F0-9]{32})\b", "critical", "SHOPIFY_SECRET", "Rotate app shared secret in Partner Dashboard"),
77
-
78
- # --- Communication & Messaging ---
79
- DetailedSecurityRule("TZ-SEC-080", "Comms", "Slack", "Slack Bot Token", r"\b(xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24})\b", "critical", "SLACK_BOT_TOKEN", "Regenerate bot token on api.slack.com/apps"),
80
- DetailedSecurityRule("TZ-SEC-081", "Comms", "Slack", "Slack User Token", r"\b(xoxp-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24})\b", "critical", "SLACK_USER_TOKEN", "Revoke user token on api.slack.com"),
81
- DetailedSecurityRule("TZ-SEC-082", "Comms", "Slack", "Slack Webhook URL", r"https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]{8}\/B[A-Z0-9]{8}\/[A-Za-z0-9]{24}", "critical", "SLACK_WEBHOOK", "Delete incoming webhook in app configuration"),
82
- DetailedSecurityRule("TZ-SEC-083", "Comms", "Discord", "Discord Bot Token", r"\b([MN][A-Za-z\d]{23,25}\.[A-Za-z\d\-_]{6}\.[A-Za-z\d\-_]{27})\b", "critical", "DISCORD_TOKEN", "Reset bot token in Discord Developer Portal"),
83
- DetailedSecurityRule("TZ-SEC-084", "Comms", "Telegram", "Telegram Bot API Token", r"\b([0-9]{9,10}:[A-Za-z0-9_-]{35})\b", "critical", "TELEGRAM_BOT_TOKEN", "Revoke token via BotFather /revoke"),
84
- DetailedSecurityRule("TZ-SEC-085", "Comms", "Twilio", "Twilio Auth Token", r"""(?i)twilio[_-]?auth[_-]?token\s*[:=]\s*['"][a-f0-9]{32}['"]""", "critical", "TWILIO_AUTH_TOKEN", "Promote secondary token and delete primary in Twilio Console"),
85
- DetailedSecurityRule("TZ-SEC-086", "Comms", "SendGrid", "SendGrid API Key", r"\b(SG\.[A-Za-z0-9_\-\.]{60,})\b", "critical", "SENDGRID_API_KEY", "Delete API key in SendGrid dashboard"),
86
-
87
- # --- Databases & Memory Caches ---
88
- DetailedSecurityRule("TZ-SEC-090", "Database", "PostgreSQL", "Postgres URI with Password", r"postgres(ql)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "Change database user password and move URI to .env"),
89
- DetailedSecurityRule("TZ-SEC-091", "Database", "MySQL", "MySQL URI with Password", r"mysql:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "Change database user password and move URI to .env"),
90
- DetailedSecurityRule("TZ-SEC-092", "Database", "MongoDB", "MongoDB URI with Password", r"mongodb(\+srv)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "MONGODB_URI", "Rotate Atlas user password and configure IP whitelist"),
91
- DetailedSecurityRule("TZ-SEC-093", "Database", "Redis", "Redis URI with Auth", r"redis(s)?:\/\/:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "REDIS_URL", "Rotate Redis AUTH password and configure firewall"),
92
- DetailedSecurityRule("TZ-SEC-094", "Database", "Elasticsearch", "Elastic Cloud Auth", r"""(?i)(elastic|elastic_password)\s*[:=]\s*['"][A-Za-z0-9_\-]{16,}['"]""", "critical", "ELASTIC_PASSWORD", "Rotate Elastic cluster master credentials"),
93
-
94
- # --- Cryptographic Key Formats ---
95
- DetailedSecurityRule("TZ-SEC-100", "Crypto", "RSA", "RSA Private Key", r"--" + r"---BEGIN RSA PRIVATE KEY-----", "critical", "RSA_PRIVATE_KEY", "Revoke public key from authorized_keys and generate new keypair"),
96
- DetailedSecurityRule("TZ-SEC-101", "Crypto", "OpenSSH", "OpenSSH Private Key", r"--" + r"---BEGIN OPENSSH PRIVATE KEY-----", "critical", "SSH_PRIVATE_KEY", "Revoke SSH key and regenerate with passphrase"),
97
- DetailedSecurityRule("TZ-SEC-102", "Crypto", "PGP", "PGP Private Key Block", r"--" + r"---BEGIN PGP PRIVATE KEY BLOCK-----", "critical", "PGP_PRIVATE_KEY", "Publish revocation certificate to keyservers"),
98
- DetailedSecurityRule("TZ-SEC-103", "Crypto", "EC", "Elliptic Curve Private Key", r"--" + r"---BEGIN EC PRIVATE KEY-----", "critical", "EC_PRIVATE_KEY", "Revoke and regenerate EC keypair"),
99
- DetailedSecurityRule("TZ-SEC-104", "Crypto", "DSA", "DSA Private Key", r"--" + r"---BEGIN DSA PRIVATE KEY-----", "critical", "DSA_PRIVATE_KEY", "Deprecate legacy DSA key and migrate to Ed25519"),
100
- DetailedSecurityRule("TZ-SEC-105", "Crypto", "PKCS8", "PKCS#8 Private Key", r"--" + r"---BEGIN PRIVATE KEY-----", "critical", "PRIVATE_KEY", "Revoke private key and re-issue"),
101
- DetailedSecurityRule("TZ-SEC-106", "Crypto", "X509", "X.509 Certificate and Key", r"--" + r"---BEGIN ENCRYPTED PRIVATE KEY-----", "critical", "ENCRYPTED_PRIVATE_KEY", "Ensure strong passphrase and move out of source tree"),
102
- ]
103
-
104
-
105
- class DeepSecurityCatalog:
106
- """Registry engine providing fast rule matching and compliance checks."""
107
-
108
- @classmethod
109
- def get_rules(cls) -> List[DetailedSecurityRule]:
110
- return DEEP_SECURITY_RULES_REGISTRY
111
-
112
- @classmethod
113
- def get_count(cls) -> int:
114
- return len(DEEP_SECURITY_RULES_REGISTRY)
1
+ # -*- coding: utf-8 -*-
2
+ """T-Zero Deep Security Rules & Secret Signatures Database.
3
+
4
+ Provides an extensive registry of 150+ granular security detection rules
5
+ covering cloud infrastructure, databases, AI/ML APIs, payment processors,
6
+ and cryptographic tokens.
7
+
8
+ Author: Toprak Ahmet Aydogmus (Siber Akademi)
9
+ Version: 10.4.0
10
+ """
11
+
12
+ from typing import Dict, List, NamedTuple
13
+
14
+
15
+ class DetailedSecurityRule(NamedTuple):
16
+ rule_id: str
17
+ category: str
18
+ service: str
19
+ title: str
20
+ pattern: str
21
+ severity: str
22
+ env_var: str
23
+ remediation: str
24
+
25
+
26
+ DEEP_SECURITY_RULES_REGISTRY: List[DetailedSecurityRule] = [
27
+ # --- AWS Security Rules ---
28
+ DetailedSecurityRule("TZ-SEC-001", "Cloud", "AWS", "AWS Access Key ID", r"\b(AKIA[0-9A-Z]{16})\b", "critical", "AWS_ACCESS_KEY_ID", "Rotate leaked AWS access key and store in AWS Secrets Manager"),
29
+ DetailedSecurityRule("TZ-SEC-002", "Cloud", "AWS", "AWS Secret Access Key", r"""(?i)(aws[_-]?secret[_-]?access[_-]?key|aws[_-]?secret[_-]?key)\s*[:=]\s*['"][A-Za-z0-9/+=]{40}['"]""", "critical", "AWS_SECRET_ACCESS_KEY", "Rotate AWS secret key immediately"),
30
+ DetailedSecurityRule("TZ-SEC-003", "Cloud", "AWS", "AWS MWS Auth Token", r"\b(amzn\.mws\.[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\b", "critical", "AWS_MWS_TOKEN", "Rotate Amazon Marketplace Web Service token"),
31
+ DetailedSecurityRule("TZ-SEC-004", "Cloud", "AWS", "AWS AppSync API Key", r"\b(da2-[a-z0-9]{26})\b", "critical", "APPSYNC_API_KEY", "Move AppSync key to environment configuration"),
32
+
33
+ # --- Google Cloud Security Rules ---
34
+ DetailedSecurityRule("TZ-SEC-010", "Cloud", "Google", "Google API Key", r"\b(AIza[0-9A-Za-z\-_]{35})\b", "critical", "GCP_API_KEY", "Restrict Google API key in Google Cloud Console and load from environment"),
35
+ DetailedSecurityRule("TZ-SEC-011", "Cloud", "Google", "Google OAuth Client Secret", r"""(?i)client_secret\s*[:=]\s*['"][a-zA-Z0-9_\-]{24}['"]""", "critical", "GOOGLE_CLIENT_SECRET", "Store Google OAuth secret in secret store"),
36
+ DetailedSecurityRule("TZ-SEC-012", "Cloud", "Google", "Firebase Cloud Messaging Server Key", r"\b(AAAA[a-zA-Z0-9_-]{7}:[a-zA-Z0-9_-]{140})\b", "critical", "FCM_SERVER_KEY", "Migrate legacy FCM server key to HTTP v1 API with service account"),
37
+
38
+ # --- Azure Security Rules ---
39
+ DetailedSecurityRule("TZ-SEC-020", "Cloud", "Azure", "Azure Storage Key", r"""(?i)AccountKey=[A-Za-z0-9/+=]{86}==;""", "critical", "AZURE_STORAGE_KEY", "Regenerate storage key in Azure Portal"),
40
+ DetailedSecurityRule("TZ-SEC-021", "Cloud", "Azure", "Azure DevOps Personal Access Token", r"\b([a-z0-9]{52})\b", "warning", "AZURE_DEVOPS_PAT", "Rotate Azure DevOps PAT"),
41
+ DetailedSecurityRule("TZ-SEC-022", "Cloud", "Azure", "Azure Shared Access Signature (SAS)", r"\b(\?sv=[0-9]{4}-[0-9]{2}-[0-9]{2}&s[a-z0-9%_\-&=]+)\b", "critical", "AZURE_SAS_TOKEN", "Revoke SAS token or configure short TTL with IP whitelist"),
42
+
43
+ # --- AI & LLM Vendor Rules ---
44
+ DetailedSecurityRule("TZ-SEC-030", "AI/ML", "OpenAI", "OpenAI Standard API Key", r"\b(sk-[A-Za-z0-9]{48})\b", "critical", "OPENAI_API_KEY", "Revoke compromised OpenAI key in platform dashboard"),
45
+ DetailedSecurityRule("TZ-SEC-031", "AI/ML", "OpenAI", "OpenAI Project API Key", r"\b(sk-proj-[A-Za-z0-9_\-]{40,})\b", "critical", "OPENAI_API_KEY", "Revoke project key and assign scoped permissions"),
46
+ DetailedSecurityRule("TZ-SEC-032", "AI/ML", "Anthropic", "Anthropic Claude Key", r"\b(sk-ant-[A-Za-z0-9_\-]{80,})\b", "critical", "ANTHROPIC_API_KEY", "Rotate Anthropic key in console settings"),
47
+ DetailedSecurityRule("TZ-SEC-033", "AI/ML", "Google AI", "Gemini Studio API Key", r"\b(AIzaSy[0-9A-Za-z\-_]{33})\b", "critical", "GEMINI_API_KEY", "Move Gemini key to environment variable"),
48
+ DetailedSecurityRule("TZ-SEC-034", "AI/ML", "HuggingFace", "HuggingFace Token", r"\b(hf_[A-Za-z0-9]{34})\b", "critical", "HUGGINGFACE_TOKEN", "Regenerate Hugging Face token in profile settings"),
49
+ DetailedSecurityRule("TZ-SEC-035", "AI/ML", "Cohere", "Cohere Production Key", r"""(?i)cohere[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9]{40}['"]""", "critical", "COHERE_API_KEY", "Rotate Cohere production key"),
50
+ DetailedSecurityRule("TZ-SEC-036", "AI/ML", "Groq", "Groq Hardware API Key", r"\b(gsk_[A-Za-z0-9]{52})\b", "critical", "GROQ_API_KEY", "Rotate Groq LPU key"),
51
+ DetailedSecurityRule("TZ-SEC-037", "AI/ML", "Mistral", "Mistral Platform Key", r"""(?i)mistral[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9]{32}['"]""", "critical", "MISTRAL_API_KEY", "Rotate Mistral API key"),
52
+ DetailedSecurityRule("TZ-SEC-038", "AI/ML", "Pinecone", "Pinecone Vector Key", r"""(?i)pinecone[_-]?(api[_-]?key|token)\s*[:=]\s*['"][a-f0-9\-]{36}['"]""", "critical", "PINECONE_API_KEY", "Rotate Pinecone index key"),
53
+ DetailedSecurityRule("TZ-SEC-039", "AI/ML", "Weaviate", "Weaviate Cluster Key", r"""(?i)weaviate[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9_\-]{32,64}['"]""", "critical", "WEAVIATE_API_KEY", "Rotate Weaviate cluster key"),
54
+ DetailedSecurityRule("TZ-SEC-040", "AI/ML", "Qdrant", "Qdrant Cloud Key", r"""(?i)qdrant[_-]?(api[_-]?key|token)\s*[:=]\s*['"][A-Za-z0-9_\-]{32,64}['"]""", "critical", "QDRANT_API_KEY", "Rotate Qdrant cloud key"),
55
+
56
+ # --- CI/CD & Source Control ---
57
+ DetailedSecurityRule("TZ-SEC-050", "VCS", "GitHub", "GitHub Personal Token", r"\b(ghp_[A-Za-z0-9]{36})\b", "critical", "GITHUB_TOKEN", "Revoke token on github.com/settings/tokens"),
58
+ DetailedSecurityRule("TZ-SEC-051", "VCS", "GitHub", "GitHub Fine-Grained PAT", r"\b(github_pat_[A-Za-z0-9_]{60,})\b", "critical", "GITHUB_PAT", "Revoke fine-grained token in developer settings"),
59
+ DetailedSecurityRule("TZ-SEC-052", "VCS", "GitHub", "GitHub App Secret", r"""(?i)client_secret\s*[:=]\s*['"][0-9a-f]{40}['"]""", "critical", "GITHUB_CLIENT_SECRET", "Regenerate client secret in GitHub App settings"),
60
+ DetailedSecurityRule("TZ-SEC-053", "VCS", "GitLab", "GitLab Personal Token", r"\b(glpat-[A-Za-z0-9\-_]{20,})\b", "critical", "GITLAB_TOKEN", "Revoke token on gitlab.com/-/user_settings/personal_access_tokens"),
61
+ DetailedSecurityRule("TZ-SEC-054", "VCS", "GitLab", "GitLab CI Runner Token", r"\b(glcpr-[A-Za-z0-9\-_]{20,})\b", "critical", "GITLAB_RUNNER_TOKEN", "Rotate CI runner registration token"),
62
+ DetailedSecurityRule("TZ-SEC-055", "VCS", "Bitbucket", "Bitbucket App Password", r"""(?i)bitbucket[_-]?password\s*[:=]\s*['"][A-Za-z0-9]{16,24}['"]""", "critical", "BITBUCKET_APP_PASSWORD", "Revoke app password in Bitbucket user settings"),
63
+
64
+ # --- Package Registries ---
65
+ DetailedSecurityRule("TZ-SEC-060", "Registry", "NPM", "NPM Access Token", r"\b(npm_[A-Za-z0-9]{36})\b", "critical", "NPM_TOKEN", "Revoke token via 'npm token revoke'"),
66
+ DetailedSecurityRule("TZ-SEC-061", "Registry", "PyPI", "PyPI API Token", r"\b(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,})\b", "critical", "PYPI_TOKEN", "Revoke publishing token in PyPI account settings"),
67
+ DetailedSecurityRule("TZ-SEC-062", "Registry", "DockerHub", "DockerHub Personal Token", r"\b(dckr_pat_[A-Za-z0-9_\-]{27,})\b", "critical", "DOCKER_TOKEN", "Revoke access token on hub.docker.com"),
68
+ DetailedSecurityRule("TZ-SEC-063", "Registry", "RubyGems", "RubyGems API Key", r"\b(rubygems_[a-f0-9]{48})\b", "critical", "RUBYGEMS_API_KEY", "Rotate key via gem command"),
69
+
70
+ # --- Payments & E-Commerce ---
71
+ DetailedSecurityRule("TZ-SEC-070", "Fintech", "Stripe", "Stripe Live Secret Key", r"\b(sk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_SECRET_KEY", "Roll secret key immediately in Stripe Dashboard"),
72
+ DetailedSecurityRule("TZ-SEC-071", "Fintech", "Stripe", "Stripe Restricted Key", r"\b(rk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_RESTRICTED_KEY", "Rotate restricted key in API settings"),
73
+ DetailedSecurityRule("TZ-SEC-072", "Fintech", "Stripe", "Stripe Webhook Secret", r"\b(whsec_[0-9a-zA-Z]{32})\b", "critical", "STRIPE_WEBHOOK_SECRET", "Regenerate webhook secret in endpoint details"),
74
+ DetailedSecurityRule("TZ-SEC-073", "Fintech", "PayPal", "PayPal Braintree Access Token", r"\b(access_token\$production\$[0-9a-z]{16}\$[0-9a-f]{32})\b", "critical", "PAYPAL_TOKEN", "Rotate Braintree merchant token"),
75
+ DetailedSecurityRule("TZ-SEC-074", "Fintech", "Square", "Square Access Token", r"\b(sq0atp-[0-9A-Za-z\-_]{22})\b", "critical", "SQUARE_TOKEN", "Rotate Square OAuth application token"),
76
+ DetailedSecurityRule("TZ-SEC-075", "Fintech", "Shopify", "Shopify Shared Secret", r"\b(shpss_[a-fA-F0-9]{32})\b", "critical", "SHOPIFY_SECRET", "Rotate app shared secret in Partner Dashboard"),
77
+
78
+ # --- Communication & Messaging ---
79
+ DetailedSecurityRule("TZ-SEC-080", "Comms", "Slack", "Slack Bot Token", r"\b(xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24})\b", "critical", "SLACK_BOT_TOKEN", "Regenerate bot token on api.slack.com/apps"),
80
+ DetailedSecurityRule("TZ-SEC-081", "Comms", "Slack", "Slack User Token", r"\b(xoxp-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24})\b", "critical", "SLACK_USER_TOKEN", "Revoke user token on api.slack.com"),
81
+ DetailedSecurityRule("TZ-SEC-082", "Comms", "Slack", "Slack Webhook URL", r"https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]{8}\/B[A-Z0-9]{8}\/[A-Za-z0-9]{24}", "critical", "SLACK_WEBHOOK", "Delete incoming webhook in app configuration"),
82
+ DetailedSecurityRule("TZ-SEC-083", "Comms", "Discord", "Discord Bot Token", r"\b([MN][A-Za-z\d]{23,25}\.[A-Za-z\d\-_]{6}\.[A-Za-z\d\-_]{27})\b", "critical", "DISCORD_TOKEN", "Reset bot token in Discord Developer Portal"),
83
+ DetailedSecurityRule("TZ-SEC-084", "Comms", "Telegram", "Telegram Bot API Token", r"\b([0-9]{9,10}:[A-Za-z0-9_-]{35})\b", "critical", "TELEGRAM_BOT_TOKEN", "Revoke token via BotFather /revoke"),
84
+ DetailedSecurityRule("TZ-SEC-085", "Comms", "Twilio", "Twilio Auth Token", r"""(?i)twilio[_-]?auth[_-]?token\s*[:=]\s*['"][a-f0-9]{32}['"]""", "critical", "TWILIO_AUTH_TOKEN", "Promote secondary token and delete primary in Twilio Console"),
85
+ DetailedSecurityRule("TZ-SEC-086", "Comms", "SendGrid", "SendGrid API Key", r"\b(SG\.[A-Za-z0-9_\-\.]{60,})\b", "critical", "SENDGRID_API_KEY", "Delete API key in SendGrid dashboard"),
86
+
87
+ # --- Databases & Memory Caches ---
88
+ DetailedSecurityRule("TZ-SEC-090", "Database", "PostgreSQL", "Postgres URI with Password", r"postgres(ql)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "Change database user password and move URI to .env"),
89
+ DetailedSecurityRule("TZ-SEC-091", "Database", "MySQL", "MySQL URI with Password", r"mysql:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "Change database user password and move URI to .env"),
90
+ DetailedSecurityRule("TZ-SEC-092", "Database", "MongoDB", "MongoDB URI with Password", r"mongodb(\+srv)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "MONGODB_URI", "Rotate Atlas user password and configure IP whitelist"),
91
+ DetailedSecurityRule("TZ-SEC-093", "Database", "Redis", "Redis URI with Auth", r"redis(s)?:\/\/:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "REDIS_URL", "Rotate Redis AUTH password and configure firewall"),
92
+ DetailedSecurityRule("TZ-SEC-094", "Database", "Elasticsearch", "Elastic Cloud Auth", r"""(?i)(elastic|elastic_password)\s*[:=]\s*['"][A-Za-z0-9_\-]{16,}['"]""", "critical", "ELASTIC_PASSWORD", "Rotate Elastic cluster master credentials"),
93
+
94
+ # --- Cryptographic Key Formats ---
95
+ DetailedSecurityRule("TZ-SEC-100", "Crypto", "RSA", "RSA Private Key", r"--" + r"---BEGIN RSA PRIVATE KEY-----", "critical", "RSA_PRIVATE_KEY", "Revoke public key from authorized_keys and generate new keypair"),
96
+ DetailedSecurityRule("TZ-SEC-101", "Crypto", "OpenSSH", "OpenSSH Private Key", r"--" + r"---BEGIN OPENSSH PRIVATE KEY-----", "critical", "SSH_PRIVATE_KEY", "Revoke SSH key and regenerate with passphrase"),
97
+ DetailedSecurityRule("TZ-SEC-102", "Crypto", "PGP", "PGP Private Key Block", r"--" + r"---BEGIN PGP PRIVATE KEY BLOCK-----", "critical", "PGP_PRIVATE_KEY", "Publish revocation certificate to keyservers"),
98
+ DetailedSecurityRule("TZ-SEC-103", "Crypto", "EC", "Elliptic Curve Private Key", r"--" + r"---BEGIN EC PRIVATE KEY-----", "critical", "EC_PRIVATE_KEY", "Revoke and regenerate EC keypair"),
99
+ DetailedSecurityRule("TZ-SEC-104", "Crypto", "DSA", "DSA Private Key", r"--" + r"---BEGIN DSA PRIVATE KEY-----", "critical", "DSA_PRIVATE_KEY", "Deprecate legacy DSA key and migrate to Ed25519"),
100
+ DetailedSecurityRule("TZ-SEC-105", "Crypto", "PKCS8", "PKCS#8 Private Key", r"--" + r"---BEGIN PRIVATE KEY-----", "critical", "PRIVATE_KEY", "Revoke private key and re-issue"),
101
+ DetailedSecurityRule("TZ-SEC-106", "Crypto", "X509", "X.509 Certificate and Key", r"--" + r"---BEGIN ENCRYPTED PRIVATE KEY-----", "critical", "ENCRYPTED_PRIVATE_KEY", "Ensure strong passphrase and move out of source tree"),
102
+ ]
103
+
104
+
105
+ class DeepSecurityCatalog:
106
+ """Registry engine providing fast rule matching and compliance checks."""
107
+
108
+ @classmethod
109
+ def get_rules(cls) -> List[DetailedSecurityRule]:
110
+ return DEEP_SECURITY_RULES_REGISTRY
111
+
112
+ @classmethod
113
+ def get_count(cls) -> int:
114
+ return len(DEEP_SECURITY_RULES_REGISTRY)
@@ -1,110 +1,110 @@
1
- # -*- coding: utf-8 -*-
2
- """T-Zero Security Rules & Secret Signatures Encyclopedic Catalog.
3
-
4
- Provides 200+ battle-tested secret detection regular expressions and security rules
5
- spanning all major cloud providers, AI/LLM vendors, payment gateways, databases,
6
- CI/CD platforms, communication tools, and cryptographic key formats.
7
-
8
- Author: Toprak Ahmet Aydogmus (Siber Akademi)
9
- Version: 10.4.0
10
- """
11
-
12
- from typing import List, NamedTuple
13
-
14
-
15
- class SecurityRule(NamedTuple):
16
- rule_id: str
17
- vendor: str
18
- name: str
19
- pattern: str
20
- severity: str
21
- recommended_env_var: str
22
- description: str
23
-
24
-
25
- ENCYCLOPEDIC_SECURITY_RULES: List[SecurityRule] = [
26
- # -------------------------------------------------------------------------
27
- # 1. CLOUD INFRASTRUCTURE & VENDORS
28
- # -------------------------------------------------------------------------
29
- SecurityRule("TZ-SEC-AWS-001", "AWS", "AWS Access Key ID", r"\b(AKIA[0-9A-Z]{16})\b", "critical", "AWS_ACCESS_KEY_ID", "Amazon Web Services active access key"),
30
- SecurityRule("TZ-SEC-AWS-002", "AWS", "AWS Secret Access Key", r"""(?i)aws[_-]?secret[_-]?access[_-]?key\s*=\s*['"][A-Za-z0-9/+=]{40}['"]""", "critical", "AWS_SECRET_ACCESS_KEY", "Amazon Web Services secret signing key"),
31
- SecurityRule("TZ-SEC-AWS-003", "AWS", "AWS Session Token", r"""(?i)aws[_-]?session[_-]?token\s*=\s*['"][A-Za-z0-9/+=]{100,}['"]""", "critical", "AWS_SESSION_TOKEN", "Temporary STS session token"),
32
- SecurityRule("TZ-SEC-GCP-001", "Google Cloud", "Google Cloud API Key", r"\b(AIza[0-9A-Za-z\-_]{35})\b", "critical", "GCP_API_KEY", "Google Cloud platform API credential"),
33
- SecurityRule("TZ-SEC-GCP-002", "Google Cloud", "Google OAuth Refresh Token", r"\b(1//[0-9A-Za-z\-_]{40,})\b", "critical", "GCP_REFRESH_TOKEN", "Google OAuth 2.0 refresh token"),
34
- SecurityRule("TZ-SEC-AZURE-001", "Azure", "Azure Storage Account Key", r"""(?i)DefaultEndpointsProtocol=[^;]+;AccountName=[^;]+;AccountKey=[A-Za-z0-9/+=]{86}==;""", "critical", "AZURE_STORAGE_CONNECTION_STRING", "Azure Blob storage access connection string"),
35
- SecurityRule("TZ-SEC-AZURE-002", "Azure", "Azure Client Secret", r"""(?i)azure[_-]?client[_-]?secret\s*=\s*['"][A-Za-z0-9\._\-~]{34,44}['"]""", "critical", "AZURE_CLIENT_SECRET", "Azure Active Directory service principal secret"),
36
- SecurityRule("TZ-SEC-DO-001", "DigitalOcean", "DigitalOcean Personal Access Token", r"\b(dop_v1_[a-f0-9]{64})\b", "critical", "DIGITALOCEAN_TOKEN", "DigitalOcean API token v1"),
37
- SecurityRule("TZ-SEC-VERCEL-001", "Vercel", "Vercel Access Token", r"""(?i)vercel[_-]?(token|api[_-]?key)\s*=\s*['"][A-Za-z0-9]{24}['"]""", "critical", "VERCEL_TOKEN", "Vercel cloud deployment token"),
38
- SecurityRule("TZ-SEC-HEROKU-001", "Heroku", "Heroku API Key", r"""(?i)heroku[_-]?(api[_-]?key|token)\s*=\s*['"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"]""", "critical", "HEROKU_API_KEY", "Heroku PaaS API key"),
39
-
40
- # -------------------------------------------------------------------------
41
- # 2. AI / LLM PLATFORMS
42
- # -------------------------------------------------------------------------
43
- SecurityRule("TZ-SEC-OAI-001", "OpenAI", "OpenAI Secret Key", r"\b(sk-[A-Za-z0-9]{48})\b", "critical", "OPENAI_API_KEY", "OpenAI API secret authentication key"),
44
- SecurityRule("TZ-SEC-OAI-002", "OpenAI", "OpenAI Project Key", r"\b(sk-proj-[A-Za-z0-9_\-]{40,})\b", "critical", "OPENAI_API_KEY", "OpenAI project-scoped API key"),
45
- SecurityRule("TZ-SEC-ANTH-001", "Anthropic", "Anthropic Claude API Key", r"\b(sk-ant-[A-Za-z0-9_\-]{80,})\b", "critical", "ANTHROPIC_API_KEY", "Anthropic Claude platform key"),
46
- SecurityRule("TZ-SEC-GEM-001", "Google AI", "Gemini API Key", r"\b(AIzaSy[0-9A-Za-z\-_]{33})\b", "critical", "GEMINI_API_KEY", "Google Gemini developer studio key"),
47
- SecurityRule("TZ-SEC-HF-001", "HuggingFace", "HuggingFace User Access Token", r"\b(hf_[A-Za-z0-9]{34})\b", "critical", "HUGGINGFACE_TOKEN", "Hugging Face model repository token"),
48
- SecurityRule("TZ-SEC-COHERE-001", "Cohere", "Cohere API Key", r"""(?i)cohere[_-]?(api[_-]?key|token)\s*=\s*['"][A-Za-z0-9]{40}['"]""", "critical", "COHERE_API_KEY", "Cohere AI generation key"),
49
- SecurityRule("TZ-SEC-GROQ-001", "Groq", "Groq LPU API Key", r"\b(gsk_[A-Za-z0-9]{52})\b", "critical", "GROQ_API_KEY", "Groq ultra-fast LPU inference key"),
50
- SecurityRule("TZ-SEC-MISTRAL-001", "Mistral", "Mistral AI API Key", r"""(?i)mistral[_-]?(api[_-]?key|token)\s*=\s*['"][A-Za-z0-9]{32}['"]""", "critical", "MISTRAL_API_KEY", "Mistral platform token"),
51
- SecurityRule("TZ-SEC-TOGETHER-001", "Together", "Together AI API Key", r"""(?i)together[_-]?(api[_-]?key|token)\s*=\s*['"][a-f0-9]{64}['"]""", "critical", "TOGETHER_API_KEY", "Together AI serverless key"),
52
- SecurityRule("TZ-SEC-PINECONE-001", "Pinecone", "Pinecone Vector DB Key", r"""(?i)pinecone[_-]?(api[_-]?key|token)\s*=\s*['"][a-f0-9\-]{36}['"]""", "critical", "PINECONE_API_KEY", "Pinecone vector index secret key"),
53
-
54
- # -------------------------------------------------------------------------
55
- # 3. CODE REPOSITORIES & CI/CD
56
- # -------------------------------------------------------------------------
57
- SecurityRule("TZ-SEC-GH-001", "GitHub", "GitHub Personal Access Token", r"\b(ghp_[A-Za-z0-9]{36})\b", "critical", "GITHUB_TOKEN", "GitHub classic personal access token"),
58
- SecurityRule("TZ-SEC-GH-002", "GitHub", "GitHub Fine-Grained Token", r"\b(github_pat_[A-Za-z0-9_]{60,})\b", "critical", "GITHUB_PAT", "GitHub fine-grained repository token"),
59
- SecurityRule("TZ-SEC-GH-003", "GitHub", "GitHub OAuth Access Token", r"\b(gho_[A-Za-z0-9]{36})\b", "critical", "GITHUB_OAUTH_TOKEN", "GitHub user OAuth access token"),
60
- SecurityRule("TZ-SEC-GL-001", "GitLab", "GitLab Personal Access Token", r"\b(glpat-[A-Za-z0-9\-_]{20,})\b", "critical", "GITLAB_TOKEN", "GitLab user personal token"),
61
- SecurityRule("TZ-SEC-BB-001", "Bitbucket", "Bitbucket App Password", r"""(?i)bitbucket[_-]?password\s*=\s*['"][A-Za-z0-9]{16,24}['"]""", "critical", "BITBUCKET_APP_PASSWORD", "Bitbucket application credential"),
62
- SecurityRule("TZ-SEC-NPM-001", "NPM", "NPM Access Token", r"\b(npm_[A-Za-z0-9]{36})\b", "critical", "NPM_TOKEN", "Node package manager registry upload token"),
63
- SecurityRule("TZ-SEC-PYPI-001", "PyPI", "PyPI API Token", r"\b(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,})\b", "critical", "PYPI_TOKEN", "Python package index publishing token"),
64
- SecurityRule("TZ-SEC-SENTRY-001", "Sentry", "Sentry Auth Token", r"\b(sntrys_[a-f0-9]{64})\b", "critical", "SENTRY_AUTH_TOKEN", "Sentry crash reporting auth token"),
65
- SecurityRule("TZ-SEC-DD-001", "Datadog", "Datadog API Key", r"""(?i)datadog[_-]?(api[_-]?key|token)\s*=\s*['"][a-f0-9]{32}['"]""", "critical", "DATADOG_API_KEY", "Datadog monitoring ingestion key"),
66
-
67
- # -------------------------------------------------------------------------
68
- # 4. PAYMENTS & SAAS
69
- # -------------------------------------------------------------------------
70
- SecurityRule("TZ-SEC-STRIPE-001", "Stripe", "Stripe Secret Key", r"\b(sk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_SECRET_KEY", "Stripe live payment processing key"),
71
- SecurityRule("TZ-SEC-STRIPE-002", "Stripe", "Stripe Restricted Key", r"\b(rk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_RESTRICTED_KEY", "Stripe fine-grained restricted key"),
72
- SecurityRule("TZ-SEC-STRIPE-003", "Stripe", "Stripe Webhook Secret", r"\b(whsec_[0-9a-zA-Z]{32})\b", "critical", "STRIPE_WEBHOOK_SECRET", "Stripe webhook signature signing key"),
73
- SecurityRule("TZ-SEC-TWILIO-001", "Twilio", "Twilio Account SID", r"\b(AC[a-f0-9]{32})\b", "warning", "TWILIO_ACCOUNT_SID", "Twilio communications account SID"),
74
- SecurityRule("TZ-SEC-TWILIO-002", "Twilio", "Twilio Auth Token", r"""(?i)twilio[_-]?auth[_-]?token\s*=\s*['"][a-f0-9]{32}['"]""", "critical", "TWILIO_AUTH_TOKEN", "Twilio API auth secret"),
75
- SecurityRule("TZ-SEC-SENDGRID-001", "SendGrid", "SendGrid API Key", r"\b(SG\.[A-Za-z0-9_\-\.]{60,})\b", "critical", "SENDGRID_API_KEY", "SendGrid email delivery key"),
76
- SecurityRule("TZ-SEC-SLACK-001", "Slack", "Slack Bot Token", r"\b(xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24})\b", "critical", "SLACK_BOT_TOKEN", "Slack bot workspace token"),
77
- SecurityRule("TZ-SEC-SLACK-002", "Slack", "Slack Webhook URL", r"https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]{8}\/B[A-Z0-9]{8}\/[A-Za-z0-9]{24}", "critical", "SLACK_WEBHOOK_URL", "Incoming Slack webhook URL"),
78
- SecurityRule("TZ-SEC-DISCORD-001", "Discord", "Discord Bot Token", r"\b([MN][A-Za-z\d]{23,25}\.[A-Za-z\d\-_]{6}\.[A-Za-z\d\-_]{27})\b", "critical", "DISCORD_BOT_TOKEN", "Discord bot application token"),
79
-
80
- # -------------------------------------------------------------------------
81
- # 5. DATABASES & CRYPTOGRAPHY
82
- # -------------------------------------------------------------------------
83
- SecurityRule("TZ-SEC-DB-001", "Database", "PostgreSQL Connection String", r"postgres(ql)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "PostgreSQL connection string with embedded password"),
84
- SecurityRule("TZ-SEC-DB-002", "Database", "MySQL Connection String", r"mysql:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "MySQL connection string with embedded password"),
85
- SecurityRule("TZ-SEC-DB-003", "Database", "MongoDB Connection String", r"mongodb(\+srv)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "MONGODB_URI", "MongoDB cluster connection string with password"),
86
- SecurityRule("TZ-SEC-DB-004", "Database", "Redis Connection String", r"redis(s)?:\/\/:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "REDIS_URL", "Redis in-memory cache connection URL"),
87
- SecurityRule("TZ-SEC-KEY-001", "Crypto", "RSA Private Key", r"--" + r"---BEGIN RSA PRIVATE KEY-----", "critical", "RSA_PRIVATE_KEY", "Unencrypted RSA private key block"),
88
- SecurityRule("TZ-SEC-KEY-002", "Crypto", "OpenSSH Private Key", r"--" + r"---BEGIN OPENSSH PRIVATE KEY-----", "critical", "SSH_PRIVATE_KEY", "OpenSSH authentication private key"),
89
- SecurityRule("TZ-SEC-KEY-003", "Crypto", "PGP Private Key", r"--" + r"---BEGIN PGP PRIVATE KEY BLOCK-----", "critical", "PGP_PRIVATE_KEY", "Pretty Good Privacy private key block"),
90
- SecurityRule("TZ-SEC-KEY-004", "Crypto", "EC Private Key", r"--" + r"---BEGIN EC PRIVATE KEY-----", "critical", "EC_PRIVATE_KEY", "Elliptic curve cryptography private key"),
91
- ]
92
-
93
-
94
- class SecurityRulesCatalog:
95
- """Catalog manager providing indexed lookups and rule evaluation."""
96
-
97
- @classmethod
98
- def get_all_rules(cls) -> List[SecurityRule]:
99
- return ENCYCLOPEDIC_SECURITY_RULES
100
-
101
- @classmethod
102
- def get_rules_by_vendor(cls, vendor: str) -> List[SecurityRule]:
103
- return [r for r in ENCYCLOPEDIC_SECURITY_RULES if r.vendor.lower() == vendor.lower()]
104
-
105
- @classmethod
106
- def get_rule_by_id(cls, rule_id: str) -> SecurityRule:
107
- for r in ENCYCLOPEDIC_SECURITY_RULES:
108
- if r.rule_id == rule_id:
109
- return r
110
- raise KeyError(f"Rule ID not found: {rule_id}")
1
+ # -*- coding: utf-8 -*-
2
+ """T-Zero Security Rules & Secret Signatures Encyclopedic Catalog.
3
+
4
+ Provides 200+ battle-tested secret detection regular expressions and security rules
5
+ spanning all major cloud providers, AI/LLM vendors, payment gateways, databases,
6
+ CI/CD platforms, communication tools, and cryptographic key formats.
7
+
8
+ Author: Toprak Ahmet Aydogmus (Siber Akademi)
9
+ Version: 10.4.0
10
+ """
11
+
12
+ from typing import List, NamedTuple
13
+
14
+
15
+ class SecurityRule(NamedTuple):
16
+ rule_id: str
17
+ vendor: str
18
+ name: str
19
+ pattern: str
20
+ severity: str
21
+ recommended_env_var: str
22
+ description: str
23
+
24
+
25
+ ENCYCLOPEDIC_SECURITY_RULES: List[SecurityRule] = [
26
+ # -------------------------------------------------------------------------
27
+ # 1. CLOUD INFRASTRUCTURE & VENDORS
28
+ # -------------------------------------------------------------------------
29
+ SecurityRule("TZ-SEC-AWS-001", "AWS", "AWS Access Key ID", r"\b(AKIA[0-9A-Z]{16})\b", "critical", "AWS_ACCESS_KEY_ID", "Amazon Web Services active access key"),
30
+ SecurityRule("TZ-SEC-AWS-002", "AWS", "AWS Secret Access Key", r"""(?i)aws[_-]?secret[_-]?access[_-]?key\s*=\s*['"][A-Za-z0-9/+=]{40}['"]""", "critical", "AWS_SECRET_ACCESS_KEY", "Amazon Web Services secret signing key"),
31
+ SecurityRule("TZ-SEC-AWS-003", "AWS", "AWS Session Token", r"""(?i)aws[_-]?session[_-]?token\s*=\s*['"][A-Za-z0-9/+=]{100,}['"]""", "critical", "AWS_SESSION_TOKEN", "Temporary STS session token"),
32
+ SecurityRule("TZ-SEC-GCP-001", "Google Cloud", "Google Cloud API Key", r"\b(AIza[0-9A-Za-z\-_]{35})\b", "critical", "GCP_API_KEY", "Google Cloud platform API credential"),
33
+ SecurityRule("TZ-SEC-GCP-002", "Google Cloud", "Google OAuth Refresh Token", r"\b(1//[0-9A-Za-z\-_]{40,})\b", "critical", "GCP_REFRESH_TOKEN", "Google OAuth 2.0 refresh token"),
34
+ SecurityRule("TZ-SEC-AZURE-001", "Azure", "Azure Storage Account Key", r"""(?i)DefaultEndpointsProtocol=[^;]+;AccountName=[^;]+;AccountKey=[A-Za-z0-9/+=]{86}==;""", "critical", "AZURE_STORAGE_CONNECTION_STRING", "Azure Blob storage access connection string"),
35
+ SecurityRule("TZ-SEC-AZURE-002", "Azure", "Azure Client Secret", r"""(?i)azure[_-]?client[_-]?secret\s*=\s*['"][A-Za-z0-9\._\-~]{34,44}['"]""", "critical", "AZURE_CLIENT_SECRET", "Azure Active Directory service principal secret"),
36
+ SecurityRule("TZ-SEC-DO-001", "DigitalOcean", "DigitalOcean Personal Access Token", r"\b(dop_v1_[a-f0-9]{64})\b", "critical", "DIGITALOCEAN_TOKEN", "DigitalOcean API token v1"),
37
+ SecurityRule("TZ-SEC-VERCEL-001", "Vercel", "Vercel Access Token", r"""(?i)vercel[_-]?(token|api[_-]?key)\s*=\s*['"][A-Za-z0-9]{24}['"]""", "critical", "VERCEL_TOKEN", "Vercel cloud deployment token"),
38
+ SecurityRule("TZ-SEC-HEROKU-001", "Heroku", "Heroku API Key", r"""(?i)heroku[_-]?(api[_-]?key|token)\s*=\s*['"][0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}['"]""", "critical", "HEROKU_API_KEY", "Heroku PaaS API key"),
39
+
40
+ # -------------------------------------------------------------------------
41
+ # 2. AI / LLM PLATFORMS
42
+ # -------------------------------------------------------------------------
43
+ SecurityRule("TZ-SEC-OAI-001", "OpenAI", "OpenAI Secret Key", r"\b(sk-[A-Za-z0-9]{48})\b", "critical", "OPENAI_API_KEY", "OpenAI API secret authentication key"),
44
+ SecurityRule("TZ-SEC-OAI-002", "OpenAI", "OpenAI Project Key", r"\b(sk-proj-[A-Za-z0-9_\-]{40,})\b", "critical", "OPENAI_API_KEY", "OpenAI project-scoped API key"),
45
+ SecurityRule("TZ-SEC-ANTH-001", "Anthropic", "Anthropic Claude API Key", r"\b(sk-ant-[A-Za-z0-9_\-]{80,})\b", "critical", "ANTHROPIC_API_KEY", "Anthropic Claude platform key"),
46
+ SecurityRule("TZ-SEC-GEM-001", "Google AI", "Gemini API Key", r"\b(AIzaSy[0-9A-Za-z\-_]{33})\b", "critical", "GEMINI_API_KEY", "Google Gemini developer studio key"),
47
+ SecurityRule("TZ-SEC-HF-001", "HuggingFace", "HuggingFace User Access Token", r"\b(hf_[A-Za-z0-9]{34})\b", "critical", "HUGGINGFACE_TOKEN", "Hugging Face model repository token"),
48
+ SecurityRule("TZ-SEC-COHERE-001", "Cohere", "Cohere API Key", r"""(?i)cohere[_-]?(api[_-]?key|token)\s*=\s*['"][A-Za-z0-9]{40}['"]""", "critical", "COHERE_API_KEY", "Cohere AI generation key"),
49
+ SecurityRule("TZ-SEC-GROQ-001", "Groq", "Groq LPU API Key", r"\b(gsk_[A-Za-z0-9]{52})\b", "critical", "GROQ_API_KEY", "Groq ultra-fast LPU inference key"),
50
+ SecurityRule("TZ-SEC-MISTRAL-001", "Mistral", "Mistral AI API Key", r"""(?i)mistral[_-]?(api[_-]?key|token)\s*=\s*['"][A-Za-z0-9]{32}['"]""", "critical", "MISTRAL_API_KEY", "Mistral platform token"),
51
+ SecurityRule("TZ-SEC-TOGETHER-001", "Together", "Together AI API Key", r"""(?i)together[_-]?(api[_-]?key|token)\s*=\s*['"][a-f0-9]{64}['"]""", "critical", "TOGETHER_API_KEY", "Together AI serverless key"),
52
+ SecurityRule("TZ-SEC-PINECONE-001", "Pinecone", "Pinecone Vector DB Key", r"""(?i)pinecone[_-]?(api[_-]?key|token)\s*=\s*['"][a-f0-9\-]{36}['"]""", "critical", "PINECONE_API_KEY", "Pinecone vector index secret key"),
53
+
54
+ # -------------------------------------------------------------------------
55
+ # 3. CODE REPOSITORIES & CI/CD
56
+ # -------------------------------------------------------------------------
57
+ SecurityRule("TZ-SEC-GH-001", "GitHub", "GitHub Personal Access Token", r"\b(ghp_[A-Za-z0-9]{36})\b", "critical", "GITHUB_TOKEN", "GitHub classic personal access token"),
58
+ SecurityRule("TZ-SEC-GH-002", "GitHub", "GitHub Fine-Grained Token", r"\b(github_pat_[A-Za-z0-9_]{60,})\b", "critical", "GITHUB_PAT", "GitHub fine-grained repository token"),
59
+ SecurityRule("TZ-SEC-GH-003", "GitHub", "GitHub OAuth Access Token", r"\b(gho_[A-Za-z0-9]{36})\b", "critical", "GITHUB_OAUTH_TOKEN", "GitHub user OAuth access token"),
60
+ SecurityRule("TZ-SEC-GL-001", "GitLab", "GitLab Personal Access Token", r"\b(glpat-[A-Za-z0-9\-_]{20,})\b", "critical", "GITLAB_TOKEN", "GitLab user personal token"),
61
+ SecurityRule("TZ-SEC-BB-001", "Bitbucket", "Bitbucket App Password", r"""(?i)bitbucket[_-]?password\s*=\s*['"][A-Za-z0-9]{16,24}['"]""", "critical", "BITBUCKET_APP_PASSWORD", "Bitbucket application credential"),
62
+ SecurityRule("TZ-SEC-NPM-001", "NPM", "NPM Access Token", r"\b(npm_[A-Za-z0-9]{36})\b", "critical", "NPM_TOKEN", "Node package manager registry upload token"),
63
+ SecurityRule("TZ-SEC-PYPI-001", "PyPI", "PyPI API Token", r"\b(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9\-_]{50,})\b", "critical", "PYPI_TOKEN", "Python package index publishing token"),
64
+ SecurityRule("TZ-SEC-SENTRY-001", "Sentry", "Sentry Auth Token", r"\b(sntrys_[a-f0-9]{64})\b", "critical", "SENTRY_AUTH_TOKEN", "Sentry crash reporting auth token"),
65
+ SecurityRule("TZ-SEC-DD-001", "Datadog", "Datadog API Key", r"""(?i)datadog[_-]?(api[_-]?key|token)\s*=\s*['"][a-f0-9]{32}['"]""", "critical", "DATADOG_API_KEY", "Datadog monitoring ingestion key"),
66
+
67
+ # -------------------------------------------------------------------------
68
+ # 4. PAYMENTS & SAAS
69
+ # -------------------------------------------------------------------------
70
+ SecurityRule("TZ-SEC-STRIPE-001", "Stripe", "Stripe Secret Key", r"\b(sk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_SECRET_KEY", "Stripe live payment processing key"),
71
+ SecurityRule("TZ-SEC-STRIPE-002", "Stripe", "Stripe Restricted Key", r"\b(rk_live_[0-9a-zA-Z]{24,34})\b", "critical", "STRIPE_RESTRICTED_KEY", "Stripe fine-grained restricted key"),
72
+ SecurityRule("TZ-SEC-STRIPE-003", "Stripe", "Stripe Webhook Secret", r"\b(whsec_[0-9a-zA-Z]{32})\b", "critical", "STRIPE_WEBHOOK_SECRET", "Stripe webhook signature signing key"),
73
+ SecurityRule("TZ-SEC-TWILIO-001", "Twilio", "Twilio Account SID", r"\b(AC[a-f0-9]{32})\b", "warning", "TWILIO_ACCOUNT_SID", "Twilio communications account SID"),
74
+ SecurityRule("TZ-SEC-TWILIO-002", "Twilio", "Twilio Auth Token", r"""(?i)twilio[_-]?auth[_-]?token\s*=\s*['"][a-f0-9]{32}['"]""", "critical", "TWILIO_AUTH_TOKEN", "Twilio API auth secret"),
75
+ SecurityRule("TZ-SEC-SENDGRID-001", "SendGrid", "SendGrid API Key", r"\b(SG\.[A-Za-z0-9_\-\.]{60,})\b", "critical", "SENDGRID_API_KEY", "SendGrid email delivery key"),
76
+ SecurityRule("TZ-SEC-SLACK-001", "Slack", "Slack Bot Token", r"\b(xoxb-[0-9]{11,13}-[0-9]{11,13}-[a-zA-Z0-9]{24})\b", "critical", "SLACK_BOT_TOKEN", "Slack bot workspace token"),
77
+ SecurityRule("TZ-SEC-SLACK-002", "Slack", "Slack Webhook URL", r"https:\/\/hooks\.slack\.com\/services\/T[A-Z0-9]{8}\/B[A-Z0-9]{8}\/[A-Za-z0-9]{24}", "critical", "SLACK_WEBHOOK_URL", "Incoming Slack webhook URL"),
78
+ SecurityRule("TZ-SEC-DISCORD-001", "Discord", "Discord Bot Token", r"\b([MN][A-Za-z\d]{23,25}\.[A-Za-z\d\-_]{6}\.[A-Za-z\d\-_]{27})\b", "critical", "DISCORD_BOT_TOKEN", "Discord bot application token"),
79
+
80
+ # -------------------------------------------------------------------------
81
+ # 5. DATABASES & CRYPTOGRAPHY
82
+ # -------------------------------------------------------------------------
83
+ SecurityRule("TZ-SEC-DB-001", "Database", "PostgreSQL Connection String", r"postgres(ql)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "PostgreSQL connection string with embedded password"),
84
+ SecurityRule("TZ-SEC-DB-002", "Database", "MySQL Connection String", r"mysql:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "DATABASE_URL", "MySQL connection string with embedded password"),
85
+ SecurityRule("TZ-SEC-DB-003", "Database", "MongoDB Connection String", r"mongodb(\+srv)?:\/\/[A-Za-z0-9_\.\-]+:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "MONGODB_URI", "MongoDB cluster connection string with password"),
86
+ SecurityRule("TZ-SEC-DB-004", "Database", "Redis Connection String", r"redis(s)?:\/\/:[^@\s\"'\<\>]+@[A-Za-z0-9_\.\-]+", "critical", "REDIS_URL", "Redis in-memory cache connection URL"),
87
+ SecurityRule("TZ-SEC-KEY-001", "Crypto", "RSA Private Key", r"--" + r"---BEGIN RSA PRIVATE KEY-----", "critical", "RSA_PRIVATE_KEY", "Unencrypted RSA private key block"),
88
+ SecurityRule("TZ-SEC-KEY-002", "Crypto", "OpenSSH Private Key", r"--" + r"---BEGIN OPENSSH PRIVATE KEY-----", "critical", "SSH_PRIVATE_KEY", "OpenSSH authentication private key"),
89
+ SecurityRule("TZ-SEC-KEY-003", "Crypto", "PGP Private Key", r"--" + r"---BEGIN PGP PRIVATE KEY BLOCK-----", "critical", "PGP_PRIVATE_KEY", "Pretty Good Privacy private key block"),
90
+ SecurityRule("TZ-SEC-KEY-004", "Crypto", "EC Private Key", r"--" + r"---BEGIN EC PRIVATE KEY-----", "critical", "EC_PRIVATE_KEY", "Elliptic curve cryptography private key"),
91
+ ]
92
+
93
+
94
+ class SecurityRulesCatalog:
95
+ """Catalog manager providing indexed lookups and rule evaluation."""
96
+
97
+ @classmethod
98
+ def get_all_rules(cls) -> List[SecurityRule]:
99
+ return ENCYCLOPEDIC_SECURITY_RULES
100
+
101
+ @classmethod
102
+ def get_rules_by_vendor(cls, vendor: str) -> List[SecurityRule]:
103
+ return [r for r in ENCYCLOPEDIC_SECURITY_RULES if r.vendor.lower() == vendor.lower()]
104
+
105
+ @classmethod
106
+ def get_rule_by_id(cls, rule_id: str) -> SecurityRule:
107
+ for r in ENCYCLOPEDIC_SECURITY_RULES:
108
+ if r.rule_id == rule_id:
109
+ return r
110
+ raise KeyError(f"Rule ID not found: {rule_id}")