@rafter-security/cli 0.11.5 → 0.11.6

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.
@@ -59,9 +59,10 @@ export function loadPolicy(baseDir) {
59
59
  return null;
60
60
  try {
61
61
  const content = fs.readFileSync(policyPath, "utf-8");
62
- const parsed = yaml.load(content);
63
- if (!parsed || typeof parsed !== "object")
62
+ const loaded = yaml.load(content);
63
+ if (!loaded || typeof loaded !== "object")
64
64
  return null;
65
+ const parsed = normalizeKeySpelling(loaded);
65
66
  return validatePolicy(mapPolicy(parsed), parsed);
66
67
  }
67
68
  catch (e) {
@@ -69,6 +70,65 @@ export function loadPolicy(baseDir) {
69
70
  return null;
70
71
  }
71
72
  }
73
+ /**
74
+ * camelCase spelling -> snake_case key, for every multi-word key the loader
75
+ * reads, per nesting level (sable-req5). The hosted scanner accepts both
76
+ * spellings with snake_case winning on collision; so do both CLIs. Keep this
77
+ * table identical to _CAMEL_ALIASES in python/rafter_cli/core/policy_loader.py.
78
+ */
79
+ const CAMEL_ALIASES = {
80
+ top: {
81
+ riskLevel: "risk_level",
82
+ commandPolicy: "command_policy",
83
+ excludePaths: "exclude_paths",
84
+ customPatterns: "custom_patterns",
85
+ },
86
+ command_policy: {
87
+ blockedPatterns: "blocked_patterns",
88
+ requireApproval: "require_approval",
89
+ allowedPatterns: "allowed_patterns",
90
+ },
91
+ scan: {
92
+ excludePaths: "exclude_paths",
93
+ customPatterns: "custom_patterns",
94
+ autoUpdateBetterleaks: "auto_update_betterleaks",
95
+ plusRequiresApproval: "plus_requires_approval",
96
+ },
97
+ audit: {
98
+ retentionDays: "retention_days",
99
+ logLevel: "log_level",
100
+ logPath: "log_path",
101
+ },
102
+ "docs.cache": {
103
+ ttlSeconds: "ttl_seconds",
104
+ },
105
+ };
106
+ const isPlainObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
107
+ /** Copy `d` with known camelCase keys renamed to snake_case; snake_case wins. */
108
+ function snakeKeys(d, aliases) {
109
+ const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
110
+ // fromEntries defines own properties, so a "__proto__" key stays a plain key.
111
+ const out = Object.fromEntries(Object.entries(d).filter(([k]) => !has(aliases, k)));
112
+ for (const [camel, snake] of Object.entries(aliases)) {
113
+ if (has(d, camel) && !has(d, snake))
114
+ out[snake] = d[camel];
115
+ }
116
+ return out;
117
+ }
118
+ /** Rewrite camelCase policy keys to the snake_case `mapPolicy` reads. */
119
+ function normalizeKeySpelling(loaded) {
120
+ const raw = snakeKeys(loaded, CAMEL_ALIASES.top);
121
+ for (const section of ["command_policy", "scan", "audit"]) {
122
+ if (isPlainObject(raw[section]))
123
+ raw[section] = snakeKeys(raw[section], CAMEL_ALIASES[section]);
124
+ }
125
+ if (Array.isArray(raw.docs)) {
126
+ raw.docs = raw.docs.map((e) => isPlainObject(e) && isPlainObject(e.cache)
127
+ ? { ...e, cache: snakeKeys(e.cache, CAMEL_ALIASES["docs.cache"]) }
128
+ : e);
129
+ }
130
+ return raw;
131
+ }
72
132
  /**
73
133
  * Map snake_case YAML keys to camelCase PolicyFile
74
134
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rafter-security/cli",
3
- "version": "0.11.5",
3
+ "version": "0.11.6",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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.11.5
4
+ version: 0.11.6
5
5
  homepage: https://rafter.so
6
6
  metadata:
7
7
  openclaw: