@rafter-security/cli 0.5.3 → 0.5.9

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.
Files changed (40) hide show
  1. package/README.md +15 -3
  2. package/dist/commands/agent/audit-skill.js +2 -2
  3. package/dist/commands/agent/audit.js +96 -0
  4. package/dist/commands/agent/baseline.js +213 -0
  5. package/dist/commands/agent/exec.js +1 -1
  6. package/dist/commands/agent/index.js +4 -0
  7. package/dist/commands/agent/init.js +371 -29
  8. package/dist/commands/agent/install-hook.js +41 -47
  9. package/dist/commands/agent/scan.js +196 -23
  10. package/dist/commands/agent/status.js +65 -4
  11. package/dist/commands/agent/update-gitleaks.js +40 -0
  12. package/dist/commands/agent/verify.js +18 -4
  13. package/dist/commands/backend/run.js +69 -61
  14. package/dist/commands/ci/init.js +10 -3
  15. package/dist/commands/completion.js +320 -110
  16. package/dist/commands/hook/posttool.js +21 -7
  17. package/dist/commands/hook/pretool.js +50 -13
  18. package/dist/commands/issues/dedup.js +39 -0
  19. package/dist/commands/issues/from-scan.js +143 -0
  20. package/dist/commands/issues/from-text.js +185 -0
  21. package/dist/commands/issues/github-client.js +85 -0
  22. package/dist/commands/issues/index.js +25 -0
  23. package/dist/commands/issues/issue-builder.js +101 -0
  24. package/dist/commands/policy/export.js +7 -2
  25. package/dist/commands/scan/index.js +44 -0
  26. package/dist/core/audit-logger.js +41 -0
  27. package/dist/core/config-defaults.js +28 -0
  28. package/dist/core/config-manager.js +19 -2
  29. package/dist/core/pattern-engine.js +26 -1
  30. package/dist/core/risk-rules.js +5 -3
  31. package/dist/index.js +8 -2
  32. package/dist/scanners/gitleaks.js +5 -5
  33. package/dist/scanners/regex-scanner.js +12 -1
  34. package/dist/scanners/secret-patterns.js +3 -3
  35. package/dist/utils/binary-manager.js +59 -20
  36. package/dist/utils/skill-manager.js +5 -3
  37. package/package.json +2 -1
  38. package/resources/pre-commit-hook.sh +2 -2
  39. package/resources/pre-push-hook.sh +60 -0
  40. package/resources/rafter-security-skill.md +7 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rafter-security/cli",
3
- "version": "0.5.3",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "rafter": "./dist/index.js"
@@ -22,6 +22,7 @@
22
22
  "@modelcontextprotocol/sdk": "^1.12.0",
23
23
  "axios": "^1.6.8",
24
24
  "chalk": "^5.3.0",
25
+ "chokidar": "^5.0.0",
25
26
  "commander": "^11.1.0",
26
27
  "dotenv": "^16.4.5",
27
28
  "js-yaml": "^4.1.0",
@@ -27,14 +27,14 @@ fi
27
27
  echo "🔍 Rafter: Scanning staged files for secrets..."
28
28
 
29
29
  # Scan staged files
30
- rafter agent scan --staged --quiet
30
+ rafter scan local --staged --quiet
31
31
 
32
32
  EXIT_CODE=$?
33
33
 
34
34
  if [ $EXIT_CODE -ne 0 ]; then
35
35
  echo -e "${RED}❌ Commit blocked: Secrets detected in staged files${NC}"
36
36
  echo ""
37
- echo " Run: rafter agent scan --staged"
37
+ echo " Run: rafter scan local --staged"
38
38
  echo " To see details and remediate."
39
39
  echo ""
40
40
  echo " To bypass (NOT recommended): git commit --no-verify"
