praxis-sec 1.0.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 (183) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +170 -0
  3. package/ai-defense/cost-protection.md +292 -0
  4. package/ai-defense/llm-security-checklist.md +324 -0
  5. package/ai-defense/prompt-injection-patterns.js +283 -0
  6. package/ai-defense/system-prompt-armor.md +327 -0
  7. package/checklists/launch-day.md +168 -0
  8. package/cli/agents/abom-generator.js +225 -0
  9. package/cli/agents/agent-attestation-agent.js +318 -0
  10. package/cli/agents/agent-config-scanner.js +787 -0
  11. package/cli/agents/agent-telemetry-agent.js +415 -0
  12. package/cli/agents/agentic-security-agent.js +296 -0
  13. package/cli/agents/agentic-supply-chain-agent.js +463 -0
  14. package/cli/agents/ai-infra-inventory-agent.js +449 -0
  15. package/cli/agents/api-fuzzer.js +345 -0
  16. package/cli/agents/auth-bypass-agent.js +348 -0
  17. package/cli/agents/base-agent.js +280 -0
  18. package/cli/agents/cicd-scanner.js +300 -0
  19. package/cli/agents/config-auditor.js +757 -0
  20. package/cli/agents/deep-analyzer.js +776 -0
  21. package/cli/agents/endpoint-agent-abuse-agent.js +404 -0
  22. package/cli/agents/exception-handler-agent.js +187 -0
  23. package/cli/agents/git-history-scanner.js +169 -0
  24. package/cli/agents/governance-audits.js +138 -0
  25. package/cli/agents/hermes-security-agent.js +536 -0
  26. package/cli/agents/html-reporter.js +1125 -0
  27. package/cli/agents/index.js +147 -0
  28. package/cli/agents/injection-tester.js +502 -0
  29. package/cli/agents/legal-risk-agent.js +328 -0
  30. package/cli/agents/llm-redteam.js +199 -0
  31. package/cli/agents/managed-agent-scanner.js +333 -0
  32. package/cli/agents/mcp-security-agent.js +588 -0
  33. package/cli/agents/memory-poisoning-agent.js +305 -0
  34. package/cli/agents/mobile-scanner.js +231 -0
  35. package/cli/agents/model-file-scanner.js +259 -0
  36. package/cli/agents/orchestrator.js +355 -0
  37. package/cli/agents/pii-compliance-agent.js +301 -0
  38. package/cli/agents/policy-engine.js +229 -0
  39. package/cli/agents/prompt-injection-prober.js +224 -0
  40. package/cli/agents/rag-security-agent.js +204 -0
  41. package/cli/agents/recon-agent.js +207 -0
  42. package/cli/agents/sbom-generator.js +265 -0
  43. package/cli/agents/scoring-engine.js +273 -0
  44. package/cli/agents/ssrf-prober.js +130 -0
  45. package/cli/agents/stateful-watcher.js +238 -0
  46. package/cli/agents/supabase-rls-agent.js +154 -0
  47. package/cli/agents/supply-chain-agent.js +857 -0
  48. package/cli/agents/swarm-orchestrator.js +200 -0
  49. package/cli/agents/verifier-agent.js +303 -0
  50. package/cli/agents/vibe-coding-agent.js +250 -0
  51. package/cli/bin/praxis.js +866 -0
  52. package/cli/commands/abom.js +73 -0
  53. package/cli/commands/agent-fix.js +1245 -0
  54. package/cli/commands/audit.js +1180 -0
  55. package/cli/commands/autofix.js +383 -0
  56. package/cli/commands/baseline.js +193 -0
  57. package/cli/commands/benchmark.js +327 -0
  58. package/cli/commands/checklist.js +223 -0
  59. package/cli/commands/ci.js +403 -0
  60. package/cli/commands/deps.js +516 -0
  61. package/cli/commands/diff.js +200 -0
  62. package/cli/commands/doctor.js +195 -0
  63. package/cli/commands/env-audit.js +349 -0
  64. package/cli/commands/fix.js +218 -0
  65. package/cli/commands/guard.js +396 -0
  66. package/cli/commands/hooks.js +278 -0
  67. package/cli/commands/init.js +514 -0
  68. package/cli/commands/legal.js +158 -0
  69. package/cli/commands/live-advisories.js +241 -0
  70. package/cli/commands/mcp.js +660 -0
  71. package/cli/commands/openclaw.js +386 -0
  72. package/cli/commands/red-team.js +350 -0
  73. package/cli/commands/redteam.js +78 -0
  74. package/cli/commands/remediate.js +797 -0
  75. package/cli/commands/rotate.js +768 -0
  76. package/cli/commands/rules.js +196 -0
  77. package/cli/commands/scan-mcp.js +534 -0
  78. package/cli/commands/scan-skill.js +588 -0
  79. package/cli/commands/scan-standard.js +251 -0
  80. package/cli/commands/scan.js +524 -0
  81. package/cli/commands/score.js +449 -0
  82. package/cli/commands/shell.js +514 -0
  83. package/cli/commands/team-report.js +398 -0
  84. package/cli/commands/undo.js +161 -0
  85. package/cli/commands/update-intel.js +126 -0
  86. package/cli/commands/vibe-check.js +276 -0
  87. package/cli/commands/watch.js +757 -0
  88. package/cli/commands/web.js +63 -0
  89. package/cli/core/ast/guardrail-detector.js +141 -0
  90. package/cli/core/ast/index.js +22 -0
  91. package/cli/core/ast/parser.js +676 -0
  92. package/cli/core/ast/scope-tree.js +287 -0
  93. package/cli/core/ast/taint-tracker.js +158 -0
  94. package/cli/core/branding.js +37 -0
  95. package/cli/core/env.js +38 -0
  96. package/cli/core/errors.js +61 -0
  97. package/cli/core/fs.js +62 -0
  98. package/cli/core/output/compliance.js +90 -0
  99. package/cli/core/output/html-theme.js +158 -0
  100. package/cli/core/output/index.js +57 -0
  101. package/cli/core/output/json.js +48 -0
  102. package/cli/core/output/sarif.js +240 -0
  103. package/cli/core/version.js +67 -0
  104. package/cli/core/web/jobs.js +183 -0
  105. package/cli/core/web/projects.js +146 -0
  106. package/cli/core/web/server.js +439 -0
  107. package/cli/data/atlas-knowledge.json +5640 -0
  108. package/cli/data/eaa-catalog.json +39 -0
  109. package/cli/data/known-mcps.json +26 -0
  110. package/cli/data/probes/prompt-injection-corpus.json +271 -0
  111. package/cli/data/threat-intel.json +85 -0
  112. package/cli/data/threatpacks/latest.json +41 -0
  113. package/cli/hooks/patterns.js +313 -0
  114. package/cli/hooks/post-tool-use.js +140 -0
  115. package/cli/hooks/pre-tool-use.js +186 -0
  116. package/cli/index.js +90 -0
  117. package/cli/providers/llm-provider.js +766 -0
  118. package/cli/utils/autofix-rules.js +74 -0
  119. package/cli/utils/cache-manager.js +310 -0
  120. package/cli/utils/compliance-map.js +191 -0
  121. package/cli/utils/entropy.js +132 -0
  122. package/cli/utils/fix-ledger.js +127 -0
  123. package/cli/utils/hermes-tool-registry.js +252 -0
  124. package/cli/utils/intel/cache.js +61 -0
  125. package/cli/utils/intel/http.js +88 -0
  126. package/cli/utils/intel/index.js +235 -0
  127. package/cli/utils/intel/merge.js +229 -0
  128. package/cli/utils/intel/sources/epss.js +54 -0
  129. package/cli/utils/intel/sources/ghsa.js +81 -0
  130. package/cli/utils/intel/sources/gitguardian.js +40 -0
  131. package/cli/utils/intel/sources/gitleaks.js +101 -0
  132. package/cli/utils/intel/sources/kev.js +38 -0
  133. package/cli/utils/intel/sources/nvd.js +84 -0
  134. package/cli/utils/intel/sources/osv.js +132 -0
  135. package/cli/utils/intel/sources/phylum.js +44 -0
  136. package/cli/utils/intel/sources/snyk.js +46 -0
  137. package/cli/utils/intel/sources/socket.js +69 -0
  138. package/cli/utils/intel/sources/sonatype.js +84 -0
  139. package/cli/utils/intel/sources/threatpack.js +69 -0
  140. package/cli/utils/mcp-trust.js +60 -0
  141. package/cli/utils/output.js +251 -0
  142. package/cli/utils/patterns.js +1130 -0
  143. package/cli/utils/pdf-generator.js +94 -0
  144. package/cli/utils/plugin-loader.js +364 -0
  145. package/cli/utils/rule-import.js +228 -0
  146. package/cli/utils/rule-registry.js +426 -0
  147. package/cli/utils/scan-fingerprint.js +109 -0
  148. package/cli/utils/scan-playbook.js +312 -0
  149. package/cli/utils/score-history.js +119 -0
  150. package/cli/utils/secrets-verifier.js +247 -0
  151. package/cli/utils/security-memory.js +296 -0
  152. package/cli/utils/standards/atlas-knowledge.js +87 -0
  153. package/cli/utils/standards/index.js +127 -0
  154. package/cli/utils/standards/sources/avid.js +45 -0
  155. package/cli/utils/standards/sources/eu-ai-act.js +89 -0
  156. package/cli/utils/standards/sources/google-saif.js +39 -0
  157. package/cli/utils/standards/sources/iso-42001.js +94 -0
  158. package/cli/utils/standards/sources/mitre-atlas.js +54 -0
  159. package/cli/utils/standards/sources/nist-ai-600-1.js +45 -0
  160. package/cli/utils/standards/sources/owasp-llm.js +45 -0
  161. package/cli/utils/standards/sources/owasp-ml.js +45 -0
  162. package/cli/utils/threat-intel.js +265 -0
  163. package/configs/firebase/firestore-rules.txt +215 -0
  164. package/configs/firebase/security-checklist.md +236 -0
  165. package/configs/firebase/storage-rules.txt +206 -0
  166. package/configs/gitignore-template +258 -0
  167. package/configs/nextjs-security-headers.js +220 -0
  168. package/configs/praxisignore-template +50 -0
  169. package/configs/supabase/secure-client.ts +225 -0
  170. package/configs/supabase/security-checklist.md +278 -0
  171. package/docs/THIRD_PARTY_NOTICES.md +26 -0
  172. package/docs/THREAT_INTEL.md +292 -0
  173. package/docs/USAGE.md +1205 -0
  174. package/docs/design/WEB-UI.md +82 -0
  175. package/package.json +71 -0
  176. package/scripts/check-determinism.mjs +119 -0
  177. package/snippets/README.md +122 -0
  178. package/snippets/api-security/api-security-checklist.md +412 -0
  179. package/snippets/api-security/cors-config.ts +322 -0
  180. package/snippets/api-security/input-validation.ts +430 -0
  181. package/snippets/auth/jwt-checklist.md +322 -0
  182. package/snippets/rate-limiting/nextjs-middleware.ts +211 -0
  183. package/snippets/rate-limiting/upstash-ratelimit.ts +229 -0
