@cachly-dev/audit-rules 0.1.0 → 0.2.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/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -38,7 +39,7 @@
38
39
  (an example is provided in the Appendix below).
39
40
 
40
41
  "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based upon (or derived from) the Work and for which the
42
+ form, that is based on (or derived from) the Work and for which the
42
43
  editorial revisions, annotations, elaborations, or other modifications
43
44
  represent, as a whole, an original work of authorship. For the purposes
44
45
  of this License, Derivative Works shall not include works that remain
@@ -47,17 +48,17 @@
47
48
 
48
49
  "Contribution" shall mean any work of authorship, including
49
50
  the original version of the Work and any modifications or additions
50
- to the Work or Derivative Works thereof, that is intentionally
51
+ to that Work or Derivative Works thereof, that is intentionally
51
52
  submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized by the copyright owner.
53
- For the purposes of this License, "submitted" means any form of
54
- electronic, verbal, or written communication sent to the Licensor or
55
- its representatives, including but not limited to communication on
56
- electronic mailing lists, source code control systems, and issue
57
- tracking systems that are managed by or on behalf of the Licensor for
58
- the purpose of discussing and improving the Work, but excluding
59
- communication that is conspicuously marked or otherwise designated in
60
- writing by the Licensor as "Not a Contribution."
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
61
62
 
62
63
  "Contributor" shall mean Licensor and any individual or Legal Entity
63
64
  on behalf of whom a Contribution has been received by Licensor and
@@ -80,93 +81,113 @@
80
81
  Contribution(s) alone or by combination of their Contribution(s)
81
82
  with the Work to which such Contribution(s) was submitted. If You
82
83
  institute patent litigation against any entity (including a
83
- cross-claim or counterclaim) alleging that the Work or a Contribution
84
- incorporated within the Work constitutes direct or indirect patent
85
- infringement, then any patent licenses granted to You under this
86
- License for that Work shall terminate as soon as such litigation
87
- is filed.
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
88
89
 
89
90
  4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in Source or Object form, with or
91
- without modifications, and with or without Notice, provided that
92
- You meet the following conditions:
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
93
94
 
