wize-dev-kit 0.5.0 → 0.6.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.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/security-overlay/_shared/allowlist.js +154 -0
- package/src/security-overlay/_shared/cli-runner.js +87 -0
- package/src/security-overlay/_shared/cvss.js +108 -0
- package/src/security-overlay/_shared/detect.js +125 -0
- package/src/security-overlay/_shared/install-script.js +205 -0
- package/src/security-overlay/_shared/invoke-phase.js +86 -0
- package/src/security-overlay/_shared/owasp.js +56 -0
- package/src/security-overlay/_shared/partial.js +225 -0
- package/src/security-overlay/_shared/preflight.js +175 -0
- package/src/security-overlay/_shared/scope-gate.js +172 -0
- package/src/security-overlay/_shared/scope-parser.js +120 -0
- package/src/security-overlay/agents/red-teamer/agent.yaml +51 -0
- package/src/security-overlay/agents/red-teamer/persona.md +43 -0
- package/src/security-overlay/data/common.txt +115 -0
- package/src/security-overlay/data/owasp-top10.json +15 -0
- package/src/security-overlay/data/tool-allowlist.json +31 -0
- package/src/security-overlay/skills/wize-sec-enumerate/scripts/run-enumerate.js +180 -0
- package/src/security-overlay/skills/wize-sec-enumerate/skill.md +32 -0
- package/src/security-overlay/skills/wize-sec-exploit/data/common.txt +117 -0
- package/src/security-overlay/skills/wize-sec-exploit/scripts/run-ffuf.js +147 -0
- package/src/security-overlay/skills/wize-sec-exploit/scripts/run-nikto.js +145 -0
- package/src/security-overlay/skills/wize-sec-exploit/scripts/run-nuclei.js +176 -0
- package/src/security-overlay/skills/wize-sec-exploit/scripts/run-sqlmap.js +139 -0
- package/src/security-overlay/skills/wize-sec-pentest/scripts/run-pipeline.js +157 -0
- package/src/security-overlay/skills/wize-sec-pentest/skill.md +52 -0
- package/src/security-overlay/skills/wize-sec-recon/scripts/run-gitleaks.js +139 -0
- package/src/security-overlay/skills/wize-sec-recon/scripts/run-osv.js +227 -0
- package/src/security-overlay/skills/wize-sec-recon/scripts/run-recon.js +162 -0
- package/src/security-overlay/skills/wize-sec-recon/skill.md +35 -0
- package/src/security-overlay/skills/wize-sec-report/scripts/render-report.js +999 -0
- package/tools/installer/onboarding.js +1 -0
- package/tools/installer/render-shared.js +5 -1
- package/tools/installer/wize-cli.js +8 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// run-osv.js — SAST dependencies via osv-scanner (primary) or grype (fallback).
|
|
4
|
+
// Auto-detects common manifest files in the project root and emits findings
|
|
5
|
+
// into sast.md (composing with secrets from run-gitleaks.js).
|
|
6
|
+
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
const fs = require('node:fs');
|
|
9
|
+
const { execFileSync } = require('node:child_process');
|
|
10
|
+
|
|
11
|
+
const { filterArgs } = require('../../../_shared/allowlist.js');
|
|
12
|
+
const { writePartial, loadPartial } = require('../../../_shared/partial.js');
|
|
13
|
+
|
|
14
|
+
const MANIFEST_FILES = [
|
|
15
|
+
'package.json', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml',
|
|
16
|
+
'requirements.txt', 'Pipfile', 'Pipfile.lock', 'pyproject.toml', 'poetry.lock',
|
|
17
|
+
'go.mod', 'go.sum',
|
|
18
|
+
'Cargo.toml', 'Cargo.lock',
|
|
19
|
+
'composer.json', 'composer.lock',
|
|
20
|
+
'Gemfile', 'Gemfile.lock'
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
function detectManifests(root) {
|
|
24
|
+
const found = [];
|
|
25
|
+
for (const m of MANIFEST_FILES) {
|
|
26
|
+
if (fs.existsSync(path.join(root, m))) found.push(m);
|
|
27
|
+
}
|
|
28
|
+
return found;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parseOsvReport(report) {
|
|
32
|
+
// osv-scanner JSON shape (simplified): { results: [{ packages: [{ package: {name, version}, vulnerabilities: [{id, severity, cvss: {score}}] }] }] }
|
|
33
|
+
const out = [];
|
|
34
|
+
const results = report && report.results ? report.results : [];
|
|
35
|
+
// Map a CVSS base score to a coarse severity label.
|
|
36
|
+
const sevFromScore = s => {
|
|
37
|
+
const n = parseFloat(s);
|
|
38
|
+
if (isNaN(n)) return null;
|
|
39
|
+
if (n === 0) return 'None';
|
|
40
|
+
if (n < 4) return 'Low';
|
|
41
|
+
if (n < 7) return 'Medium';
|
|
42
|
+
if (n < 9) return 'High';
|
|
43
|
+
return 'Critical';
|
|
44
|
+
};
|
|
45
|
+
for (const r of results) {
|
|
46
|
+
for (const p of (r.packages || [])) {
|
|
47
|
+
const name = p.package && p.package.name;
|
|
48
|
+
const version = p.package && p.package.version;
|
|
49
|
+
// osv-scanner v2 groups vulnerabilities and exposes a max_severity
|
|
50
|
+
// (CVSS) + aliases (CVE ids) per group. Prefer that; fall back to
|
|
51
|
+
// the raw vulnerabilities array for older shapes.
|
|
52
|
+
const groups = Array.isArray(p.groups) ? p.groups : [];
|
|
53
|
+
if (groups.length) {
|
|
54
|
+
for (const g of groups) {
|
|
55
|
+
const ids = g.aliases && g.aliases.length ? g.aliases : g.ids || [];
|
|
56
|
+
const cve = ids.find(x => /^CVE-/.test(x)) || ids[0] || '?';
|
|
57
|
+
const cvss = g.max_severity ? parseFloat(g.max_severity) : null;
|
|
58
|
+
out.push({ package: name, version, cve, severity: sevFromScore(g.max_severity) || 'UNKNOWN', cvss });
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
for (const v of (p.vulnerabilities || [])) {
|
|
62
|
+
const cve = v.id || '?';
|
|
63
|
+
const cvss = v.cvss && (typeof v.cvss === 'number' ? v.cvss : v.cvss.score);
|
|
64
|
+
out.push({ package: name, version, cve, severity: sevFromScore(cvss) || 'UNKNOWN', cvss });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function parseGrypeReport(report) {
|
|
73
|
+
// grype JSON shape: { matches: [{ artifact: {name, version}, vulnerability: {id, severity, cvss:[{metrics:{baseScore}}]} }] }
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const m of (report && report.matches ? report.matches : [])) {
|
|
76
|
+
const name = m.artifact && m.artifact.name;
|
|
77
|
+
const version = m.artifact && m.artifact.version;
|
|
78
|
+
const v = m.vulnerability || {};
|
|
79
|
+
const cve = v.id || '?';
|
|
80
|
+
const severity = v.severity || 'UNKNOWN';
|
|
81
|
+
let cvss = null;
|
|
82
|
+
if (Array.isArray(v.cvss) && v.cvss[0] && v.cvss[0].metrics) {
|
|
83
|
+
cvss = v.cvss[0].metrics.baseScore;
|
|
84
|
+
} else if (typeof v.cvss === 'number') {
|
|
85
|
+
cvss = v.cvss;
|
|
86
|
+
}
|
|
87
|
+
out.push({ package: name, version, cve, severity, cvss });
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function renderDepsSection(findings) {
|
|
93
|
+
if (!findings.length) return '_(nenhuma dep vulnerável encontrada)_';
|
|
94
|
+
return findings.map(f => {
|
|
95
|
+
const cvss = f.cvss != null ? ` cvss=${f.cvss}` : '';
|
|
96
|
+
return `- **${f.package}@${f.version || '?'}** \`${f.cve}\` severity=${f.severity}${cvss}`;
|
|
97
|
+
}).join('\n');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// runOsv({ securityDir, scope, active, execFn?, detectFn?, manifestRoot?, reportFilename? })
|
|
101
|
+
async function runOsv(opts = {}) {
|
|
102
|
+
const sec = opts.securityDir;
|
|
103
|
+
const scope = opts.scope;
|
|
104
|
+
const active = opts.active === true;
|
|
105
|
+
// The project to scan is the parent of `.wize/security/`. Scripts run with
|
|
106
|
+
// cwd = the kit, so default to the target repo, not process.cwd().
|
|
107
|
+
const manifestRoot = opts.manifestRoot
|
|
108
|
+
|| (sec ? path.resolve(sec, '..', '..') : process.cwd());
|
|
109
|
+
const osvReportName = 'osv-report.json';
|
|
110
|
+
const grypeReportName = 'grype-report.json';
|
|
111
|
+
|
|
112
|
+
const execFn = opts.execFn || ((bin, args) => {
|
|
113
|
+
return execFileSync(bin, args, { encoding: 'utf8', timeout: 5 * 60 * 1000 });
|
|
114
|
+
});
|
|
115
|
+
const detectFn = opts.detectFn || require('../../../_shared/detect.js').detectTools;
|
|
116
|
+
|
|
117
|
+
const tools = detectFn(['osv-scanner', 'grype'], { cacheDir: sec });
|
|
118
|
+
const osvPresent = !!(tools['osv-scanner'] && tools['osv-scanner'].present);
|
|
119
|
+
const grypePresent = !!(tools.grype && tools.grype.present);
|
|
120
|
+
|
|
121
|
+
// No tools at all -> degraded.
|
|
122
|
+
if (!osvPresent && !grypePresent) {
|
|
123
|
+
mergeSast(sec, scope, active, tools, {
|
|
124
|
+
degraded: '- deps: osv-scanner e grype ausentes — instale um dos dois e re-rode.'
|
|
125
|
+
});
|
|
126
|
+
return { ok: true, partialStatus: 'incomplete', tool: null, findings: [] };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Manifest detection: warn if the project root has no known manifest.
|
|
130
|
+
const manifests = detectManifests(manifestRoot);
|
|
131
|
+
if (manifests.length === 0) {
|
|
132
|
+
mergeSast(sec, scope, active, tools, {
|
|
133
|
+
degraded: `- deps: nenhum manifesto encontrado em ${manifestRoot} (procurando package.json, requirements.txt, go.mod, Cargo.toml, pyproject.toml, composer.json, Gemfile).`
|
|
134
|
+
});
|
|
135
|
+
return { ok: true, partialStatus: 'incomplete', tool: null, findings: [] };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Pick tool. Prefer osv-scanner; fallback to grype.
|
|
139
|
+
let findings = [];
|
|
140
|
+
let tool = null;
|
|
141
|
+
if (osvPresent) {
|
|
142
|
+
tool = 'osv-scanner';
|
|
143
|
+
const reportPath = path.join(sec, osvReportName);
|
|
144
|
+
// osv-scanner v2 needs explicit lockfiles (`-L <path>`); recursive
|
|
145
|
+
// directory scan misses composer.lock/package-lock.json. We pass each
|
|
146
|
+
// detected lockfile we found. Non-zero exit = vulns found (success).
|
|
147
|
+
const LOCKFILES = ['composer.lock', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml',
|
|
148
|
+
'requirements.txt', 'Pipfile.lock', 'poetry.lock', 'go.sum', 'Cargo.lock', 'Gemfile.lock'];
|
|
149
|
+
const lockArgs = [];
|
|
150
|
+
for (const lf of LOCKFILES) {
|
|
151
|
+
if (fs.existsSync(path.join(manifestRoot, lf))) {
|
|
152
|
+
lockArgs.push('-L', path.join(manifestRoot, lf));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const args = lockArgs.length
|
|
156
|
+
? filterArgs('osv-scanner', ['scan', 'source', ...lockArgs, '--format', 'json', '--output-file', reportPath])
|
|
157
|
+
: filterArgs('osv-scanner', ['scan', 'source', '-r', '--format', 'json', '--output-file', reportPath, manifestRoot]);
|
|
158
|
+
try {
|
|
159
|
+
execFn('osv-scanner', args, { timeout: 5 * 60 * 1000 });
|
|
160
|
+
} catch (_) { /* vulns found -> non-zero exit; report still written */ }
|
|
161
|
+
if (fs.existsSync(reportPath)) {
|
|
162
|
+
try { findings = parseOsvReport(JSON.parse(fs.readFileSync(reportPath, 'utf8'))); }
|
|
163
|
+
catch (_) { findings = []; }
|
|
164
|
+
}
|
|
165
|
+
} else if (grypePresent) {
|
|
166
|
+
tool = 'grype';
|
|
167
|
+
const reportPath = path.join(sec, grypeReportName);
|
|
168
|
+
const args = filterArgs('grype', ['dir:' + manifestRoot, '-o', 'json']);
|
|
169
|
+
execFn('grype', args, { timeout: 5 * 60 * 1000 });
|
|
170
|
+
if (fs.existsSync(reportPath)) {
|
|
171
|
+
try { findings = parseGrypeReport(JSON.parse(fs.readFileSync(reportPath, 'utf8'))); }
|
|
172
|
+
catch (_) { findings = []; }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
mergeSast(sec, scope, active, tools, {
|
|
177
|
+
deps: renderDepsSection(findings)
|
|
178
|
+
});
|
|
179
|
+
return { ok: true, partialStatus: 'complete', tool, findings };
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function mergeSast(sec, scope, active, tools, update) {
|
|
183
|
+
const existing = loadPartial({ securityDir: sec, phase: 'sast' });
|
|
184
|
+
const sections = {};
|
|
185
|
+
let mergedTools = Object.assign({}, tools);
|
|
186
|
+
if (existing) {
|
|
187
|
+
if (existing.body) {
|
|
188
|
+
const re = /## ([a-z_]+)\n\n([\s\S]*?)(?=\n## |$)/g;
|
|
189
|
+
let m;
|
|
190
|
+
while ((m = re.exec(existing.body)) !== null) {
|
|
191
|
+
sections[m[1]] = m[2].trim();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (existing.frontmatter && existing.frontmatter.tools) {
|
|
195
|
+
mergedTools = Object.assign({}, existing.frontmatter.tools, tools);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (update.degraded) {
|
|
199
|
+
sections.degraded_checks = sections.degraded_checks
|
|
200
|
+
? sections.degraded_checks + '\n' + update.degraded
|
|
201
|
+
: update.degraded;
|
|
202
|
+
}
|
|
203
|
+
if (update.deps !== undefined) sections.deps = update.deps;
|
|
204
|
+
const status = sections.degraded_checks ? 'incomplete' : 'complete';
|
|
205
|
+
writePartial({
|
|
206
|
+
securityDir: sec,
|
|
207
|
+
phase: 'sast',
|
|
208
|
+
mode: active ? 'active' : 'passive',
|
|
209
|
+
scope,
|
|
210
|
+
status,
|
|
211
|
+
tools: mergedTools,
|
|
212
|
+
sections
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
module.exports = { runOsv, parseOsvReport, parseGrypeReport, detectManifests, MANIFEST_FILES };
|
|
217
|
+
|
|
218
|
+
if (require.main === module) {
|
|
219
|
+
require('../../../_shared/cli-runner.js').runFromArgv({
|
|
220
|
+
fn: ({ securityDir, scopePath, active, manifestRoot, reportFilename } = {}) => {
|
|
221
|
+
const { loadScope } = require('../../../_shared/scope-gate.js');
|
|
222
|
+
const scope = loadScope(scopePath);
|
|
223
|
+
return runOsv({ securityDir, scope, active, manifestRoot, reportFilename });
|
|
224
|
+
},
|
|
225
|
+
argMap: { 'securityDir': 'securityDir', 'scope': 'scopePath', 'active': 'active', 'manifestRoot': 'manifestRoot', 'reportFilename': 'reportFilename' }
|
|
226
|
+
});
|
|
227
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// run-recon.js — the nmap portion of the wize-sec-recon skill.
|
|
4
|
+
// SAST (gitleaks, osv/grype) is implemented in E05 and lives in
|
|
5
|
+
// scripts/run-sast.js (sibling). The orchestrator (wize-sec-pentest) and
|
|
6
|
+
// any caller can invoke either script directly; this file only handles
|
|
7
|
+
// recon.
|
|
8
|
+
|
|
9
|
+
const path = require('node:path');
|
|
10
|
+
const { execFileSync } = require('node:child_process');
|
|
11
|
+
|
|
12
|
+
const { assertTargetInScope, ScopeError } = require('../../../_shared/scope-gate.js');
|
|
13
|
+
const { filterArgs } = require('../../../_shared/allowlist.js');
|
|
14
|
+
const { writePartial } = require('../../../_shared/partial.js');
|
|
15
|
+
|
|
16
|
+
// Default argument list for nmap. filterArgs() will drop anything not in
|
|
17
|
+
// the tool-allowlist, so this list is intentionally explicit and minimal.
|
|
18
|
+
function defaultArgs(active) {
|
|
19
|
+
const args = ['-Pn', '-T4'];
|
|
20
|
+
if (active) args.push('-sV');
|
|
21
|
+
else args.push('-sn'); // passive: ping scan only — no port scan, no service detection.
|
|
22
|
+
return args;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Parse a greppable nmap stdout into a markdown list. We only care about
|
|
26
|
+
// lines that look like `PORT/PROTO SERVICE VERSION`. Ports whose service
|
|
27
|
+
// nmap could not fingerprint (`?`, unknown, tcpwrapped, or empty version)
|
|
28
|
+
// are flagged for manual investigation — an unidentified open port is a
|
|
29
|
+
// medium-priority unknown, not just inventory.
|
|
30
|
+
function parseNmapGreppable(stdout) {
|
|
31
|
+
const lines = String(stdout || '').split('\n');
|
|
32
|
+
const out = [];
|
|
33
|
+
for (const line of lines) {
|
|
34
|
+
const m = line.match(/^(\d+\/[a-z]+)\s+(\S+)\s+(.*)$/);
|
|
35
|
+
if (!m) continue;
|
|
36
|
+
const port = m[1];
|
|
37
|
+
const service = m[2];
|
|
38
|
+
const version = m[3].trim();
|
|
39
|
+
const unidentified = /\?$/.test(service) || /^(unknown|tcpwrapped)$/i.test(service) || version === '';
|
|
40
|
+
if (unidentified) {
|
|
41
|
+
out.push(`- **${port}** \`${service}\` — ⚠️ serviço não identificado. **Investigar:** \`lsof -i :${port.split('/')[0]}\` · \`docker ps\` · \`ss -tulpn | grep ${port.split('/')[0]}\``);
|
|
42
|
+
} else {
|
|
43
|
+
out.push(`- **${port}** \`${service}\` — ${version}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return out.join('\n');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// runRecon({ securityDir, scope, target, active, execFn?, detectFn? }) ->
|
|
50
|
+
// { ok, partialStatus, mode }
|
|
51
|
+
// dependencies are injectable for tests.
|
|
52
|
+
async function runRecon(opts = {}) {
|
|
53
|
+
const sec = opts.securityDir;
|
|
54
|
+
const scope = opts.scope;
|
|
55
|
+
const target = opts.target;
|
|
56
|
+
const active = opts.active === true;
|
|
57
|
+
|
|
58
|
+
const execFn = opts.execFn || ((bin, args, opt) => {
|
|
59
|
+
return execFileSync(bin, args, { encoding: 'utf8', timeout: 60_000 });
|
|
60
|
+
});
|
|
61
|
+
const detectFn = opts.detectFn || require('../../../_shared/detect.js').detectTools;
|
|
62
|
+
|
|
63
|
+
// Gate — propagates ScopeError if scope is invalid.
|
|
64
|
+
const tools = detectFn(['nmap'], { cacheDir: sec });
|
|
65
|
+
const nmapTool = tools.nmap || { present: false };
|
|
66
|
+
|
|
67
|
+
// 1. nmap missing -> degraded partial, exit 0.
|
|
68
|
+
if (!nmapTool.present) {
|
|
69
|
+
writePartial({
|
|
70
|
+
securityDir: sec,
|
|
71
|
+
phase: 'recon',
|
|
72
|
+
mode: active ? 'active' : 'passive',
|
|
73
|
+
scope,
|
|
74
|
+
status: 'incomplete',
|
|
75
|
+
tools,
|
|
76
|
+
sections: {
|
|
77
|
+
degraded_checks: 'nmap ausente — instale nmap e re-rode a fase para resultados completos.'
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
return { ok: true, partialStatus: 'incomplete', mode: active ? 'active' : 'passive' };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 2. target out of scope -> degraded partial, ok=false (gate refused).
|
|
84
|
+
const inScope = assertTargetInScope(scope, { host: target }, { refusalsDir: sec });
|
|
85
|
+
if (!inScope) {
|
|
86
|
+
writePartial({
|
|
87
|
+
securityDir: sec,
|
|
88
|
+
phase: 'recon',
|
|
89
|
+
mode: active ? 'active' : 'passive',
|
|
90
|
+
scope,
|
|
91
|
+
status: 'incomplete',
|
|
92
|
+
tools,
|
|
93
|
+
sections: {
|
|
94
|
+
degraded_checks: `target ${target} recusado pelo gate (host not in allowlist) — ver .wize/security/.refusals.log`
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return { ok: false, partialStatus: 'incomplete', mode: active ? 'active' : 'passive' };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// 3. happy path: filterArgs + execFile.
|
|
101
|
+
const args = filterArgs('nmap', [...defaultArgs(active), target]);
|
|
102
|
+
const out = execFn('nmap', args, { timeout: 60_000 });
|
|
103
|
+
const portsText = parseNmapGreppable(out && out.stdout ? out.stdout : out);
|
|
104
|
+
const body = portsText || '_(nmap returned no parseable ports)_';
|
|
105
|
+
|
|
106
|
+
writePartial({
|
|
107
|
+
securityDir: sec,
|
|
108
|
+
phase: 'recon',
|
|
109
|
+
mode: active ? 'active' : 'passive',
|
|
110
|
+
scope,
|
|
111
|
+
status: 'complete',
|
|
112
|
+
tools,
|
|
113
|
+
sections: { open_ports: body }
|
|
114
|
+
});
|
|
115
|
+
return { ok: true, partialStatus: 'complete', mode: active ? 'active' : 'passive' };
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// --- CLI entrypoint ------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
function parseArgv(argv) {
|
|
121
|
+
const out = { active: false, securityDir: null, scopePath: null, target: null };
|
|
122
|
+
for (let i = 0; i < argv.length; i++) {
|
|
123
|
+
const a = argv[i];
|
|
124
|
+
if (a === '--active') out.active = true;
|
|
125
|
+
else if (a === '--target' && argv[i + 1]) { out.target = argv[i + 1]; i++; }
|
|
126
|
+
else if (a.startsWith('--target=')) out.target = a.slice('--target='.length);
|
|
127
|
+
else if (a === '--scope' && argv[i + 1]) { out.scopePath = argv[i + 1]; i++; }
|
|
128
|
+
else if (a.startsWith('--scope=')) out.scopePath = a.slice('--scope='.length);
|
|
129
|
+
else if (a === '--securityDir' && argv[i + 1]) { out.securityDir = argv[i + 1]; i++; }
|
|
130
|
+
else if (a.startsWith('--securityDir=')) out.securityDir = a.slice('--securityDir='.length);
|
|
131
|
+
}
|
|
132
|
+
if (!out.securityDir) out.securityDir = path.join(process.cwd(), '.wize', 'security');
|
|
133
|
+
if (!out.scopePath) out.scopePath = path.join(process.cwd(), '.wize', 'security', 'scope.md');
|
|
134
|
+
if (!out.target) {
|
|
135
|
+
// Default to scope.md dast_target.url host if available.
|
|
136
|
+
out.target = 'localhost';
|
|
137
|
+
}
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function main() {
|
|
142
|
+
const args = parseArgv(process.argv.slice(2));
|
|
143
|
+
const { loadScope } = require('../../../_shared/scope-gate.js');
|
|
144
|
+
const scope = loadScope(args.scopePath);
|
|
145
|
+
const r = await runRecon({
|
|
146
|
+
securityDir: args.securityDir,
|
|
147
|
+
scope,
|
|
148
|
+
target: args.target,
|
|
149
|
+
active: args.active
|
|
150
|
+
});
|
|
151
|
+
console.log(`recon: partial_status=${r.partialStatus} mode=${r.mode}`);
|
|
152
|
+
process.exit(r.ok ? 0 : 1);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (require.main === module) {
|
|
156
|
+
main().catch(err => {
|
|
157
|
+
console.error('✖ wize-sec-recon:', err && err.message ? err.message : err);
|
|
158
|
+
process.exit(2);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
module.exports = { runRecon, defaultArgs, parseNmapGreppable };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
code: wize-sec-recon
|
|
3
|
+
name: wize-sec-recon
|
|
4
|
+
overlay: security
|
|
5
|
+
module: security-overlay
|
|
6
|
+
owner: red-teamer
|
|
7
|
+
status: ready
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# wize-sec-recon — Recon (nmap)
|
|
11
|
+
|
|
12
|
+
Runs nmap against the targets in the `scope.md` allowlist and writes `recon.md`. **Default passive** (ping scan only); `--active` enables `-sV` service detection.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
/wize-sec-recon
|
|
18
|
+
/wize-sec-recon --active
|
|
19
|
+
/wize-sec-recon --target=staging.example.internal
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Behavior
|
|
23
|
+
|
|
24
|
+
- Loads `.wize/security/scope.md` first; aborts loudly on invalid scope (HASH_MISMATCH / MISSING_FIELDS).
|
|
25
|
+
- Detects nmap via `command -v`. If absent, writes a `partial_status: incomplete` recon.md with a `degraded_checks` section and exits 0 — the pipeline continues.
|
|
26
|
+
- Calls `assertTargetInScope` for the target. Out-of-scope targets produce an `incomplete` partial and a refusal entry in `.refusals.log`; nmap is **not** invoked.
|
|
27
|
+
- Active vs passive flag set is recorded in the partial's `mode:` frontmatter.
|
|
28
|
+
- The SAST portion of recon (gitleaks, osv/grype) is implemented in a sibling script `scripts/run-sast.js` and is invoked separately or by the orchestrator — see E05.
|
|
29
|
+
|
|
30
|
+
## Output
|
|
31
|
+
|
|
32
|
+
- `.wize/security/recon.md` — partial with `## open_ports` (or `## degraded_checks` on missing tool / out-of-scope target).
|
|
33
|
+
- `.wize/security/.refusals.log` — appended on out-of-scope targets.
|
|
34
|
+
|
|
35
|
+
Exits 0 on success or graceful degradation; 1 when the gate refused the target; 2 on scope error.
|