securenow 8.12.2 → 8.12.3
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.
- package/cli/threatModel.js +80 -0
- package/cli.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// `securenow threat-model <category>` — print the copy-paste threat-modeling prompt for a category,
|
|
4
|
+
// fetched from the published set at securenow.ai (the same prompt shown on securenow.ai/threat-modeling).
|
|
5
|
+
// Pipe it straight into your coding agent:
|
|
6
|
+
// claude -p "$(npx securenow threat-model authentication)"
|
|
7
|
+
// or save it: npx securenow threat-model authentication --out prompt.md
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const ui = require('./ui');
|
|
10
|
+
|
|
11
|
+
const BASE = process.env.SECURENOW_THREAT_PROMPTS_URL || 'https://securenow.ai/threat-prompts';
|
|
12
|
+
|
|
13
|
+
// Published categories (slugs). Aliases map common shorthands to the slug.
|
|
14
|
+
const CATEGORIES = [
|
|
15
|
+
'authentication', 'authorization', 'xss-csrf-cors', 'client-side-supply-chain', 'injection',
|
|
16
|
+
'oauth-sso-integrations', 'admin-support-tools', 'payment-business-logic', 'file-upload-download',
|
|
17
|
+
'messaging-notifications', 'rate-limits-and-abuse', 'legacy-endpoints', 'api-security', 'graphql-security',
|
|
18
|
+
'webhooks', 'realtime-websocket-sse', 'serverless-and-edge', 'cloud-infrastructure', 'secrets-and-cloud-iam',
|
|
19
|
+
'dns-tls-certificates', 'supply-chain-cicd', 'storage-and-logs', 'data-privacy-pii', 'ai-llm-features',
|
|
20
|
+
'secrets-and-api-key-hygiene',
|
|
21
|
+
];
|
|
22
|
+
const ALIASES = { auth: 'authentication', authz: 'authorization', oauth: 'oauth-sso-integrations', sso: 'oauth-sso-integrations', api: 'api-security', graphql: 'graphql-security', uploads: 'file-upload-download', upload: 'file-upload-download', xss: 'xss-csrf-cors', csrf: 'xss-csrf-cors', cors: 'xss-csrf-cors', rate: 'rate-limits-and-abuse', 'rate-limits': 'rate-limits-and-abuse', secrets: 'secrets-and-api-key-hygiene', privacy: 'data-privacy-pii', pii: 'data-privacy-pii', ai: 'ai-llm-features', llm: 'ai-llm-features' };
|
|
23
|
+
|
|
24
|
+
function resolveSlug(input) {
|
|
25
|
+
const raw = String(input || '').trim().toLowerCase().replace(/\.md$/, '').replace(/^\d+[-_]/, '');
|
|
26
|
+
if (!raw) return null;
|
|
27
|
+
if (CATEGORIES.includes(raw)) return raw;
|
|
28
|
+
if (ALIASES[raw]) return ALIASES[raw];
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function listCategories() {
|
|
33
|
+
ui.heading('SecureNow threat-modeling prompts');
|
|
34
|
+
console.log(' Copy-paste a prompt into your coding agent, or run it with the SecureNow CLI.\n');
|
|
35
|
+
for (const slug of CATEGORIES) console.log(' ' + slug);
|
|
36
|
+
console.log('\n Print one: securenow threat-model authentication');
|
|
37
|
+
console.log(' Pipe it: claude -p "$(securenow threat-model authentication)"');
|
|
38
|
+
console.log(' Save it: securenow threat-model authentication --out prompt.md');
|
|
39
|
+
console.log(' On the web: securenow.ai/threat-modeling');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function run(args, flags = {}) {
|
|
43
|
+
const category = args[0];
|
|
44
|
+
if (flags.list || (!category && !flags.all)) {
|
|
45
|
+
if (!category && !flags.list) ui.info('Pick a category (or --list to see them all):\n');
|
|
46
|
+
listCategories();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const slug = resolveSlug(category);
|
|
51
|
+
if (!slug) {
|
|
52
|
+
ui.error(`Unknown category "${category}". Run "securenow threat-model --list" to see the ${CATEGORIES.length} categories.`);
|
|
53
|
+
process.exitCode = 1;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const url = `${BASE}/${slug}.md`;
|
|
58
|
+
let text;
|
|
59
|
+
try {
|
|
60
|
+
const res = await fetch(url, { headers: { accept: 'text/markdown, text/plain' } });
|
|
61
|
+
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
62
|
+
text = await res.text();
|
|
63
|
+
} catch (err) {
|
|
64
|
+
ui.error(`Could not fetch the ${slug} prompt (${err.message}). Open securenow.ai/threat-modeling/${slug} in a browser instead.`);
|
|
65
|
+
process.exitCode = 1;
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (flags.out) {
|
|
70
|
+
fs.writeFileSync(flags.out, text);
|
|
71
|
+
ui.success(`Saved the ${slug} threat-model prompt to ${flags.out} (${text.length.toLocaleString()} chars).`);
|
|
72
|
+
ui.info('Open it with your coding agent at the root of a project that has the securenow SDK installed.');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Default: raw prompt to stdout so it pipes cleanly into an agent.
|
|
77
|
+
process.stdout.write(text.endsWith('\n') ? text : text + '\n');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
module.exports = { run, resolveSlug, CATEGORIES, ALIASES };
|
package/cli.js
CHANGED
|
@@ -671,6 +671,12 @@ const COMMANDS = {
|
|
|
671
671
|
rawArgv: true,
|
|
672
672
|
run: (rawArgs) => require('./cli/run').run(rawArgs),
|
|
673
673
|
},
|
|
674
|
+
'threat-model': {
|
|
675
|
+
desc: 'Print a copy-paste threat-modeling prompt for a category (pipe it into your coding agent)',
|
|
676
|
+
usage: 'securenow threat-model <authentication|authorization|…|--list> [--out prompt.md]',
|
|
677
|
+
flags: { list: 'List all threat-modeling categories', out: 'Write the prompt to a file instead of stdout' },
|
|
678
|
+
run: (a, f) => require('./cli/threatModel').run(a, f),
|
|
679
|
+
},
|
|
674
680
|
redact: {
|
|
675
681
|
desc: 'Redact sensitive fields and OTP codes from a JSON payload',
|
|
676
682
|
usage: "securenow redact '<json>' [--fields f1,f2] [--json]",
|
|
@@ -822,7 +828,7 @@ function showHelp(commandName) {
|
|
|
822
828
|
'Firewall': ['firewall'],
|
|
823
829
|
'Remediation': ['automation', 'ratelimit', 'challenge', 'blocklist', 'revoke', 'allowlist', 'trusted'],
|
|
824
830
|
'Telemetry': ['telemetry', 'log', 'event', 'test-span'],
|
|
825
|
-
'Utilities': ['redact', 'cidr', 'doctor', 'env', 'mcp'],
|
|
831
|
+
'Utilities': ['threat-model', 'redact', 'cidr', 'doctor', 'env', 'mcp'],
|
|
826
832
|
'Settings': ['instances', 'config', 'version'],
|
|
827
833
|
};
|
|
828
834
|
|
package/package.json
CHANGED