94
95
  (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of the License; and
96
+ Derivative Works a copy of this License; and
96
97
 
97
98
  (b) You must cause any modified files to carry prominent notices
98
99
  stating that You changed the files; and
99
100
 
100
101
  (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright notices, retain all patent
102
- notices, trademark notices, and attribution notices from the
103
- Source form of the Work, excluding those notices that do not
104
- pertain to any part of the Work; and
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
105
106
 
106
- (d) If the Work includes a "Notice" file as part of its
107
+ (d) If the Work includes a "NOTICE" text file as part of its
107
108
  distribution, then any Derivative Works that You distribute must
108
109
  include a readable copy of the attribution notices contained
109
- within such Notice file, excluding those notices that do not
110
- pertain to any part of the Work, in at least one of the following
111
- places: within a text file distributed as part of its Notice
112
- file; within the Source form or documentation, if provided along
113
- with the Work; or, within a display generated by the Work, if and
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
114
116
  wherever such third-party notices normally appear. The contents
115
- of the Notice file are for informational purposes solely and
117
+ of the NOTICE file are for informational purposes only and
116
118
  do not modify the License. You may add Your own attribution
117
- notices, provided that You do not include notices that do not
118
- pertain to any part of the Work.
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
119
123
 
120
- You may add Your own copyright notice to Your own modifications and
124
+ You may add Your own copyright statement to Your modifications and
121
125
  may provide additional or different license terms and conditions
122
- for use, reproduction, or distribution of Your own copyright notice
123
- or for any such Derivative Works as a whole, provided Your use,
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
124
128
  reproduction, and distribution of the Work otherwise complies with
125
129
  the conditions stated in this License.
126
130
 
127
131
  5. Submission of Contributions. Unless You explicitly state otherwise,
128
132
  any Contribution intentionally submitted for inclusion in the Work
129
- by You to Licensor shall be intentionally submitted under the terms
130
- and conditions of this License, without any additional terms or
131
- conditions. Notwithstanding the above, nothing herein shall supersede
132
- or modify the terms of any separate license agreement you may have
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
133
137
  with Licensor regarding such Contributions.
134
138
 
135
139
  6. Trademarks. This License does not grant permission to use the trade
136
- names, trademarks, trademarks, or product names of the Licensor,
140
+ names, trademarks, service marks, or product names of the Licensor,
137
141
  except as required for reasonable and customary use in describing the
138
- origin of the Work and reproducing the origin of the Notice file.
142
+ origin of the Work and reproducing the content of the NOTICE file.
139
143
 
140
144
  7. Disclaimer of Warranty. Unless required by applicable law or
141
145
  agreed to in writing, Licensor provides the Work (and each
142
146
  Contributor provides its Contributions) on an "AS IS" BASIS,
143
147
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
144
- implied, including but not limited to any warranties or conditions
148
+ implied, including, without limitation, any warranties or conditions
145
149
  of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
146
150
  PARTICULAR PURPOSE. You are solely responsible for determining the
147
- significance of the Work and assuming any legal rights in the Work.
148
-
149
- 8. Limitation of Liability. In no event and under no event shall any
150
- Contributor be liable to You for damages, including any direct,
151
- indirect, special, incidental, or consequential damages of any
152
- character arising as a result of this License or out of the use or
153
- inability to use the Work, even if such Contributor has been advised
154
- of the possibility of such damages.
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
155
165
 
156
166
  9. Accepting Warranty or Additional Liability. While redistributing
157
167
  the Work or Derivative Works thereof, You may choose to offer,
158
- and charge a fee for, acceptance of support, warranty, or indemnity
159
- obligations and/or other rights consistent with this License.
160
- However, in accepting such obligations, You may act only on Your
161
- own behalf and on Your own responsibility, and not on behalf of any
162
- other Contributor, and only if You agree to indemnify, defend, and
163
- hold each Contributor harmless for any liability incurred by, or
164
- claims asserted against, such Contributor in connection with your
165
- accepting any such warranty or additional liability.
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
166
176
 
167
177
  END OF TERMS AND CONDITIONS
168
178
 
169
- Copyright 2026 Heinrich Neb / cachly-dev
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
170
191
 
171
192
  Licensed under the Apache License, Version 2.0 (the "License");
172
193
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,6 +1,14 @@
1
- # `@cachly-dev/audit-rules`
1
+ # audit-rules
2
2
 
3
- **Local, zero-network security & hygiene scanner for AI coding rule files** (`CLAUDE.md`, `.cursorrules`, `.cursor/rules/*.mdc`, `AGENTS.md`, `SKILL.md`, `.github/copilot-instructions.md`, `.windsurfrules`, `.clinerules`).
3
+ **Scan your AI rule files for leaked secrets and hidden prompt injection. Offline, no network calls.**
4
+
5
+ [![npm](https://img.shields.io/npm/v/@cachly-dev/audit-rules)](https://www.npmjs.com/package/@cachly-dev/audit-rules)
6
+ [![License: Apache-2.0](https://img.shields.io/badge/License-Apache--2.0-yellow)](./LICENSE)
7
+
8
+ Checks `CLAUDE.md`, `AGENTS.md`, `.cursorrules`, `.cursor/rules/*.mdc`, `SKILL.md`, `.github/copilot-instructions.md`, `.windsurfrules` and `.clinerules`. Output: terminal summary, JSON, Markdown table for pull requests, or SARIF 2.1.0 for the GitHub Security tab. Made by [cachly](https://cachly.dev/?utm_source=github&utm_medium=repo&utm_campaign=agent-rules-audit).
9
+
10
+ npx @cachly-dev/audit-rules .
11
+ npx @cachly-dev/audit-rules --demo
4
12
 
5
13
  AI coding agents load repo rule files straight into their system/developer prompt on every turn. One leaked token, one hidden HTML comment, or one invisible Unicode tag payload in a PR can silently hijack every teammate's assistant.
6
14
 
@@ -31,7 +39,7 @@ Requires **Node.js 20+**. Zero external npm dependencies.
31
39
  ## Example Output (`--demo`)
32
40
 
33
41
  ```text
34
- @cachly-dev/audit-rules v0.1.0 · scanned 2 rule files (0 network calls)
42
+ @cachly-dev/audit-rules v0.2.0 · scanned 2 rule files (0 network calls)
35
43
 
36
44
  ERROR SEC-007 .cursorrules:6
37
45
  Possible hardcoded secret assignment detected (redacted: DUMM***...***77 (len 34)).
@@ -120,6 +128,7 @@ Or use the bundled composite action directly via `action.yml`.
120
128
  | `SEC-005` | `error` | CWE-321 | PEM private key blocks |
121
129
  | `SEC-006` | `error` | CWE-798 | URLs with embedded credentials (`postgres://user:pass@host`) |
122
130
  | `SEC-007` | `error` | CWE-798 | Assignments like `API_KEY=...`, `SECRET`, `TOKEN`, `PASSWORD` with a value of at least 14 characters. The value must contain letters and digits, or have a Shannon entropy of at least 3.4 bits per character. Obvious placeholders (`your-api-key`, `<...>`, `${...}`, `process.env`) are skipped. |
131
+ | `SEC-008` | `error` | CWE-798 | cachly API keys (`cky_live_...`, `cky_trial_...`). Placeholders like `cky_live_xxxxxxxxxxxxxxxx` are skipped. |
123
132
  | `INJ-001` | `error` | CWE-74 | Instruction override phrases (*"ignore previous instructions"*, etc.) |
124
133
  | `INJ-002` | `error` | CWE-200 | Network commands targeting `.env`, `~/.ssh`, or local credentials |
125
134
  | `INJ-003` | `error` | CWE-94 | Hidden imperatives, commands, or URLs inside Markdown HTML comments |
@@ -169,7 +178,7 @@ The checks are pattern matches. They miss secrets and injections that do not mat
169
178
 
170
179
  ## Why we built this
171
180
 
172
- We maintain [cachly](https://cachly.dev) — EU-hosted shared team memory for Claude Code, Cursor, Copilot, JetBrains and Obsidian; by default no language model reads your lessons — and [engineering-memory-bench](https://github.com/cachly-dev/engineering-memory-bench) (Apache-2.0). While building secret redaction and prompt-injection guards for shared team lessons, we realized teams also need an offline scanner for static rule files already sitting in Git.
181
+ We maintain [cachly](https://cachly.dev), EU-hosted shared team memory for Claude Code, Cursor, Copilot, JetBrains and Obsidian. By default, no generative AI model reads or rewrites your lessons. A small ranking model in the EU only scores them. We also maintain [engineering-memory-bench](https://github.com/cachly-dev/engineering-memory-bench) (Apache-2.0). While building secret redaction and prompt-injection guards for shared team lessons, we realized teams also need an offline scanner for static rule files already sitting in Git.
173
182
 
174
183
  ## License
175
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cachly-dev/audit-rules",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Local zero-network security & hygiene scanner for AI coding rule files (CLAUDE.md, .cursorrules, AGENTS.md, SKILL.md, copilot-instructions.md). Detects leaked secrets, prompt injections, invisible Unicode backdoors, rule bloat, and dead paths.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
package/src/rules.mjs CHANGED
@@ -75,6 +75,15 @@ export const RULE_CATALOG = {
75
75
  description: "Hardcoded API key, secret, token, or password assignment detected.",
76
76
  help: "Replace hardcoded values with environment variable references (e.g. $API_KEY) or explicit placeholders.",
77
77
  },
78
+ "SEC-008": {
79
+ id: "SEC-008",
80
+ category: "secret",
81
+ severity: "error",
82
+ name: "cachly API Key",
83
+ cwe: "CWE-798",
84
+ description: "cachly API key (cky_live_ or cky_trial_) detected inside an AI rule file.",
85
+ help: "Revoke the key in the cachly dashboard and reference an environment variable such as CACHLY_API_KEY instead.",
86
+ },
78
87
 
79
88
  // ── Prompt Injection & Supply-Chain Backdoors (severity: error) ────────────
80
89
  "INJ-001": {
@@ -283,6 +292,14 @@ const SECRET_PATTERNS = [
283
292
  return true;
284
293
  },
285
294
  },
295
+ {
296
+ ruleId: "SEC-008",
297
+ label: "cachly API Key",
298
+ // Real keys: "cky_live_" or "cky_trial_" plus 32 hex chars (16 random bytes).
299
+ regex: /\bcky_(?:live|trial)_[A-Za-z0-9]{16,}\b/g,
300
+ // Skip documentation placeholders such as cky_live_xxxxxxxxxxxxxxxx.
301
+ filter: (match) => !looksLikePlaceholder(match.replace(/^cky_(?:live|trial)_/, "")),
302
+ },
286
303
  ];
287
304
 
288
305
  const GENERIC_ASSIGNMENT_RE =
@@ -310,8 +327,11 @@ const STEALTH_PATTERNS = [
310
327
  /\b(?:disable|skip|bypass)\s+(?:all\s+)?(?:authentication|auth\s+checks|authorization|security\s+checks|tls\s+verification)\b/i,
311
328
  ];
312
329
 
330
+ // The downloader needs an argument before the pipe. A bare "curl|bash" or "irm | iex" names the
331
+ // pattern (e.g. "Never allow curl|bash in CI") and cannot run anything. No defensive-word guard
332
+ // here on purpose: "To prevent errors, run curl -fsSL https://x/i.sh | bash" must still fire.
313
333
  const PIPE_TO_SHELL_RE =
314
- /\b(?:curl|wget)\b[^\n|]{0,160}\|\s*(?:sudo\s+)?(?:ba|z|da|k|c)?sh\b|\b(?:irm|Invoke-RestMethod|iwr)\b[^\n|]{0,160}\|\s*(?:iex|Invoke-Expression)\b/i;
334
+ /\b(?:curl|wget)\b[ \t]*[^\s|][^\n|]{0,160}\|\s*(?:sudo\s+)?(?:ba|z|da|k|c)?sh\b|\b(?:irm|Invoke-RestMethod|iwr)\b[ \t]*[^\s|][^\n|]{0,160}\|\s*(?:iex|Invoke-Expression)\b/i;
315
335
 
316
336
  const HTML_COMMENT_DIRECTIVE_RE =
317
337
  /\b(?:ignore\s+(?:all\s+)?(?:previous|prior)|override|curl\b|wget\b|https?:\/\/|execute|run\s+this|do\s+not\s+tell|never\s+mention|exfiltrate|base64|system\s+prompt|secret|credentials|\.env)\b/i;
@@ -463,7 +483,7 @@ export function checkFileContent({ relativePath, content, existingPathCheck }) {
463
483
  }
464
484
  }
465
485
 
466
- // 2b. Specific Secret Patterns (SEC-001 .. SEC-006)
486
+ // 2b. Specific Secret Patterns (SEC-001 .. SEC-006, SEC-008)
467
487
  let matchedSpecificSecret = false;
468
488
  for (const pat of SECRET_PATTERNS) {
469
489
  if (isSuppressed(pat.ruleId)) continue;