eslint-plugin-anthropic-security 0.3.0 → 0.3.2

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/README.md CHANGED
@@ -16,6 +16,7 @@
16
16
  <a href="https://www.npmjs.com/package/eslint-plugin-anthropic-security" target="_blank"><img src="https://img.shields.io/npm/v/eslint-plugin-anthropic-security.svg" alt="NPM Version" /></a>
17
17
  <a href="https://www.npmjs.com/package/eslint-plugin-anthropic-security" target="_blank"><img src="https://img.shields.io/npm/dm/eslint-plugin-anthropic-security.svg" alt="NPM Downloads" /></a>
18
18
  <a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="Package License" /></a>
19
+ <a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/eslint" target="_blank"><img src="https://api.securityscorecards.dev/projects/github.com/ofri-peretz/eslint/badge" alt="OpenSSF Scorecard" /></a>
19
20
  </p>
20
21
 
21
22
  > ⭐ If this plugin caught a real bug for you, [**star the repo**](https://github.com/ofri-peretz/eslint) — it's the signal that keeps these rules maintained.
@@ -30,6 +31,45 @@ Every rule gates on the SDK actually being imported, so the plugin stays silent
30
31
 
31
32
  **Interlace** fosters **strength through integration**. Instead of stacking isolated rules, we **interlace** security directly into your workflow to create a resilient fabric of code. We believe tools should **guide rather than gatekeep**, providing educational feedback that strengthens the developer with every interaction.
32
33
 
34
+ <!-- AUTO-GENERATED:DOCTRINE:START - Do not edit manually -->
35
+
36
+ ## Why these rules are quiet
37
+
38
+ **Noise creates apathy, and apathy is not a security posture.** A linter that reports
39
+ a thousand things a week gets switched off in a month, and the real finding goes with
40
+ it. So every rule here is built to be worth reading: we would rather miss a finding
41
+ than spend your attention on one that was never real.
42
+
43
+ That is a trade, and it is made deliberately. It costs recall, and we measure what it
44
+ costs rather than assuming it is free.
45
+
46
+ ## How the rules decide
47
+
48
+ **Evidence, not names.** A rule fires on what the code *does*, resolved through the
49
+ AST and ESLint's own scope analysis — not on an identifier that happens to contain
50
+ `query`, a method called `setItem`, or a file whose path contains `key`. Every one of
51
+ those was a real false positive in this ecosystem, found by reading our own output on
52
+ open-source projects and fixed with a test that fails on the unfixed rule.
53
+
54
+ Where a rule has known false-positive shapes, its page carries a **Not a finding**
55
+ section: what it deliberately stays quiet on, and what to check first when it fires
56
+ and you disagree.
57
+
58
+ ## What you get
59
+
60
+ The rules below. Security rules carry a CWE mapping and, where one is assigned, a
61
+ CVSS score; every rule carries a fix on its message — in prose for a human and as
62
+ structured JSON for an agent. Install it, enable
63
+ `recommended`, and read the findings. If one of them is wrong,
64
+ [open an issue](https://github.com/ofri-peretz/eslint/issues) — a false positive is a
65
+ bug here, not a tuning exercise for you.
66
+
67
+ How that is measured, on which projects, and where it falls short:
68
+ [benchmark methodology](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-METHODOLOGY.md)
69
+ and [results](https://github.com/ofri-peretz/eslint/blob/main/BENCHMARK-RESULTS.md).
70
+
71
+ <!-- AUTO-GENERATED:DOCTRINE:END -->
72
+
33
73
  ## Getting Started
34
74
 
35
75
  - To check out the [guide](https://eslint.interlace.tools/docs/security/plugin-anthropic-security?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-anthropic-security), visit [eslint.interlace.tools](https://eslint.interlace.tools/?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-anthropic-security). 📚
@@ -96,10 +136,13 @@ See the [ESLint Version Support Policy](../../docs/ESLINT_VERSION_SUPPORT.md) fo
96
136
  | 🟡 | **Type-aware (refining)**: pure-AST primary path; types refine precision. |
97
137
  | 🟠 | **Type-aware (graceful)**: requires TS program; silent without it. |
98
138
 
139
+ <!-- AUTO-GENERATED:RULES_TABLE:START - Do not edit manually -->
99
140
  | Rule | CWE | OWASP | CVSS | Description | 🧠 | 💼 | ⚠️ | 🔧 | 💡 | 🚫 |
100
- | :--- | :--- | :--- | :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
101
- | [no-hardcoded-api-key](./docs/rules/no-hardcoded-api-key.md) | CWE-798 | A07:2021 | 9.1 | Forbid a literal API key in the Anthropic client options | 🟢 | 💼 | | | | |
102
-
141
+ | :--- | :---: | :---: | :---: | :--- | :---: | :---: | :---: | :---: | :---: | :---: |
142
+ | [no-browser-api-key-exposure](https://eslint.interlace.tools/docs/security/plugin-anthropic-security/rules/no-browser-api-key-exposure?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-anthropic-security) | CWE-522 | A07:2021 | | Forbid dangerouslyAllowBrowser, which exposes the Anthropic API key to the client | 🟢 | | | | | |
143
+ | [no-hardcoded-api-key](https://eslint.interlace.tools/docs/security/plugin-anthropic-security/rules/no-hardcoded-api-key?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-anthropic-security) | CWE-798 | A07:2021 | | Forbid a literal API key in the Anthropic client options | 🟢 | | | | | |
144
+ | [no-untrusted-content-in-prompt](https://eslint.interlace.tools/docs/security/plugin-anthropic-security/rules/no-untrusted-content-in-prompt?utm_source=github&utm_medium=referral&utm_campaign=eslint-plugin-anthropic-security) | CWE-1427 | A03:2021 | | Disallow untrusted content built into the Anthropic system prompt | 🟢 | | | | | |
145
+ <!-- AUTO-GENERATED:RULES_TABLE:END -->
103
146
  <!-- INTERLACE:STAR_CTA:START -->
104
147
  ## ⭐ Support & follow
105
148
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-anthropic-security",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "ESLint plugin for Anthropic SDK security — catches hardcoded Claude API keys, the browser escape hatch that ships them to every visitor, and system prompts assembled from untrusted input.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -62,7 +62,7 @@
62
62
  "node": ">=18.0.0"
63
63
  },
64
64
  "peerDependencies": {
65
- "eslint": "^8.0.0 || ^9.0.0 || ^10.0.0",
65
+ "eslint": "^8.40.0 || ^9.0.0 || ^10.0.0",
66
66
  "@anthropic-ai/sdk": ">=0.1.0 <1.0.0",
67
67
  "@anthropic-ai/claude-agent-sdk": ">=0.1.0 <1.0.0"
68
68
  },
@@ -75,7 +75,7 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@interlace/eslint-devkit": "^1.10.0"
78
+ "@interlace/eslint-devkit": "^1.17.3"
79
79
  },
80
80
  "funding": {
81
81
  "type": "github",
package/src/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=exports.noUntrustedContentInPrompt=exports.noHardcodedApiKey=exports.noBrowserApiKeyExposure=void 0;var no_browser_api_key_exposure_2=require("./rules/no-browser-api-key-exposure");Object.defineProperty(exports,"noBrowserApiKeyExposure",{enumerable:true,get:function(){return no_browser_api_key_exposure_2.noBrowserApiKeyExposure}});var no_hardcoded_api_key_2=require("./rules/no-hardcoded-api-key");Object.defineProperty(exports,"noHardcodedApiKey",{enumerable:true,get:function(){return no_hardcoded_api_key_2.noHardcodedApiKey}});var no_untrusted_content_in_prompt_2=require("./rules/no-untrusted-content-in-prompt");Object.defineProperty(exports,"noUntrustedContentInPrompt",{enumerable:true,get:function(){return no_untrusted_content_in_prompt_2.noUntrustedContentInPrompt}});exports.rules={get"no-browser-api-key-exposure"(){return require("./rules/no-browser-api-key-exposure").noBrowserApiKeyExposure},get"no-hardcoded-api-key"(){return require("./rules/no-hardcoded-api-key").noHardcodedApiKey},get"no-untrusted-content-in-prompt"(){return require("./rules/no-untrusted-content-in-prompt").noUntrustedContentInPrompt}};exports.plugin={meta:{name:"eslint-plugin-anthropic-security",version:"0.3.0"},rules:exports.rules};const enabled={plugins:{"anthropic-security":exports.plugin},rules:{"anthropic-security/no-browser-api-key-exposure":"error","anthropic-security/no-hardcoded-api-key":"error"}};const strict={plugins:{"anthropic-security":exports.plugin},rules:{...enabled.rules,"anthropic-security/no-untrusted-content-in-prompt":"error"}};exports.configs={minimal:enabled,recommended:enabled,strict};exports.default={...exports.plugin,configs:exports.configs};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.configs=exports.plugin=exports.rules=exports.noUntrustedContentInPrompt=exports.noHardcodedApiKey=exports.noBrowserApiKeyExposure=void 0;const eslint_devkit_1=require("@interlace/eslint-devkit");var no_browser_api_key_exposure_2=require("./rules/no-browser-api-key-exposure");Object.defineProperty(exports,"noBrowserApiKeyExposure",{enumerable:true,get:function(){return no_browser_api_key_exposure_2.noBrowserApiKeyExposure}});var no_hardcoded_api_key_2=require("./rules/no-hardcoded-api-key");Object.defineProperty(exports,"noHardcodedApiKey",{enumerable:true,get:function(){return no_hardcoded_api_key_2.noHardcodedApiKey}});var no_untrusted_content_in_prompt_2=require("./rules/no-untrusted-content-in-prompt");Object.defineProperty(exports,"noUntrustedContentInPrompt",{enumerable:true,get:function(){return no_untrusted_content_in_prompt_2.noUntrustedContentInPrompt}});exports.rules={get"no-browser-api-key-exposure"(){return require("./rules/no-browser-api-key-exposure").noBrowserApiKeyExposure},get"no-hardcoded-api-key"(){return require("./rules/no-hardcoded-api-key").noHardcodedApiKey},get"no-untrusted-content-in-prompt"(){return require("./rules/no-untrusted-content-in-prompt").noUntrustedContentInPrompt}};(0,eslint_devkit_1.withCanonicalDocsUrls)("plugin-anthropic-security",exports.rules);exports.plugin={meta:{name:"eslint-plugin-anthropic-security",version:"0.3.1"},rules:exports.rules};const enabled={plugins:{"anthropic-security":exports.plugin},rules:{"anthropic-security/no-browser-api-key-exposure":"error","anthropic-security/no-hardcoded-api-key":"error"}};const strict={plugins:{"anthropic-security":exports.plugin},rules:{...enabled.rules,"anthropic-security/no-untrusted-content-in-prompt":"error"}};exports.configs={minimal:enabled,recommended:enabled,strict};exports.default={...exports.plugin,configs:exports.configs};