@rafter-security/cli 0.9.1 → 0.10.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/dist/commands/mcp/server.js +123 -0
- package/dist/commands/sites/create.js +30 -0
- package/dist/commands/sites/errors.js +78 -0
- package/dist/commands/sites/get.js +30 -0
- package/dist/commands/sites/index.js +27 -0
- package/dist/commands/sites/list.js +39 -0
- package/dist/commands/sites/scan.js +54 -0
- package/dist/index.js +3 -0
- package/dist/utils/api.js +4 -0
- package/package.json +1 -1
- package/resources/rafter-security-skill.md +1 -1
|
@@ -10,6 +10,9 @@ import { AuditLogger } from "../../core/audit-logger.js";
|
|
|
10
10
|
import { ConfigManager, redactConfigSecrets, isSecretConfigKey, maskSecretValue } from "../../core/config-manager.js";
|
|
11
11
|
import { listDocs, resolveDocSelector, fetchDoc } from "../../core/docs-loader.js";
|
|
12
12
|
import { writeSuppression } from "../../core/suppression-writer.js";
|
|
13
|
+
import { apiUrl } from "../../utils/api.js";
|
|
14
|
+
import { describeSitesError, resolveMcpApiKey } from "../sites/errors.js";
|
|
15
|
+
import axios from "axios";
|
|
13
16
|
import { createRequire } from "module";
|
|
14
17
|
const _require = createRequire(import.meta.url);
|
|
15
18
|
const { version: CLI_VERSION } = _require("../../../package.json");
|
|
@@ -131,6 +134,56 @@ export function createServer() {
|
|
|
131
134
|
required: ["path"],
|
|
132
135
|
},
|
|
133
136
|
},
|
|
137
|
+
{
|
|
138
|
+
name: "sites_create",
|
|
139
|
+
description: "Register a URL as a Rafter Site for live-application security monitoring (exposed backends, DNS misconfig, SEO, accessibility) and kick off its first scan. Use when asked to start monitoring a domain/site.",
|
|
140
|
+
inputSchema: {
|
|
141
|
+
type: "object",
|
|
142
|
+
properties: {
|
|
143
|
+
url: { type: "string", description: "URL of the site to monitor" },
|
|
144
|
+
},
|
|
145
|
+
required: ["url"],
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "sites_scan",
|
|
150
|
+
description: "Trigger a re-scan of an existing Rafter Site. Identify the site by projectId OR url (exactly one required). Use when asked to re-scan or refresh a site's findings.",
|
|
151
|
+
inputSchema: {
|
|
152
|
+
type: "object",
|
|
153
|
+
properties: {
|
|
154
|
+
projectId: { type: "string", description: "The site's project id (use this or url, not both)" },
|
|
155
|
+
url: { type: "string", description: "The site's URL (use this or projectId, not both)" },
|
|
156
|
+
sections: {
|
|
157
|
+
type: "array",
|
|
158
|
+
items: { type: "string", enum: ["flight", "security", "dns"] },
|
|
159
|
+
description: "Subset of scan sections to run. Omit to run all.",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: "sites_list",
|
|
166
|
+
description: "List Rafter Sites registered for monitoring, paginated. Use when asked 'what sites are being monitored?' or to browse before calling sites_get.",
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: "object",
|
|
169
|
+
properties: {
|
|
170
|
+
limit: { type: "number", description: "Results per page, 1-100 (default: 25)" },
|
|
171
|
+
offset: { type: "number", description: "Pagination offset (default: 0)" },
|
|
172
|
+
include_archived: { type: "boolean", description: "Include archived sites (default: false)" },
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
name: "sites_get",
|
|
178
|
+
description: "Get a Rafter Site's status, latest scan run, and findings summary by its project id. Use after sites_list or sites_create to check a specific site's results.",
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: "object",
|
|
181
|
+
properties: {
|
|
182
|
+
id: { type: "string", description: "The site's project id" },
|
|
183
|
+
},
|
|
184
|
+
required: ["id"],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
134
187
|
],
|
|
135
188
|
}));
|
|
136
189
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
@@ -271,6 +324,76 @@ export function createServer() {
|
|
|
271
324
|
return errorResult(`Failed to write suppression: ${err.message || err}`);
|
|
272
325
|
}
|
|
273
326
|
}
|
|
327
|
+
case "sites_create": {
|
|
328
|
+
const url = args?.url;
|
|
329
|
+
if (!url)
|
|
330
|
+
return errorResult("url is required");
|
|
331
|
+
const key = resolveMcpApiKey();
|
|
332
|
+
if (!key)
|
|
333
|
+
return errorResult("No API key configured. Set RAFTER_API_KEY or run 'rafter agent config set backend.apiKey <key>'.");
|
|
334
|
+
try {
|
|
335
|
+
const { data } = await axios.post(apiUrl("static/sites"), { url }, { headers: { "x-api-key": key } });
|
|
336
|
+
return textResult(data);
|
|
337
|
+
}
|
|
338
|
+
catch (e) {
|
|
339
|
+
return errorResult(describeSitesError(e).message);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
case "sites_scan": {
|
|
343
|
+
const projectId = args?.projectId;
|
|
344
|
+
const url = args?.url;
|
|
345
|
+
if (!projectId && !url)
|
|
346
|
+
return errorResult("Provide exactly one of projectId or url");
|
|
347
|
+
if (projectId && url)
|
|
348
|
+
return errorResult("Provide exactly one of projectId or url, not both");
|
|
349
|
+
const key = resolveMcpApiKey();
|
|
350
|
+
if (!key)
|
|
351
|
+
return errorResult("No API key configured. Set RAFTER_API_KEY or run 'rafter agent config set backend.apiKey <key>'.");
|
|
352
|
+
const body = projectId ? { projectId } : { url };
|
|
353
|
+
if (Array.isArray(args?.sections))
|
|
354
|
+
body.sections = args.sections.map((s) => String(s));
|
|
355
|
+
try {
|
|
356
|
+
const { data } = await axios.post(apiUrl("static/sites/scan"), body, { headers: { "x-api-key": key } });
|
|
357
|
+
return textResult(data);
|
|
358
|
+
}
|
|
359
|
+
catch (e) {
|
|
360
|
+
return errorResult(describeSitesError(e).message);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
case "sites_list": {
|
|
364
|
+
const key = resolveMcpApiKey();
|
|
365
|
+
if (!key)
|
|
366
|
+
return errorResult("No API key configured. Set RAFTER_API_KEY or run 'rafter agent config set backend.apiKey <key>'.");
|
|
367
|
+
const params = {};
|
|
368
|
+
if (args?.limit !== undefined)
|
|
369
|
+
params.limit = String(args.limit);
|
|
370
|
+
if (args?.offset !== undefined)
|
|
371
|
+
params.offset = String(args.offset);
|
|
372
|
+
if (args?.include_archived)
|
|
373
|
+
params.include_archived = "true";
|
|
374
|
+
try {
|
|
375
|
+
const { data } = await axios.get(apiUrl("static/sites"), { params, headers: { "x-api-key": key } });
|
|
376
|
+
return textResult(data);
|
|
377
|
+
}
|
|
378
|
+
catch (e) {
|
|
379
|
+
return errorResult(describeSitesError(e).message);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
case "sites_get": {
|
|
383
|
+
const id = args?.id;
|
|
384
|
+
if (!id)
|
|
385
|
+
return errorResult("id is required");
|
|
386
|
+
const key = resolveMcpApiKey();
|
|
387
|
+
if (!key)
|
|
388
|
+
return errorResult("No API key configured. Set RAFTER_API_KEY or run 'rafter agent config set backend.apiKey <key>'.");
|
|
389
|
+
try {
|
|
390
|
+
const { data } = await axios.get(apiUrl(`static/sites/${encodeURIComponent(id)}`), { headers: { "x-api-key": key } });
|
|
391
|
+
return textResult(data);
|
|
392
|
+
}
|
|
393
|
+
catch (e) {
|
|
394
|
+
return errorResult(describeSitesError(e).message);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
274
397
|
default:
|
|
275
398
|
return errorResult(`Unknown tool: ${name}`);
|
|
276
399
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { apiUrl, resolveKey, writePayload, EXIT_GENERAL_ERROR } from "../../utils/api.js";
|
|
4
|
+
import { describeSitesError, rejectUnsupportedFormat } from "./errors.js";
|
|
5
|
+
/** Register a URL as a Site and kick off its first scan. Returns the process exit code. */
|
|
6
|
+
export async function runSitesCreate(url, opts) {
|
|
7
|
+
if (rejectUnsupportedFormat(opts.format))
|
|
8
|
+
return EXIT_GENERAL_ERROR;
|
|
9
|
+
const key = resolveKey(opts.apiKey);
|
|
10
|
+
try {
|
|
11
|
+
const { data } = await axios.post(apiUrl("static/sites"), { url }, { headers: { "x-api-key": key } });
|
|
12
|
+
return writePayload(data, opts.format, opts.quiet);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
const { message, exitCode } = describeSitesError(e);
|
|
16
|
+
console.error(`Error: ${message}`);
|
|
17
|
+
return exitCode;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function createSitesCreateCommand() {
|
|
21
|
+
return new Command("create")
|
|
22
|
+
.description("Register a site for live monitoring and kick off its first scan")
|
|
23
|
+
.argument("<url>", "URL of the site to monitor")
|
|
24
|
+
.option("-k, --api-key <key>", "API key or RAFTER_API_KEY env var")
|
|
25
|
+
.option("-f, --format <format>", "json | md", "json")
|
|
26
|
+
.option("--quiet", "suppress status messages")
|
|
27
|
+
.action(async (url, opts) => {
|
|
28
|
+
process.exit(await runSitesCreate(url, opts));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { EXIT_GENERAL_ERROR, EXIT_QUOTA_EXHAUSTED, EXIT_INSUFFICIENT_SCOPE, EXIT_SCAN_NOT_FOUND, } from "../../utils/api.js";
|
|
2
|
+
import { ConfigManager } from "../../core/config-manager.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the Rafter API key for a context with no CLI flag (e.g. an MCP tool
|
|
5
|
+
* call). Same precedence as resolveKey() in utils/api.ts (env > stored config)
|
|
6
|
+
* minus the --api-key flag, but returns undefined instead of calling
|
|
7
|
+
* process.exit — killing the whole MCP server over one tool's missing key
|
|
8
|
+
* would take every other tool down with it.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveMcpApiKey() {
|
|
11
|
+
if (process.env.RAFTER_API_KEY)
|
|
12
|
+
return process.env.RAFTER_API_KEY;
|
|
13
|
+
try {
|
|
14
|
+
const stored = new ConfigManager().get("backend.apiKey");
|
|
15
|
+
if (typeof stored === "string" && stored.trim())
|
|
16
|
+
return stored.trim();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// Config unreadable — fall through.
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
/** Extract a human-readable message from a Sites API error response body. */
|
|
24
|
+
function errorBodyMessage(e) {
|
|
25
|
+
const body = e?.response?.data;
|
|
26
|
+
if (typeof body === "string" && body.trim())
|
|
27
|
+
return body;
|
|
28
|
+
if (body && typeof body === "object") {
|
|
29
|
+
if (typeof body.error === "string" && body.error)
|
|
30
|
+
return body.error;
|
|
31
|
+
if (typeof body.message === "string" && body.message)
|
|
32
|
+
return body.message;
|
|
33
|
+
}
|
|
34
|
+
// Deliberately no non-empty fallback here — an unconditional default (e.g.
|
|
35
|
+
// "Unknown error") would make every `msg || "<status-specific default>"`
|
|
36
|
+
// check in describeSitesError() below unreachable, since msg would never
|
|
37
|
+
// be falsy. Let describeSitesError()'s own per-status defaults apply.
|
|
38
|
+
return e?.message || "";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The Sites API never returns a `markdown` field, so `--format md` has nothing
|
|
42
|
+
* to render. Rather than silently falling back to JSON (which looks like
|
|
43
|
+
* success but produces the wrong format), reject up front with a clear error.
|
|
44
|
+
* Returns true (and prints the error) when `fmt` is unsupported.
|
|
45
|
+
*/
|
|
46
|
+
export function rejectUnsupportedFormat(fmt) {
|
|
47
|
+
if (fmt !== "md")
|
|
48
|
+
return false;
|
|
49
|
+
console.error("Error: Sites does not support --format md yet, use --format json");
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Map a Sites API (/api/static/sites*) error to a CLI-friendly message + exit code.
|
|
54
|
+
*
|
|
55
|
+
* Unlike the remote-scan API (see handle403 in utils/api.ts, which infers "quota"
|
|
56
|
+
* from a `scan_mode` field), the Sites API returns 403 for BOTH wrong API-key
|
|
57
|
+
* scope and plan/site limits — the only signal is the free-text `error` string.
|
|
58
|
+
* Never assume 403 == quota here. 404 means "not found or not owned by this
|
|
59
|
+
* account" — the Sites API deliberately does not distinguish the two.
|
|
60
|
+
*/
|
|
61
|
+
export function describeSitesError(e) {
|
|
62
|
+
const status = e?.response?.status;
|
|
63
|
+
const msg = errorBodyMessage(e);
|
|
64
|
+
switch (status) {
|
|
65
|
+
case 400:
|
|
66
|
+
return { message: `Bad request — ${msg}`, exitCode: EXIT_GENERAL_ERROR };
|
|
67
|
+
case 401:
|
|
68
|
+
return { message: `Unauthorized — ${msg || "invalid or missing API key"}`, exitCode: EXIT_GENERAL_ERROR };
|
|
69
|
+
case 403:
|
|
70
|
+
return { message: `Forbidden — ${msg || "access denied"}`, exitCode: EXIT_INSUFFICIENT_SCOPE };
|
|
71
|
+
case 404:
|
|
72
|
+
return { message: `Not found — ${msg || "site not found, or not owned by this account"}`, exitCode: EXIT_SCAN_NOT_FOUND };
|
|
73
|
+
case 429:
|
|
74
|
+
return { message: `Rate limited — ${msg || "too many requests, try again later"}`, exitCode: EXIT_QUOTA_EXHAUSTED };
|
|
75
|
+
default:
|
|
76
|
+
return { message: msg || "Request failed", exitCode: EXIT_GENERAL_ERROR };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { apiUrl, resolveKey, writePayload, EXIT_GENERAL_ERROR } from "../../utils/api.js";
|
|
4
|
+
import { describeSitesError, rejectUnsupportedFormat } from "./errors.js";
|
|
5
|
+
/** Get a site's status, latest run, and findings summary. Returns the process exit code. */
|
|
6
|
+
export async function runSitesGet(id, opts) {
|
|
7
|
+
if (rejectUnsupportedFormat(opts.format))
|
|
8
|
+
return EXIT_GENERAL_ERROR;
|
|
9
|
+
const key = resolveKey(opts.apiKey);
|
|
10
|
+
try {
|
|
11
|
+
const { data } = await axios.get(apiUrl(`static/sites/${encodeURIComponent(id)}`), { headers: { "x-api-key": key } });
|
|
12
|
+
return writePayload(data, opts.format, opts.quiet);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
const { message, exitCode } = describeSitesError(e);
|
|
16
|
+
console.error(`Error: ${message}`);
|
|
17
|
+
return exitCode;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function createSitesGetCommand() {
|
|
21
|
+
return new Command("get")
|
|
22
|
+
.description("Get a site's status, latest run, and findings summary")
|
|
23
|
+
.argument("<id>", "site's project id")
|
|
24
|
+
.option("-k, --api-key <key>", "API key or RAFTER_API_KEY env var")
|
|
25
|
+
.option("-f, --format <format>", "json | md", "json")
|
|
26
|
+
.option("--quiet", "suppress status messages")
|
|
27
|
+
.action(async (id, opts) => {
|
|
28
|
+
process.exit(await runSitesGet(id, opts));
|
|
29
|
+
});
|
|
30
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* rafter sites — live-application security monitoring ("Sites").
|
|
3
|
+
*
|
|
4
|
+
* Subcommands:
|
|
5
|
+
* rafter sites create <url> Register a site, kick off its first scan
|
|
6
|
+
* rafter sites scan <projectId-or-url> Trigger a re-scan of an existing site
|
|
7
|
+
* rafter sites list List registered sites
|
|
8
|
+
* rafter sites get <id> Get a site's status + latest run + findings summary
|
|
9
|
+
*/
|
|
10
|
+
import { Command } from "commander";
|
|
11
|
+
import { createSitesCreateCommand } from "./create.js";
|
|
12
|
+
import { createSitesScanCommand } from "./scan.js";
|
|
13
|
+
import { createSitesListCommand } from "./list.js";
|
|
14
|
+
import { createSitesGetCommand } from "./get.js";
|
|
15
|
+
export function createSitesCommand() {
|
|
16
|
+
const sitesGroup = new Command("sites")
|
|
17
|
+
.description("Manage Rafter Sites — live-application security monitoring");
|
|
18
|
+
sitesGroup.addCommand(createSitesCreateCommand());
|
|
19
|
+
sitesGroup.addCommand(createSitesScanCommand());
|
|
20
|
+
sitesGroup.addCommand(createSitesListCommand());
|
|
21
|
+
sitesGroup.addCommand(createSitesGetCommand());
|
|
22
|
+
// Default action for `rafter sites` with no subcommand — show help.
|
|
23
|
+
sitesGroup.action(() => {
|
|
24
|
+
sitesGroup.help();
|
|
25
|
+
});
|
|
26
|
+
return sitesGroup;
|
|
27
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { apiUrl, resolveKey, writePayload, EXIT_GENERAL_ERROR } from "../../utils/api.js";
|
|
4
|
+
import { describeSitesError, rejectUnsupportedFormat } from "./errors.js";
|
|
5
|
+
/** List registered sites, paginated. Returns the process exit code. */
|
|
6
|
+
export async function runSitesList(opts) {
|
|
7
|
+
if (rejectUnsupportedFormat(opts.format))
|
|
8
|
+
return EXIT_GENERAL_ERROR;
|
|
9
|
+
const key = resolveKey(opts.apiKey);
|
|
10
|
+
const params = {};
|
|
11
|
+
if (opts.limit !== undefined)
|
|
12
|
+
params.limit = String(opts.limit);
|
|
13
|
+
if (opts.offset !== undefined)
|
|
14
|
+
params.offset = String(opts.offset);
|
|
15
|
+
if (opts.includeArchived)
|
|
16
|
+
params.include_archived = "true";
|
|
17
|
+
try {
|
|
18
|
+
const { data } = await axios.get(apiUrl("static/sites"), { params, headers: { "x-api-key": key } });
|
|
19
|
+
return writePayload(data, opts.format, opts.quiet);
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
const { message, exitCode } = describeSitesError(e);
|
|
23
|
+
console.error(`Error: ${message}`);
|
|
24
|
+
return exitCode;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function createSitesListCommand() {
|
|
28
|
+
return new Command("list")
|
|
29
|
+
.description("List registered sites")
|
|
30
|
+
.option("-k, --api-key <key>", "API key or RAFTER_API_KEY env var")
|
|
31
|
+
.option("-f, --format <format>", "json | md", "json")
|
|
32
|
+
.option("--limit <limit>", "results per page, 1-100 (default: 25)")
|
|
33
|
+
.option("--offset <offset>", "pagination offset (default: 0)")
|
|
34
|
+
.option("--include-archived", "include archived sites")
|
|
35
|
+
.option("--quiet", "suppress status messages")
|
|
36
|
+
.action(async (opts) => {
|
|
37
|
+
process.exit(await runSitesList(opts));
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import { apiUrl, resolveKey, writePayload, EXIT_GENERAL_ERROR } from "../../utils/api.js";
|
|
4
|
+
import { describeSitesError, rejectUnsupportedFormat } from "./errors.js";
|
|
5
|
+
const VALID_SECTIONS = new Set(["flight", "security", "dns"]);
|
|
6
|
+
/** True when the argument parses as an absolute URL (has a scheme); false → treat as a project id. */
|
|
7
|
+
function looksLikeUrl(value) {
|
|
8
|
+
try {
|
|
9
|
+
new URL(value);
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Trigger a re-scan of an existing site, identified by project id or URL. Returns the process exit code. */
|
|
17
|
+
export async function runSitesScan(projectIdOrUrl, opts) {
|
|
18
|
+
if (rejectUnsupportedFormat(opts.format))
|
|
19
|
+
return EXIT_GENERAL_ERROR;
|
|
20
|
+
const key = resolveKey(opts.apiKey);
|
|
21
|
+
const body = looksLikeUrl(projectIdOrUrl)
|
|
22
|
+
? { url: projectIdOrUrl }
|
|
23
|
+
: { projectId: projectIdOrUrl };
|
|
24
|
+
if (opts.sections) {
|
|
25
|
+
const sections = String(opts.sections).split(",").map((s) => s.trim()).filter(Boolean);
|
|
26
|
+
const invalid = sections.filter((s) => !VALID_SECTIONS.has(s));
|
|
27
|
+
if (invalid.length > 0) {
|
|
28
|
+
console.error(`Error: invalid --sections value(s): ${invalid.join(", ")} (expected: flight, security, dns)`);
|
|
29
|
+
return 1;
|
|
30
|
+
}
|
|
31
|
+
body.sections = sections;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const { data } = await axios.post(apiUrl("static/sites/scan"), body, { headers: { "x-api-key": key } });
|
|
35
|
+
return writePayload(data, opts.format, opts.quiet);
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
const { message, exitCode } = describeSitesError(e);
|
|
39
|
+
console.error(`Error: ${message}`);
|
|
40
|
+
return exitCode;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function createSitesScanCommand() {
|
|
44
|
+
return new Command("scan")
|
|
45
|
+
.description("Trigger a re-scan of an existing site")
|
|
46
|
+
.argument("<projectIdOrUrl>", "site's project id, or its URL")
|
|
47
|
+
.option("-k, --api-key <key>", "API key or RAFTER_API_KEY env var")
|
|
48
|
+
.option("-f, --format <format>", "json | md", "json")
|
|
49
|
+
.option("--sections <sections>", "comma-separated subset of flight,security,dns (default: all)")
|
|
50
|
+
.option("--quiet", "suppress status messages")
|
|
51
|
+
.action(async (projectIdOrUrl, opts) => {
|
|
52
|
+
process.exit(await runSitesScan(projectIdOrUrl, opts));
|
|
53
|
+
});
|
|
54
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ import { createNotifyCommand } from "./commands/notify.js";
|
|
|
18
18
|
import { createCompletionCommand } from "./commands/completion.js";
|
|
19
19
|
import { createIssuesCommand } from "./commands/issues/index.js";
|
|
20
20
|
import { createReportCommand } from "./commands/report.js";
|
|
21
|
+
import { createSitesCommand } from "./commands/sites/index.js";
|
|
21
22
|
import { checkForUpdate } from "./utils/update-checker.js";
|
|
22
23
|
import { setAgentMode } from "./utils/formatter.js";
|
|
23
24
|
import { createRequire } from "module";
|
|
@@ -39,6 +40,8 @@ const program = new Command()
|
|
|
39
40
|
program.addCommand(createRunCommand());
|
|
40
41
|
program.addCommand(createGetCommand());
|
|
41
42
|
program.addCommand(createUsageCommand());
|
|
43
|
+
// Sites — live-application security monitoring
|
|
44
|
+
program.addCommand(createSitesCommand());
|
|
42
45
|
// Scan command group (default: remote scan; subcommands: local, remote)
|
|
43
46
|
program.addCommand(createScanGroupCommand());
|
|
44
47
|
// Secrets — top-level alias for local secret scanning (explicit-scope name)
|
package/dist/utils/api.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ConfigManager } from "../core/config-manager.js";
|
|
2
2
|
export const API = "https://rafter.so/api/";
|
|
3
|
+
/** Join API with a path segment without producing a double slash, regardless of leading/trailing slashes on either side. */
|
|
4
|
+
export function apiUrl(path) {
|
|
5
|
+
return `${API.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
6
|
+
}
|
|
3
7
|
// Exit codes
|
|
4
8
|
export const EXIT_SUCCESS = 0;
|
|
5
9
|
export const EXIT_GENERAL_ERROR = 1;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: rafter-security
|
|
3
3
|
description: Security toolkit for AI workflows. Use when scanning code or repos for vulnerabilities, auditing third-party skills/MCPs/agent configs before installing, evaluating shell commands before running them, or generating secure design questions for new features. Provides `rafter run` (remote SAST + SCA, needs RAFTER_API_KEY), `rafter secrets` (offline secrets-only), `rafter agent exec --dry-run` (command-risk classification), and `rafter skill review`.
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
homepage: https://rafter.so
|
|
6
6
|
metadata:
|
|
7
7
|
openclaw:
|