@@ -0,0 +1,60 @@
1
+ /**
2
+ * MCP trust registry — known MCP servers with trust scores.
3
+ *
4
+ * Loads cli/data/known-mcps.json (Praxis-curated). The file is integrity-
5
+ * checked against an embedded SHA-256 so a tampered registry degrades
6
+ * gracefully (lookups disabled) instead of silently trusting anything.
7
+ */
8
+
9
+ import fs from 'fs';
10
+ import path from 'path';
11
+ import crypto from 'crypto';
12
+ import { fileURLToPath } from 'url';
13
+
14
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
15
+ const REGISTRY_PATH = path.join(__dirname, '..', 'data', 'known-mcps.json');
16
+
17
+ // SHA-256 of the registry file at curation time. If the file changes,
18
+ // update this constant and bump the registry version together.
19
+ export const EXPECTED_SHA256 = 'FA88051B0832B9DEDA6A43B1FF370F78A4408C78A9C846E6DE2F27A8169180D1';
20
+
21
+ let _cache = null;
22
+
23
+ function load() {
24
+ if (_cache) return _cache;
25
+ try {
26
+ const raw = fs.readFileSync(REGISTRY_PATH, 'utf8');
27
+ const hash = crypto.createHash('sha256').update(raw).digest('hex').toUpperCase();
28
+ const data = JSON.parse(raw);
29
+ _cache = {
30
+ servers: data.servers || {},
31
+ verified: hash === EXPECTED_SHA256,
32
+ };
33
+ } catch {
34
+ _cache = { servers: {}, verified: false };
35
+ }
36
+ return _cache;
37
+ }
38
+
39
+ /**
40
+ * Look up a package name in the trust registry.
41
+ * Returns { tier, trust, note } or { tier: 'unknown', trust: 0 }.
42
+ */
43
+ export function lookupTrust(packageName) {
44
+ const { servers, verified } = load();
45
+ if (!verified) return { tier: 'unverified-registry', trust: 0 };
46
+ const entry = servers[packageName];
47
+ if (!entry) return { tier: 'unknown', trust: 0 };
48
+ return { tier: entry.tier, trust: entry.trust, note: entry.note };
49
+ }
50
+
51
+ /** All known package names (for typosquat-distance checks). */
52
+ export function listKnown() {
53
+ const { servers } = load();
54
+ return Object.keys(servers);
55
+ }
56
+
57
+ /** Whether the registry file passes its integrity check. */
58
+ export function registryIntegrityOk() {
59
+ return load().verified;
60
+ }
@@ -0,0 +1,251 @@
1
+ /**
2
+ * Output Utilities
3
+ * ================
4
+ *
5
+ * Consistent, pretty terminal output for the CLI.
6
+ * Uses chalk for colors and provides helper functions
7
+ * for common output patterns.
8
+ */
9
+
10
+ import chalk from 'chalk';
11
+
12
+ // =============================================================================
13
+ // SEVERITY COLORS
14
+ // =============================================================================
15
+
16
+ export const severityColors = {
17
+ critical: chalk.bgRed.white.bold,
18
+ high: chalk.red.bold,
19
+ medium: chalk.yellow,
20
+ low: chalk.blue
21
+ };
22
+
23
+ export const severityIcons = {
24
+ critical: '\u2620\ufe0f ', // skull
25
+ high: '\u26a0\ufe0f ', // warning
26
+ medium: '\u26a1', // lightning
27
+ low: '\u2139\ufe0f ' // info
28
+ };
29
+
30
+ // =============================================================================
31
+ // OUTPUT HELPERS
32
+ // =============================================================================
33
+
34
+ /**
35
+ * Print a section header
36
+ */
37
+ export function header(text) {
38
+ console.log();
39
+ console.log(chalk.cyan.bold('='.repeat(60)));
40
+ console.log(chalk.cyan.bold(` ${text}`));
41
+ console.log(chalk.cyan.bold('='.repeat(60)));
42
+ }
43
+
44
+ /**
45
+ * Print a subheader
46
+ */
47
+ export function subheader(text) {
48
+ console.log();
49
+ console.log(chalk.white.bold(text));
50
+ console.log(chalk.gray('-'.repeat(text.length)));
51
+ }
52
+
53
+ /**
54
+ * Print a success message
55
+ */
56
+ export function success(text) {
57
+ console.log(chalk.green('\u2714 ') + text);
58
+ }
59
+
60
+ /**
61
+ * Print a warning message
62
+ */
63
+ export function warning(text) {
64
+ console.log(chalk.yellow('\u26a0 ') + text);
65
+ }
66
+
67
+ /**
68
+ * Print an error message
69
+ */
70
+ export function error(text) {
71
+ console.log(chalk.red('\u2718 ') + text);
72
+ }
73
+
74
+ /**
75
+ * Print an info message
76
+ */
77
+ export function info(text) {
78
+ console.log(chalk.blue('\u2139 ') + text);
79
+ }
80
+
81
+ const confidenceColors = {
82
+ high: chalk.red,
83
+ medium: chalk.yellow,
84
+ low: chalk.gray,
85
+ };
86
+
87
+ /**
88
+ * Print a finding (secret detected)
89
+ */
90
+ export function finding(file, line, patternName, severity, matched, description, confidence) {
91
+ const color = severityColors[severity] || chalk.white;
92
+ const icon = severityIcons[severity] || '';
93
+ const confColor = confidenceColors[confidence] || chalk.gray;
94
+ const confLabel = confidence ? ` ${chalk.gray('Confidence:')} ${confColor(confidence)}` : '';
95
+
96
+ console.log();
97
+ console.log(chalk.white.bold(`${file}:${line}`));
98
+ console.log(` ${icon}${color(`[${severity.toUpperCase()}]`)} ${chalk.white(patternName)}`);
99
+ console.log(` ${chalk.gray('Found:')} ${chalk.yellow(maskSecret(matched))}`);
100
+ if (confLabel) console.log(confLabel);
101
+ console.log(` ${chalk.gray('Why:')} ${description}`);
102
+ }
103
+
104
+ /**
105
+ * Print a vulnerability finding (code issue — show matched code, not masked)
106
+ */
107
+ export function vulnerabilityFinding(file, line, patternName, severity, matched, description) {
108
+ const color = severityColors[severity] || chalk.white;
109
+ const icon = severityIcons[severity] || '';
110
+ const snippet = matched.length > 80 ? matched.slice(0, 80) + '…' : matched;
111
+
112
+ console.log();
113
+ console.log(chalk.white.bold(`${file}:${line}`));
114
+ console.log(` ${icon}${color(`[${severity.toUpperCase()}]`)} ${chalk.white(patternName)}`);
115
+ console.log(` ${chalk.gray('Code:')} ${chalk.cyan(snippet)}`);
116
+ console.log(` ${chalk.gray('Why:')} ${description}`);
117
+ }
118
+
119
+ /**
120
+ * Mask the middle of a secret for safe display
121
+ */
122
+ export function maskSecret(secret) {
123
+ if (secret.length <= 6) {
124
+ return '***';
125
+ }
126
+ if (secret.length <= 12) {
127
+ return secret.substring(0, 3) + '***';
128
+ }
129
+ return secret.substring(0, 4) + '***' + secret.substring(secret.length - 4);
130
+ }
131
+
132
+ /**
133
+ * Print a summary box
134
+ *
135
+ * stats can include:
136
+ * total, critical, high, medium, filesScanned
137
+ * secretsTotal (optional), vulnsTotal (optional)
138
+ */
139
+ export function summary(stats) {
140
+ console.log();
141
+ console.log(chalk.cyan('='.repeat(60)));
142
+
143
+ if (stats.total === 0) {
144
+ console.log(chalk.green.bold(' \u2714 No issues detected!'));
145
+ } else {
146
+ const secretsTotal = stats.secretsTotal ?? stats.total;
147
+ const vulnsTotal = stats.vulnsTotal ?? 0;
148
+
149
+ if (secretsTotal > 0) {
150
+ console.log(chalk.red.bold(` \u26a0 Found ${secretsTotal} secret(s)`));
151
+ }
152
+ if (vulnsTotal > 0) {
153
+ console.log(chalk.yellow.bold(` \u26a0 Found ${vulnsTotal} code vulnerability/vulnerabilities`));
154
+ }
155
+
156
+ if (stats.critical > 0) {
157
+ console.log(chalk.red(` \u2022 Critical: ${stats.critical}`));
158
+ }
159
+ if (stats.high > 0) {
160
+ console.log(chalk.red(` \u2022 High: ${stats.high}`));
161
+ }
162
+ if (stats.medium > 0) {
163
+ console.log(chalk.yellow(` \u2022 Medium: ${stats.medium}`));
164
+ }
165
+ }
166
+
167
+ console.log(chalk.gray(` Files scanned: ${stats.filesScanned}`));
168
+ console.log(chalk.cyan('='.repeat(60)));
169
+ console.log(chalk.gray(` Cloud dashboard & team scanning: `) + chalk.cyan(''));
170
+ }
171
+
172
+ /**
173
+ * Print recommended actions after finding code vulnerabilities
174
+ */
175
+ export function vulnRecommendations() {
176
+ console.log();
177
+ console.log(chalk.yellow.bold('Code Vulnerability Actions:'));
178
+ console.log();
179
+ console.log(chalk.white('1.') + ' Fix the flagged code patterns (see "Why" descriptions above)');
180
+ console.log(chalk.white('2.') + ' Use # praxis-ignore on lines that are safe (e.g. internal tools, controlled input)');
181
+ console.log(chalk.white('3.') + ' Run npx praxis-sec checklist for a full launch-day security review');
182
+ console.log();
183
+ }
184
+
185
+ /**
186
+ * Print recommended actions after finding secrets
187
+ */
188
+ export function recommendations() {
189
+ console.log();
190
+ console.log(chalk.cyan.bold('Recommended Actions:'));
191
+ console.log();
192
+ console.log(chalk.white('1.') + ' Move secrets to environment variables (.env file)');
193
+ console.log(chalk.white('2.') + ' Add .env to your .gitignore');
194
+ console.log(chalk.white('3.') + chalk.yellow(' If already committed:'));
195
+ console.log(chalk.gray(' \u2022 Rotate the compromised credentials immediately'));
196
+ console.log(chalk.gray(' \u2022 Use git-filter-repo or BFG Repo-Cleaner to remove from history'));
197
+ console.log(chalk.gray(' \u2022 Remember: deleting doesn\'t remove git history!'));
198
+ console.log();
199
+ console.log(chalk.white('4.') + ' Set up pre-commit hooks to catch this automatically:');
200
+ console.log(chalk.gray(' npm install --save-dev husky'));
201
+ console.log(chalk.gray(' npx husky add .husky/pre-commit "npx praxis-sec scan ."'));
202
+ console.log();
203
+ }
204
+
205
+ /**
206
+ * Print a checklist item
207
+ */
208
+ export function checklistItem(number, title, checked = null) {
209
+ const checkbox = checked === null
210
+ ? chalk.gray('[ ]')
211
+ : checked
212
+ ? chalk.green('[\u2714]')
213
+ : chalk.red('[\u2718]');
214
+
215
+ console.log(`${checkbox} ${chalk.white.bold(`${number}.`)} ${title}`);
216
+ }
217
+
218
+ /**
219
+ * Print progress (for verbose mode)
220
+ */
221
+ export function progress(text) {
222
+ process.stdout.write(chalk.gray(`\r${text}`));
223
+ }
224
+
225
+ /**
226
+ * Clear the current line
227
+ */
228
+ export function clearLine() {
229
+ process.stdout.write('\r' + ' '.repeat(80) + '\r');
230
+ }
231
+
232
+ /**
233
+ * Print the Praxis ASCII banner.
234
+ * Call at the top of any command that should show branding.
235
+ */
236
+ export function printBanner(version) {
237
+ console.log();
238
+ console.log(chalk.cyan('██████╗ ██████╗ █████╗ ██╗ ██╗██╗███████╗'));
239
+ console.log(chalk.cyan('██╔══██╗██╔══██╗██╔══██╗╚██╗██╔╝██║██╔════╝'));
240
+ console.log(chalk.cyan('██████╔╝██████╔╝███████║ ╚███╔╝ ██║███████╗'));
241
+ console.log(chalk.cyan('██╔═══╝ ██╔══██╗██╔══██║ ██╔██╗ ██║╚════██║'));
242
+ console.log(chalk.cyan('██║ ██║ ██║██║ ██║██╔╝ ██╗██║███████║'));
243
+ console.log(chalk.cyan('╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚══════╝'));
244
+ console.log();
245
+ if (version) {
246
+ console.log(chalk.gray(` v${version} · 28 agents · From finding to fix, on autopilot.`));
247
+ } else {
248
+ console.log(chalk.gray(' 28 agents · From finding to fix, on autopilot.'));
249
+ }
250
+ console.log();
251
+ }