@@ -0,0 +1,60 @@
1
+ #!/bin/bash
2
+ # Rafter Security Pre-Push Hook
3
+ # Scans commits being pushed for secrets
4
+
5
+ # Colors for output
6
+ RED='\033[0;31m'
7
+ YELLOW='\033[1;33m'
8
+ GREEN='\033[0;32m'
9
+ NC='\033[0m' # No Color
10
+
11
+ # Check if rafter is installed
12
+ if ! command -v rafter &> /dev/null; then
13
+ echo -e "${YELLOW}⚠️ Warning: rafter CLI not found in PATH${NC}"
14
+ echo " Install: npm install -g @rafter-security/cli"
15
+ echo " Skipping secret scan..."
16
+ exit 0
17
+ fi
18
+
19
+ ZERO_SHA="0000000000000000000000000000000000000000"
20
+ FOUND_SECRETS=0
21
+
22
+ while read local_ref local_sha remote_ref remote_sha; do
23
+ # Skip branch deletions
24
+ if [ "$local_sha" = "$ZERO_SHA" ]; then
25
+ continue
26
+ fi
27
+
28
+ if [ "$remote_sha" = "$ZERO_SHA" ]; then
29
+ # New branch — scan all commits on this branch not on any remote branch
30
+ ref_arg=$(git rev-list --max-parents=0 "$local_sha" 2>/dev/null | head -1)
31
+ if [ -z "$ref_arg" ]; then
32
+ ref_arg="$local_sha^"
33
+ fi
34
+ else
35
+ # Existing branch — scan only new commits
36
+ ref_arg="$remote_sha"
37
+ fi
38
+
39
+ echo "🔍 Rafter: Scanning commits being pushed ($local_ref)..."
40
+
41
+ rafter scan local --diff "$ref_arg" --quiet
42
+ EXIT_CODE=$?
43
+
44
+ if [ $EXIT_CODE -ne 0 ]; then
45
+ FOUND_SECRETS=1
46
+ fi
47
+ done
48
+
49
+ if [ $FOUND_SECRETS -ne 0 ]; then
50
+ echo -e "${RED}❌ Push blocked: Secrets detected in commits being pushed${NC}"
51
+ echo ""
52
+ echo " Run: rafter scan local --diff <remote-sha>"
53
+ echo " To see details and remediate."
54
+ echo ""
55
+ echo " To bypass (NOT recommended): git push --no-verify"
56
+ exit 1
57
+ fi
58
+
59
+ echo -e "${GREEN}✓ No secrets detected${NC}"
60
+ exit 0
@@ -6,8 +6,8 @@ openclaw:
6
6
  always: false
7
7
  requires:
8
8
  bins: [rafter]
9
- version: 0.4.0
10
- last_updated: 2026-02-03
9
+ version: 0.5.8
10
+ last_updated: 2026-03-04
11
11
  ---
12
12
 
13
13
  # Rafter Security
@@ -32,7 +32,7 @@ Rafter provides real-time security checks for agent operations:
32
32
  Scan files for secrets before committing.
33
33
 
34
34
  ```bash
35
- rafter agent scan <path>
35
+ rafter scan local <path>
36
36
  ```
37
37
 
38
38
  **When to use:**
@@ -57,21 +57,17 @@ rafter agent scan <path>
57
57
 
58
58
  ### /rafter-bash
59
59
 
60
- Execute shell command with security validation.
60
+ Explicitly run a command through Rafter's security validator.
61
61
 
62
62
  ```bash
63
63
  rafter agent exec <command>
64
64
  ```
65
65
 
66
- **Features:**
67
- - Blocks destructive commands (rm -rf /, fork bombs)
68
- - Requires approval for dangerous operations
69
- - Logs all command attempts
70
- - Scans staged files before git commits
66
+ **When to use:** Only needed in environments where the `PreToolUse` hook is not installed. When `rafter agent init` has been run, all shell commands are validated automatically — you do not need to route commands through this.
71
67
 
72
68
  **Risk levels:**
73
69
  - **Critical** (blocked): rm -rf /, fork bombs, dd to /dev
74
- - **High** (approval required): sudo rm, chmod 777, curl|bash
70
+ - **High** (approval required): sudo rm, chmod 777, curl | bash
75
71
  - **Medium** (approval on moderate+): sudo, chmod, kill -9
76
72
  - **Low** (allowed): npm install, git commit, ls
77
73
 
@@ -269,7 +265,7 @@ Configure with: `rafter agent config set agent.riskLevel moderate`
269
265
 
270
266
  ## Best Practices
271
267
 
272
- 1. **Always scan before commits**: Run `rafter agent scan` before `git commit`
268
+ 1. **Always scan before commits**: Run `rafter scan local` before `git commit`
273
269
  2. **Audit untrusted skills**: Run `/rafter-audit-skill` on skills from unknown sources before installation
274
270
  3. **Review audit logs**: Check `rafter agent audit` after suspicious activity
275
271
  4. **Keep patterns updated**: Patterns updated automatically with CLI updates