@rafter-security/cli 0.11.6 → 0.12.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/agent/auto-update.js +171 -0
- package/dist/commands/agent/components.js +50 -176
- package/dist/commands/agent/enable.js +11 -1
- package/dist/commands/agent/index.js +2 -0
- package/dist/commands/agent/init.js +654 -764
- package/dist/commands/agent/install-files.js +689 -0
- package/dist/commands/agent/instruction-block.js +82 -40
- package/dist/commands/agent/scan.js +70 -21
- package/dist/commands/agent/status.js +11 -0
- package/dist/commands/agent/update.js +179 -0
- package/dist/commands/agent/verify.js +11 -0
- package/dist/commands/backend/get.js +5 -10
- package/dist/commands/backend/run.js +10 -20
- package/dist/commands/backend/scan-status.js +16 -3
- package/dist/commands/backend/usage.js +3 -6
- package/dist/commands/brief.js +6 -12
- package/dist/commands/counters.js +146 -0
- package/dist/commands/gates.js +36 -0
- package/dist/commands/hook/pretool.js +22 -9
- package/dist/commands/mcp/server.js +1 -1
- package/dist/commands/skill/registry.js +48 -0
- package/dist/core/risk-rules.js +240 -34
- package/dist/core/usage-counters.js +439 -0
- package/dist/index.js +36 -0
- package/dist/scanners/gate-scanner.js +721 -0
- package/dist/scanners/regex-scanner.js +26 -25
- package/dist/utils/skill-manager.js +8 -338
- package/package.json +1 -1
- package/resources/continue-rules/rafter-code-review.md +6 -6
- package/resources/continue-rules/rafter-secure-design.md +3 -4
- package/resources/continue-rules/rafter-skill-review.md +4 -4
- package/resources/continue-rules/rafter.md +2 -2
- package/resources/cursor-rules/rafter-code-review.mdc +6 -6
- package/resources/cursor-rules/rafter-secure-design.mdc +3 -4
- package/resources/cursor-rules/rafter-skill-review.mdc +4 -4
- package/resources/cursor-rules/rafter.mdc +2 -2
- package/resources/rafter-security-skill.md +1 -1
- package/resources/shipped-hashes.json +332 -0
- package/resources/skills/rafter/SKILL.md +7 -7
- package/resources/skills/rafter/docs/cli-reference.md +37 -10
- package/resources/skills/rafter/docs/finding-triage.md +1 -1
- package/resources/skills/rafter/docs/guardrails.md +2 -2
- package/resources/skills/rafter/docs/shift-left.md +4 -4
- package/resources/skills/rafter-code-review/SKILL.md +43 -14
- package/resources/skills/rafter-code-review/docs/llm.md +2 -2
- package/resources/skills/rafter-code-review/docs/security-gates.md +53 -0
- package/resources/skills/rafter-secure-design/SKILL.md +1 -0
- package/resources/skills/rafter-skill-review/SKILL.md +1 -0
- package/resources/windsurf-rules/rafter-code-review.md +6 -6
- package/resources/windsurf-rules/rafter-secure-design.md +3 -4
- package/resources/windsurf-rules/rafter-skill-review.md +4 -4
- package/resources/windsurf-rules/rafter.md +2 -2
|
@@ -12,6 +12,30 @@ function readErrorReason(e) {
|
|
|
12
12
|
return String(e.code);
|
|
13
13
|
return e instanceof Error ? e.message : "could not read file";
|
|
14
14
|
}
|
|
15
|
+
// Keep in step with DEFAULT_EXCLUDE in python/rafter_cli/scanners/regex_scanner.py.
|
|
16
|
+
export const DEFAULT_EXCLUDE = [
|
|
17
|
+
"node_modules",
|
|
18
|
+
".git",
|
|
19
|
+
"dist",
|
|
20
|
+
"build",
|
|
21
|
+
".next",
|
|
22
|
+
"coverage",
|
|
23
|
+
".vscode",
|
|
24
|
+
".idea",
|
|
25
|
+
// Vendored / virtual-env / generated dirs that cause false positives
|
|
26
|
+
"vendor",
|
|
27
|
+
".venv",
|
|
28
|
+
"venv",
|
|
29
|
+
"__pycache__",
|
|
30
|
+
".tox",
|
|
31
|
+
".mypy_cache",
|
|
32
|
+
".pytest_cache",
|
|
33
|
+
".ruff_cache",
|
|
34
|
+
"results",
|
|
35
|
+
".terraform",
|
|
36
|
+
"bower_components",
|
|
37
|
+
".trigger", // Trigger.dev build output (bundled JS + source maps)
|
|
38
|
+
];
|
|
15
39
|
export class RegexScanner {
|
|
16
40
|
constructor(customPatterns) {
|
|
17
41
|
const patterns = [...DEFAULT_SECRET_PATTERNS, ...loadCustomPatterns()];
|
|
@@ -61,30 +85,7 @@ export class RegexScanner {
|
|
|
61
85
|
* Scan a directory recursively
|
|
62
86
|
*/
|
|
63
87
|
scanDirectory(dirPath, options) {
|
|
64
|
-
|
|
65
|
-
const exclude = options?.exclude || [
|
|
66
|
-
"node_modules",
|
|
67
|
-
".git",
|
|
68
|
-
"dist",
|
|
69
|
-
"build",
|
|
70
|
-
".next",
|
|
71
|
-
"coverage",
|
|
72
|
-
".vscode",
|
|
73
|
-
".idea",
|
|
74
|
-
// Vendored / virtual-env / generated dirs that cause false positives
|
|
75
|
-
"vendor",
|
|
76
|
-
".venv",
|
|
77
|
-
"venv",
|
|
78
|
-
"__pycache__",
|
|
79
|
-
".tox",
|
|
80
|
-
".mypy_cache",
|
|
81
|
-
".pytest_cache",
|
|
82
|
-
".ruff_cache",
|
|
83
|
-
"results",
|
|
84
|
-
".terraform",
|
|
85
|
-
"bower_components",
|
|
86
|
-
".trigger", // Trigger.dev build output (bundled JS + source maps)
|
|
87
|
-
];
|
|
88
|
+
const exclude = options?.exclude || [...DEFAULT_EXCLUDE];
|
|
88
89
|
// Merge policy excludePaths into the exclude list
|
|
89
90
|
if (options?.excludePaths) {
|
|
90
91
|
for (const ep of options.excludePaths) {
|
|
@@ -193,7 +194,7 @@ export class RegexScanner {
|
|
|
193
194
|
*
|
|
194
195
|
* Batched: all candidate paths are piped through one subprocess.
|
|
195
196
|
*/
|
|
196
|
-
function filterGitIgnored(files, scanRoot) {
|
|
197
|
+
export function filterGitIgnored(files, scanRoot) {
|
|
197
198
|
if (files.length === 0)
|
|
198
199
|
return files;
|
|
199
200
|
// Locate the git work tree that owns scanRoot. Bail out (no filter) if
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import os from "os";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { openclawLegacySkillPath, openclawSkillPath } from "../commands/agent/install-files.js";
|
|
5
|
+
/**
|
|
6
|
+
* Read-only view of the OpenClaw skill install, for `agent verify`, `agent
|
|
7
|
+
* status` and `agent audit-skill`. Installing and updating go through
|
|
8
|
+
* install-files.ts like every other platform.
|
|
9
|
+
*/
|
|
9
10
|
export class SkillManager {
|
|
10
|
-
constructor(options = {}) {
|
|
11
|
-
this.configManager = new ConfigManager();
|
|
12
|
-
this.log = options.log ?? ((message) => console.log(message));
|
|
13
|
-
}
|
|
14
11
|
/**
|
|
15
12
|
* Path to the OpenClaw root directory.
|
|
16
13
|
*
|
|
@@ -44,32 +41,13 @@ export class SkillManager {
|
|
|
44
41
|
* Path to the Rafter Security SKILL.md file.
|
|
45
42
|
*/
|
|
46
43
|
getRafterSkillPath() {
|
|
47
|
-
return
|
|
44
|
+
return openclawSkillPath(os.homedir());
|
|
48
45
|
}
|
|
49
46
|
/**
|
|
50
47
|
* Legacy install path used by rafter ≤ 0.7.7. Removed on reinstall.
|
|
51
48
|
*/
|
|
52
49
|
getLegacyRafterSkillPath() {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Get path to old skill-auditor (for migration)
|
|
57
|
-
*/
|
|
58
|
-
getOldSkillAuditorPath() {
|
|
59
|
-
return path.join(this.getOpenClawRoot(), "skills", "rafter-skill-auditor.md");
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get path to Rafter Security skill source in CLI resources
|
|
63
|
-
*/
|
|
64
|
-
getRafterSkillSourcePath() {
|
|
65
|
-
// Go up from src/utils/ to node/ then into resources/
|
|
66
|
-
return path.join(__dirname, "..", "..", "resources", "rafter-security-skill.md");
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Get path to backups directory
|
|
70
|
-
*/
|
|
71
|
-
getBackupsDir() {
|
|
72
|
-
return path.join(this.getOpenClawSkillsDir(), ".backups");
|
|
50
|
+
return openclawLegacySkillPath(os.homedir());
|
|
73
51
|
}
|
|
74
52
|
/**
|
|
75
53
|
* Check if OpenClaw is installed.
|
|
@@ -94,12 +72,6 @@ export class SkillManager {
|
|
|
94
72
|
isRafterSkillInstalled() {
|
|
95
73
|
return fs.existsSync(this.getRafterSkillPath());
|
|
96
74
|
}
|
|
97
|
-
/**
|
|
98
|
-
* Check if old skill-auditor is installed (for migration)
|
|
99
|
-
*/
|
|
100
|
-
hasOldSkillAuditor() {
|
|
101
|
-
return fs.existsSync(this.getOldSkillAuditorPath());
|
|
102
|
-
}
|
|
103
75
|
/**
|
|
104
76
|
* Parse frontmatter metadata from skill file
|
|
105
77
|
*/
|
|
@@ -137,306 +109,4 @@ export class SkillManager {
|
|
|
137
109
|
return null;
|
|
138
110
|
}
|
|
139
111
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Get version of Rafter Security skill in CLI resources
|
|
142
|
-
*/
|
|
143
|
-
getSourceVersion() {
|
|
144
|
-
try {
|
|
145
|
-
const content = fs.readFileSync(this.getRafterSkillSourcePath(), "utf-8");
|
|
146
|
-
const metadata = this.parseSkillMetadata(content);
|
|
147
|
-
return metadata?.version || null;
|
|
148
|
-
}
|
|
149
|
-
catch (e) {
|
|
150
|
-
return null;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Calculate hash of file content (excluding frontmatter for version)
|
|
155
|
-
*/
|
|
156
|
-
calculateContentHash(content) {
|
|
157
|
-
// Remove frontmatter for hash calculation
|
|
158
|
-
const withoutFrontmatter = content.replace(/^---\n[\s\S]*?\n---\n/, '');
|
|
159
|
-
return createHash('sha256').update(withoutFrontmatter).digest('hex').substring(0, 8);
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Check if installed skill has been modified by user
|
|
163
|
-
*/
|
|
164
|
-
isSkillModified() {
|
|
165
|
-
if (!this.isRafterSkillInstalled()) {
|
|
166
|
-
return false;
|
|
167
|
-
}
|
|
168
|
-
try {
|
|
169
|
-
const installedContent = fs.readFileSync(this.getRafterSkillPath(), "utf-8");
|
|
170
|
-
const sourceContent = fs.readFileSync(this.getRafterSkillSourcePath(), "utf-8");
|
|
171
|
-
const installedHash = this.calculateContentHash(installedContent);
|
|
172
|
-
const sourceHash = this.calculateContentHash(sourceContent);
|
|
173
|
-
return installedHash !== sourceHash;
|
|
174
|
-
}
|
|
175
|
-
catch (e) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Remove the rafter ≤ 0.7.7 install path
|
|
181
|
-
* (`~/.openclaw/skills/rafter-security.md`). OpenClaw never read that
|
|
182
|
-
* path; we strip it on reinstall so the user is left with just the
|
|
183
|
-
* canonical ClawHub-shaped skill (rf-zgwj migration).
|
|
184
|
-
*/
|
|
185
|
-
removeLegacyRafterSkill() {
|
|
186
|
-
const legacy = this.getLegacyRafterSkillPath();
|
|
187
|
-
if (!fs.existsSync(legacy))
|
|
188
|
-
return;
|
|
189
|
-
try {
|
|
190
|
-
fs.unlinkSync(legacy);
|
|
191
|
-
this.log(`✓ Removed legacy ${legacy} (superseded by ClawHub-shaped skill at ${this.getRafterSkillPath()})`);
|
|
192
|
-
}
|
|
193
|
-
catch {
|
|
194
|
-
/* best-effort */
|
|
195
|
-
}
|
|
196
|
-
// Clean up empty parent if we just emptied it. Don't touch dirs that
|
|
197
|
-
// contain other user content.
|
|
198
|
-
const legacyDir = path.dirname(legacy);
|
|
199
|
-
try {
|
|
200
|
-
const entries = fs.readdirSync(legacyDir);
|
|
201
|
-
if (entries.length === 0) {
|
|
202
|
-
fs.rmdirSync(legacyDir);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
/* best-effort */
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Migrate from old separate skill-auditor to combined Rafter Security skill
|
|
211
|
-
*/
|
|
212
|
-
async migrateOldSkill() {
|
|
213
|
-
if (this.hasOldSkillAuditor()) {
|
|
214
|
-
try {
|
|
215
|
-
// Remove old skill-auditor file
|
|
216
|
-
fs.unlinkSync(this.getOldSkillAuditorPath());
|
|
217
|
-
this.log("✓ Migrated from separate skill-auditor to combined Rafter Security skill");
|
|
218
|
-
}
|
|
219
|
-
catch (e) {
|
|
220
|
-
// Ignore migration errors
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Install Rafter Security skill to OpenClaw (verbose result).
|
|
226
|
-
*
|
|
227
|
-
* rf-zgwj: writes to the canonical ClawHub workspace location
|
|
228
|
-
* (`~/.openclaw/workspace/skills/rafter-security/SKILL.md`) so OpenClaw
|
|
229
|
-
* auto-discovers it at session start. Earlier versions wrote to
|
|
230
|
-
* `~/.openclaw/skills/rafter-security.md` — that file is removed on
|
|
231
|
-
* reinstall as a migration step.
|
|
232
|
-
*/
|
|
233
|
-
async installRafterSkillVerbose(force = false) {
|
|
234
|
-
const skillPath = this.getRafterSkillPath();
|
|
235
|
-
const sourcePath = this.getRafterSkillSourcePath();
|
|
236
|
-
if (!this.isOpenClawInstalled()) {
|
|
237
|
-
return { ok: false, sourcePath, destPath: skillPath, error: `OpenClaw not found: ${this.getOpenClawRoot()}` };
|
|
238
|
-
}
|
|
239
|
-
// Check if already installed and not forcing
|
|
240
|
-
if (!force && this.isRafterSkillInstalled()) {
|
|
241
|
-
// Still strip the legacy file on reinstall — a previous rafter
|
|
242
|
-
// version may have left it behind alongside a hand-installed skill.
|
|
243
|
-
this.removeLegacyRafterSkill();
|
|
244
|
-
return { ok: true, sourcePath, destPath: skillPath };
|
|
245
|
-
}
|
|
246
|
-
try {
|
|
247
|
-
// Ensure the skill dir (NOT just the parent skills dir) exists; the
|
|
248
|
-
// ClawHub format is one directory per skill.
|
|
249
|
-
const skillDir = this.getRafterSkillDir();
|
|
250
|
-
if (!fs.existsSync(skillDir)) {
|
|
251
|
-
fs.mkdirSync(skillDir, { recursive: true });
|
|
252
|
-
}
|
|
253
|
-
// Verify source exists
|
|
254
|
-
if (!fs.existsSync(sourcePath)) {
|
|
255
|
-
return { ok: false, sourcePath, destPath: skillPath, error: `Source skill file not found: ${sourcePath}` };
|
|
256
|
-
}
|
|
257
|
-
// Copy skill file
|
|
258
|
-
const sourceContent = fs.readFileSync(sourcePath, "utf-8");
|
|
259
|
-
fs.writeFileSync(skillPath, sourceContent, "utf-8");
|
|
260
|
-
// Migration: strip the rafter ≤ 0.7.7 install path (rf-zgwj).
|
|
261
|
-
this.removeLegacyRafterSkill();
|
|
262
|
-
// Update config
|
|
263
|
-
const version = this.getSourceVersion();
|
|
264
|
-
if (version) {
|
|
265
|
-
this.configManager.set("agent.skills.installedVersion", version);
|
|
266
|
-
this.configManager.set("agent.skills.lastChecked", new Date().toISOString());
|
|
267
|
-
}
|
|
268
|
-
// Migrate old skill-auditor if present
|
|
269
|
-
await this.migrateOldSkill();
|
|
270
|
-
return { ok: true, sourcePath, destPath: skillPath };
|
|
271
|
-
}
|
|
272
|
-
catch (e) {
|
|
273
|
-
return { ok: false, sourcePath, destPath: skillPath, error: String(e) };
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
/**
|
|
277
|
-
* Install Rafter Security skill to OpenClaw
|
|
278
|
-
*/
|
|
279
|
-
async installRafterSkill(force = false) {
|
|
280
|
-
const result = await this.installRafterSkillVerbose(force);
|
|
281
|
-
if (!result.ok && result.error) {
|
|
282
|
-
console.error(`Failed to install Rafter Security skill: ${result.error}`);
|
|
283
|
-
}
|
|
284
|
-
return result.ok;
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Backup current skill before updating
|
|
288
|
-
*/
|
|
289
|
-
backupSkill() {
|
|
290
|
-
if (!this.isRafterSkillInstalled()) {
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
try {
|
|
294
|
-
const backupsDir = this.getBackupsDir();
|
|
295
|
-
if (!fs.existsSync(backupsDir)) {
|
|
296
|
-
fs.mkdirSync(backupsDir, { recursive: true });
|
|
297
|
-
}
|
|
298
|
-
const version = this.getInstalledVersion() || "unknown";
|
|
299
|
-
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
300
|
-
const backupPath = path.join(backupsDir, `rafter-security.md.v${version}.${timestamp}`);
|
|
301
|
-
const content = fs.readFileSync(this.getRafterSkillPath(), "utf-8");
|
|
302
|
-
fs.writeFileSync(backupPath, content, "utf-8");
|
|
303
|
-
// Keep only last 3 backups
|
|
304
|
-
this.cleanupOldBackups(3);
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
catch (e) {
|
|
308
|
-
console.error(`Failed to backup skill: ${e}`);
|
|
309
|
-
return false;
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Remove old backups, keeping only the most recent N
|
|
314
|
-
*/
|
|
315
|
-
cleanupOldBackups(keep) {
|
|
316
|
-
const backupsDir = this.getBackupsDir();
|
|
317
|
-
if (!fs.existsSync(backupsDir)) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
try {
|
|
321
|
-
const files = fs.readdirSync(backupsDir)
|
|
322
|
-
.filter(f => f.startsWith("rafter-security.md.v") || f.startsWith("rafter-skill-auditor.md.v"))
|
|
323
|
-
.map(f => ({
|
|
324
|
-
name: f,
|
|
325
|
-
path: path.join(backupsDir, f),
|
|
326
|
-
mtime: fs.statSync(path.join(backupsDir, f)).mtime
|
|
327
|
-
}))
|
|
328
|
-
.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
329
|
-
// Remove old backups
|
|
330
|
-
files.slice(keep).forEach(file => {
|
|
331
|
-
fs.unlinkSync(file.path);
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
catch (e) {
|
|
335
|
-
// Ignore cleanup errors
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Update Rafter Security skill to latest version
|
|
340
|
-
*/
|
|
341
|
-
async updateRafterSkill(options = {}) {
|
|
342
|
-
if (!this.isOpenClawInstalled()) {
|
|
343
|
-
return { updated: false, message: "OpenClaw not installed" };
|
|
344
|
-
}
|
|
345
|
-
if (!this.isRafterSkillInstalled()) {
|
|
346
|
-
// Install if not present
|
|
347
|
-
const installed = await this.installRafterSkill();
|
|
348
|
-
return {
|
|
349
|
-
updated: installed,
|
|
350
|
-
message: installed ? "Rafter Security skill installed" : "Failed to install Rafter Security skill"
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
const installedVersion = this.getInstalledVersion();
|
|
354
|
-
const sourceVersion = this.getSourceVersion();
|
|
355
|
-
if (!sourceVersion) {
|
|
356
|
-
return { updated: false, message: "Could not determine source version" };
|
|
357
|
-
}
|
|
358
|
-
// Check if update needed
|
|
359
|
-
if (!options.force && installedVersion === sourceVersion) {
|
|
360
|
-
return { updated: false, message: "Rafter Security skill is up to date" };
|
|
361
|
-
}
|
|
362
|
-
// Check if modified
|
|
363
|
-
if (!options.force && this.isSkillModified()) {
|
|
364
|
-
return {
|
|
365
|
-
updated: false,
|
|
366
|
-
message: "Skill has been modified. Use --force to overwrite."
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
// Backup if requested
|
|
370
|
-
const config = this.configManager.load();
|
|
371
|
-
if (options.backup !== false && config.agent?.skills.backupBeforeUpdate) {
|
|
372
|
-
this.backupSkill();
|
|
373
|
-
}
|
|
374
|
-
// Install new version
|
|
375
|
-
const installed = await this.installRafterSkill(true);
|
|
376
|
-
if (installed) {
|
|
377
|
-
return {
|
|
378
|
-
updated: true,
|
|
379
|
-
message: `Updated Rafter Security skill: ${installedVersion || 'unknown'} → ${sourceVersion}`
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
return {
|
|
384
|
-
updated: false,
|
|
385
|
-
message: "Failed to update Rafter Security skill"
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Remove Rafter Security skill
|
|
391
|
-
*/
|
|
392
|
-
removeRafterSkill() {
|
|
393
|
-
if (!this.isRafterSkillInstalled()) {
|
|
394
|
-
return false;
|
|
395
|
-
}
|
|
396
|
-
try {
|
|
397
|
-
fs.unlinkSync(this.getRafterSkillPath());
|
|
398
|
-
// Clear config
|
|
399
|
-
this.configManager.set("agent.skills.installedVersion", undefined);
|
|
400
|
-
return true;
|
|
401
|
-
}
|
|
402
|
-
catch (e) {
|
|
403
|
-
console.error(`Failed to remove Rafter Security skill: ${e}`);
|
|
404
|
-
return false;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
/**
|
|
408
|
-
* Check if skill update is available
|
|
409
|
-
*/
|
|
410
|
-
isUpdateAvailable() {
|
|
411
|
-
if (!this.isRafterSkillInstalled()) {
|
|
412
|
-
return false;
|
|
413
|
-
}
|
|
414
|
-
const installedVersion = this.getInstalledVersion();
|
|
415
|
-
const sourceVersion = this.getSourceVersion();
|
|
416
|
-
if (!installedVersion || !sourceVersion) {
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
return installedVersion !== sourceVersion;
|
|
420
|
-
}
|
|
421
|
-
/**
|
|
422
|
-
* Check for updates and auto-update if configured
|
|
423
|
-
*/
|
|
424
|
-
async checkAndUpdate(silent = true) {
|
|
425
|
-
const config = this.configManager.load();
|
|
426
|
-
// Skip if auto-update disabled
|
|
427
|
-
if (!config.agent?.skills.autoUpdate) {
|
|
428
|
-
return;
|
|
429
|
-
}
|
|
430
|
-
// Check if update available
|
|
431
|
-
if (!this.isUpdateAvailable()) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
// Update silently
|
|
435
|
-
const result = await this.updateRafterSkill({ backup: true });
|
|
436
|
-
if (!silent && result.updated) {
|
|
437
|
-
console.log(`✓ ${result.message}`);
|
|
438
|
-
}
|
|
439
|
-
// Update last checked timestamp
|
|
440
|
-
this.configManager.set("agent.skills.lastChecked", new Date().toISOString());
|
|
441
|
-
}
|
|
442
112
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: rafter-code-review
|
|
3
|
-
description: "
|
|
3
|
+
description: "Use for a security review of code: auditing a codebase, finding vulnerabilities in a module, or reviewing a diff before calling work on auth, input, SQL, shell or crypto done. Walks a security-gate checklist (allowlists, auth checks, token and crypto validity, path containment, escaping, limits) and OWASP/CWE questions, with file:line evidence. NOT for secret scanning alone (rafter secrets)."
|
|
4
4
|
alwaysApply: false
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# rafter-code-review — structured pre-merge review
|
|
8
8
|
|
|
9
|
-
Pointer rule
|
|
9
|
+
Pointer rule for the `rafter-code-review` skill. Use it BEFORE declaring done on any diff touching the surface listed above. (The full skill — with a sub-doc per category — installs as its own skill directory only for Claude Code (`.claude/skills/rafter-code-review/`) and for Codex and Gemini (`.agents/skills/rafter-code-review/`); this rule is the condensed equivalent here.)
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- Match the code to a category and walk its questions by hand: web app (OWASP Top 10), REST/GraphQL/gRPC API (OWASP API Top 10), LLM-integrated feature (OWASP LLM Top 10), CLI/library/IaC (MITRE CWE Top 25).
|
|
12
|
+
- Judge the code in front of you, not your memory of the project: "matches upstream" is not a verdict. Give each gate a verdict; the review ends when the list does, not at the first finding.
|
|
13
|
+
- If the branch is pushed and `RAFTER_API_KEY` is set, `rafter run` adds the backend scan. It cannot see unpushed changes and does not replace this review.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Security-relevant code is not done until you have reviewed it yourself.
|
|
@@ -6,10 +6,9 @@ alwaysApply: false
|
|
|
6
6
|
|
|
7
7
|
# rafter-secure-design — shift-left design review
|
|
8
8
|
|
|
9
|
-
Pointer rule
|
|
9
|
+
Pointer rule for the `rafter-secure-design` skill. Use it BEFORE writing code for any feature on the surface listed above. (The full skill — with a sub-doc per category — installs as its own skill directory only for Claude Code (`.claude/skills/rafter-secure-design/`) and for Codex and Gemini (`.agents/skills/rafter-secure-design/`); this rule is the condensed equivalent here.)
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- Each sub-doc is a set of questions a security engineer would ask at kickoff — answer them inline in the design or PR description.
|
|
11
|
+
- Reason through the matching category by hand: auth, data storage, API design, ingestion, deployment, dependencies. Each is a set of questions a security engineer would ask at kickoff — answer them inline in the design or PR description.
|
|
13
12
|
- Pair with `rafter-code-review` (mid-lifecycle) and `rafter run` (detection) once code exists.
|
|
14
13
|
|
|
15
|
-
Skipping this
|
|
14
|
+
Skipping this on the listed surfaces is how auth bypass, token leakage, and delete-the-wrong-record bugs ship. Do not proceed to implementation until it has run.
|
|
@@ -6,10 +6,10 @@ alwaysApply: false
|
|
|
6
6
|
|
|
7
7
|
# rafter-skill-review — vet before you install
|
|
8
8
|
|
|
9
|
-
Pointer rule
|
|
9
|
+
Pointer rule for the `rafter-skill-review` skill. Use it BEFORE installing or forwarding any third-party agent asset. (The full skill — with sub-docs on provenance, malware, prompt injection, data practices, and telemetry — installs as its own skill directory only for Claude Code (`.claude/skills/rafter-skill-review/`) and for Codex and Gemini (`.agents/skills/rafter-skill-review/`); this rule is the condensed equivalent here.)
|
|
10
10
|
|
|
11
|
-
- Run `rafter skill review <path-or-url>` against the SKILL.md / MCP manifest / Cursor rule / agent config.
|
|
12
|
-
-
|
|
13
|
-
- Do NOT install, load, recommend, or forward the asset until
|
|
11
|
+
- Run `rafter skill review <path-or-url>` against the SKILL.md / MCP manifest / Cursor rule / agent config — its report already covers most of the deeper checks (provenance, obfuscation, secrets, prompt-injection patterns).
|
|
12
|
+
- Weigh telemetry, allowed-tools scope, and network egress by hand on top of that report.
|
|
13
|
+
- Do NOT install, load, recommend, or forward the asset until you have a verdict.
|
|
14
14
|
|
|
15
15
|
Installing a skill grants Read/Bash/network under your identity — `curl | sh` in a different costume. Bypassing this turns the agent into a delivery vector.
|
|
@@ -6,11 +6,11 @@ alwaysApply: false
|
|
|
6
6
|
|
|
7
7
|
# rafter — security toolkit router
|
|
8
8
|
|
|
9
|
-
Pointer rule
|
|
9
|
+
Pointer rule for the `rafter` skill. Full guidance: run `rafter brief scanning` (or `rafter brief commands` for just the command list).
|
|
10
10
|
|
|
11
11
|
- Run `rafter run` for the default tier — remote SAST + SCA + secrets. Needs `RAFTER_API_KEY`.
|
|
12
12
|
- Run `rafter run --mode plus` for agentic deep-dive on suspicious patterns.
|
|
13
13
|
- Run `rafter secrets <path>` for offline secrets-only (NOT a code security scan).
|
|
14
14
|
- Run `rafter agent exec --dry-run -- <cmd>` to classify a shell command's risk before running it.
|
|
15
15
|
|
|
16
|
-
If unsure which tier to pick,
|
|
16
|
+
If unsure which tier to pick, run `rafter brief scanning` and follow the routing table.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: "
|
|
2
|
+
description: "Use for a security review of code: auditing a codebase, finding vulnerabilities in a module, or reviewing a diff before calling work on auth, input, SQL, shell or crypto done. Walks a security-gate checklist (allowlists, auth checks, token and crypto validity, path containment, escaping, limits) and OWASP/CWE questions, with file:line evidence. NOT for secret scanning alone (rafter secrets)."
|
|
3
3
|
alwaysApply: false
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# rafter-code-review — structured pre-merge review
|
|
7
7
|
|
|
8
|
-
Pointer rule
|
|
8
|
+
Pointer rule for the `rafter-code-review` skill. Use it BEFORE declaring done on any diff touching the surface listed above. (The full skill — with a sub-doc per category — installs as its own skill directory only for Claude Code (`.claude/skills/rafter-code-review/`) and for Codex and Gemini (`.agents/skills/rafter-code-review/`); this rule is the condensed equivalent here.)
|
|
9
9
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
10
|
+
- Match the code to a category and walk its questions by hand: web app (OWASP Top 10), REST/GraphQL/gRPC API (OWASP API Top 10), LLM-integrated feature (OWASP LLM Top 10), CLI/library/IaC (MITRE CWE Top 25).
|
|
11
|
+
- Judge the code in front of you, not your memory of the project: "matches upstream" is not a verdict. Give each gate a verdict; the review ends when the list does, not at the first finding.
|
|
12
|
+
- If the branch is pushed and `RAFTER_API_KEY` is set, `rafter run` adds the backend scan. It cannot see unpushed changes and does not replace this review.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
Security-relevant code is not done until you have reviewed it yourself.
|
|
@@ -5,10 +5,9 @@ alwaysApply: false
|
|
|
5
5
|
|
|
6
6
|
# rafter-secure-design — shift-left design review
|
|
7
7
|
|
|
8
|
-
Pointer rule
|
|
8
|
+
Pointer rule for the `rafter-secure-design` skill. Use it BEFORE writing code for any feature on the surface listed above. (The full skill — with a sub-doc per category — installs as its own skill directory only for Claude Code (`.claude/skills/rafter-secure-design/`) and for Codex and Gemini (`.agents/skills/rafter-secure-design/`); this rule is the condensed equivalent here.)
|
|
9
9
|
|
|
10
|
-
-
|
|
11
|
-
- Each sub-doc is a set of questions a security engineer would ask at kickoff — answer them inline in the design or PR description.
|
|
10
|
+
- Reason through the matching category by hand: auth, data storage, API design, ingestion, deployment, dependencies. Each is a set of questions a security engineer would ask at kickoff — answer them inline in the design or PR description.
|
|
12
11
|
- Pair with `rafter-code-review` (mid-lifecycle) and `rafter run` (detection) once code exists.
|
|
13
12
|
|
|
14
|
-
Skipping this
|
|
13
|
+
Skipping this on the listed surfaces is how auth bypass, token leakage, and delete-the-wrong-record bugs ship. Do not proceed to implementation until it has run.
|
|
@@ -5,10 +5,10 @@ alwaysApply: false
|
|
|
5
5
|
|
|
6
6
|
# rafter-skill-review — vet before you install
|
|
7
7
|
|
|
8
|
-
Pointer rule
|
|
8
|
+
Pointer rule for the `rafter-skill-review` skill. Use it BEFORE installing or forwarding any third-party agent asset. (The full skill — with sub-docs on provenance, malware, prompt injection, data practices, and telemetry — installs as its own skill directory only for Claude Code (`.claude/skills/rafter-skill-review/`) and for Codex and Gemini (`.agents/skills/rafter-skill-review/`); this rule is the condensed equivalent here.)
|
|
9
9
|
|
|
10
|
-
- Run `rafter skill review <path-or-url>` against the SKILL.md / MCP manifest / Cursor rule / agent config.
|
|
11
|
-
-
|
|
12
|
-
- Do NOT install, load, recommend, or forward the asset until
|
|
10
|
+
- Run `rafter skill review <path-or-url>` against the SKILL.md / MCP manifest / Cursor rule / agent config — its report already covers most of the deeper checks (provenance, obfuscation, secrets, prompt-injection patterns).
|
|
11
|
+
- Weigh telemetry, allowed-tools scope, and network egress by hand on top of that report.
|
|
12
|
+
- Do NOT install, load, recommend, or forward the asset until you have a verdict.
|
|
13
13
|
|
|
14
14
|
Installing a skill grants Read/Bash/network under your identity — `curl | sh` in a different costume. Bypassing this turns the agent into a delivery vector.
|
|
@@ -5,11 +5,11 @@ alwaysApply: false
|
|
|
5
5
|
|
|
6
6
|
# rafter — security toolkit router
|
|
7
7
|
|
|
8
|
-
Pointer rule.
|
|
8
|
+
Pointer rule. Full guidance is installed as a Cursor sub-agent at `.cursor/agents/rafter.md`; run `rafter brief scanning` for the same content from a terminal.
|
|
9
9
|
|
|
10
10
|
- Run `rafter run` for the default tier — remote SAST + SCA + secrets. Needs `RAFTER_API_KEY`.
|
|
11
11
|
- Run `rafter run --mode plus` for agentic deep-dive on suspicious patterns.
|
|
12
12
|
- Run `rafter secrets <path>` for offline secrets-only (NOT a code security scan).
|
|
13
13
|
- Run `rafter agent exec --dry-run -- <cmd>` to classify a shell command's risk before running it.
|
|
14
14
|
|
|
15
|
-
If unsure which tier to pick,
|
|
15
|
+
If unsure which tier to pick, run `rafter brief scanning` and follow the routing table.
|
|
@@ -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.12.0
|
|
5
5
|
homepage: https://rafter.so
|
|
6
6
|
metadata:
|
|
7
7
|
openclaw:
|