@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
|
@@ -23,7 +23,7 @@ Assume every string that reaches the prompt — user input, retrieved documents,
|
|
|
23
23
|
- Model source: where does the model come from? Provider API (which account?) or self-hosted? If self-hosted, from which registry? Is the weights file checksummed?
|
|
24
24
|
- Embedding model: same questions. Many RAG pipelines have *two* models; both are supply chain.
|
|
25
25
|
- Prompt templates: if loaded from a shared registry (LangChain Hub, custom store), pinned and verified? Or pulled by name?
|
|
26
|
-
- Plugins / tools / MCP servers registered with the agent — are they
|
|
26
|
+
- Plugins / tools / MCP servers registered with the agent — are they vetted (see `rafter skill review`) before install?
|
|
27
27
|
|
|
28
28
|
## LLM04 — Data & Model Poisoning
|
|
29
29
|
|
|
@@ -84,4 +84,4 @@ A design question, but reviewable:
|
|
|
84
84
|
- For every tool the agent can call: documented purpose, scope, and human-gate story.
|
|
85
85
|
- For every retrieval/RAG path: write-access audit, injection defenses, tenant isolation.
|
|
86
86
|
- For every model output sink: treated as untrusted, specific sanitization / validation cited.
|
|
87
|
-
- Run `rafter
|
|
87
|
+
- Run `rafter skill review` on any bundled skills/plugins. Pair with `rafter run` for SAST.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Security gates: what to check when auditing a codebase
|
|
2
|
+
|
|
3
|
+
Most exploitable bugs in mature code are not a dangerous sink reached by tainted data. They are a **gate**, a function that decides whether something is allowed, that says yes when it should say no. A one-character change to a comparison, a dropped condition, or a flag that is set and never read is enough. Source-to-sink tracing misses these, because the sink is fine and the data is trusted after the gate.
|
|
4
|
+
|
|
5
|
+
So in an audit, find the gates first, then try to make each one say yes wrongly.
|
|
6
|
+
|
|
7
|
+
## 1. Inventory the gates
|
|
8
|
+
|
|
9
|
+
Grep for the functions that decide, not the ones that act:
|
|
10
|
+
|
|
11
|
+
- Names: `authorize`, `authenticate`, `allow`, `permit`, `can*`, `is*Allowed`, `has*Permission`, `check*`, `verify*`, `validate*`, `match*`, `isSafe*`, `isTrusted*`, middleware and interceptors.
|
|
12
|
+
- Config that feeds them: allowlists, trusted domains or proxies, roles, scopes, ACL rules, TLS and auth settings.
|
|
13
|
+
- Callers that skip them: handlers registered without the middleware their siblings use.
|
|
14
|
+
|
|
15
|
+
For each gate, write down its contract in one sentence ("only same-origin redirect targets", "only active users with a valid password") before reading the body.
|
|
16
|
+
|
|
17
|
+
## 2. Ask of every gate: name an input the contract rejects and this code accepts
|
|
18
|
+
|
|
19
|
+
Work through these failure shapes. Each one has fooled real reviewers.
|
|
20
|
+
|
|
21
|
+
**Matching that is too loose.**
|
|
22
|
+
- Substring, prefix or suffix where equality or a dot-boundary was needed: `strings.Contains(host, allowed)`, `HasSuffix(host, "example.com")` accepting `evilexample.com`, `startswith("/safe")` accepting `/safe-but-not`.
|
|
23
|
+
- Case folding or normalization applied on one side only; `EqualFold` where the comparison must be exact.
|
|
24
|
+
- Wildcards and globs that match more than intended; an empty pattern or empty list that means "allow all".
|
|
25
|
+
- Comparing a truncated value (a prefix of a digest or token) as if it were the whole.
|
|
26
|
+
|
|
27
|
+
**Decision logic that fails open.**
|
|
28
|
+
- The wrong variable checked (a sibling field, the requested resource instead of the actor), or a check applied to some request kinds and skipped for others.
|
|
29
|
+
- An early `return nil` or `return true` on an error or missing value; `!= nil` versus `== nil` inverted; `||` where `&&` was needed.
|
|
30
|
+
- A default branch, fallback, or "unknown" case that grants access.
|
|
31
|
+
|
|
32
|
+
**Validity checks that are missing.**
|
|
33
|
+
- Authentication that accepts accounts or credentials it should reject (inactive, expired, unverified, revoked); expiry compared with the wrong clock or unit.
|
|
34
|
+
- Signatures, MACs or certificates parsed but never verified; key usage, issuer, audience or algorithm not checked.
|
|
35
|
+
- TLS or peer verification turned off, or a required check quietly made optional.
|
|
36
|
+
|
|
37
|
+
**A security value that is set but never read.**
|
|
38
|
+
- A flag, field or option the gate computes or accepts (`verified`, `enabled`, `strict`, `requireX`) and then ignores. Grep for each security-relevant field and confirm it is read in the decision, not only assigned.
|
|
39
|
+
- A config option parsed and stored but never wired into the code that should honor it.
|
|
40
|
+
|
|
41
|
+
**A twin that lost its guard.**
|
|
42
|
+
- Sibling implementations of the same contract: sync and async variants, two storage or authentication backends, v1 and v2 handlers. Diff them. If one escapes, checks or limits and the other doesn't, the other is the bug.
|
|
43
|
+
|
|
44
|
+
**Containment and escaping.**
|
|
45
|
+
- Paths joined from input without cleaning and re-checking that the result stays under the root, or a symlink followed after the check.
|
|
46
|
+
- Filters, queries, HTML or shell built from input without the escaping the neighboring code uses.
|
|
47
|
+
|
|
48
|
+
**Limits.**
|
|
49
|
+
- Size, count, depth or time limits missing, disabled (`-1`, `0` meaning unlimited), or checked after the expensive work.
|
|
50
|
+
|
|
51
|
+
## 3. Report
|
|
52
|
+
|
|
53
|
+
For each finding: the file and line of the faulty expression, the contract it breaks, a concrete input that gets through, and what an attacker gains. A gate that holds is not a finding; move on.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: rafter-secure-design
|
|
3
3
|
description: "REQUIRED before writing code for any feature touching auth, payments, credentials, tokens, sessions, file upload, user data, untrusted input, deserialization, network endpoints, or data deletion. Scope by that surface, not the task label — a research/experimental/local-only feature with none of it doesn't need this. Invoke it, record answers inline in the design doc or PR description, then write the code. Skipping this is how auth bypass, token leakage, and delete-the-wrong-record bugs ship. If the feature touches any of those surfaces and this hasn't run, the design is incomplete — do not proceed to implementation."
|
|
4
4
|
version: 0.1.0
|
|
5
|
+
publisher: rafter-security
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
# Rafter Secure Design — Designing It Right The First Time
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
name: rafter-skill-review
|
|
3
3
|
description: "REQUIRED before copying any third-party SKILL.md, MCP manifest, Cursor rule, or agent config into this machine or forwarding one to a user. Installing a skill grants Read/Bash/network under your identity — this is `curl | sh` in a different costume. Do not install, load, recommend, or forward any third-party agent asset until this skill has vetted it. Bypassing this turns the agent into a delivery vector."
|
|
4
4
|
version: 0.1.0
|
|
5
|
+
publisher: rafter-security
|
|
5
6
|
---
|
|
6
7
|
|
|
7
8
|
# Rafter Skill Review — Vet Before You Install
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
trigger: model_decision
|
|
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
|
---
|
|
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 @@ description: "REQUIRED before writing code for any feature touching auth, paymen
|
|
|
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 @@ description: "REQUIRED before copying any third-party SKILL.md, MCP manifest, Cu
|
|
|
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 @@ description: "Entry point for rafter. Invoke when a sub-skill is unclear, or whe
|
|
|
5
5
|
|
|
6
6
|
# rafter — security toolkit router
|
|
7
7
|
|
|
8
|
-
Pointer rule
|
|
8
|
+
Pointer rule for the `rafter` skill. Full guidance: run `rafter brief scanning` (or `rafter brief commands` for just the command list).
|
|
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.
|