eslint-plugin-vercel-ai-security 1.4.1 → 1.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint-plugin-vercel-ai-security",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "ESLint plugin for Vercel AI SDK security — detects prompt injection, system-prompt leaks, hardcoded API keys, and unvalidated model output in generateText and streamText.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -82,7 +82,7 @@ exports.rules = {
82
82
  exports.plugin = {
83
83
  meta: {
84
84
  name: 'eslint-plugin-vercel-ai-security',
85
- version: '1.4.1',
85
+ version: '1.4.2',
86
86
  },
87
87
  rules: exports.rules,
88
88
  };
@@ -80,7 +80,7 @@ exports.noDynamicSystemPrompt = (0, eslint_devkit_1.createRule)({
80
80
  for (const prop of optionsArg.properties) {
81
81
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
82
82
  continue;
83
- const keyName = (0, prompt_props_1.getStaticPropName)(prop.key);
83
+ const keyName = (0, prompt_props_1.getStaticPropName)(prop);
84
84
  if (!(0, prompt_props_1.isSystemPromptProp)(keyName))
85
85
  continue;
86
86
  if (isDynamicContent(prop.value)) {
@@ -103,7 +103,7 @@ exports.noSensitiveInPrompt = (0, eslint_devkit_1.createRule)({
103
103
  for (const prop of optionsArg.properties) {
104
104
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
105
105
  continue;
106
- const keyName = (0, prompt_props_1.getStaticPropName)(prop.key);
106
+ const keyName = (0, prompt_props_1.getStaticPropName)(prop);
107
107
  if (!keyName || !propsToCheck.has(keyName))
108
108
  continue;
109
109
  const sensitiveVar = findSensitiveData(prop.value);
@@ -132,7 +132,7 @@ exports.requireRagContentValidation = (0, eslint_devkit_1.createRule)({
132
132
  for (const prop of optionsArg.properties) {
133
133
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
134
134
  continue;
135
- const keyName = (0, prompt_props_1.getStaticPropName)(prop.key);
135
+ const keyName = (0, prompt_props_1.getStaticPropName)(prop);
136
136
  if (keyName !== 'prompt' && !(0, prompt_props_1.isSystemPromptProp)(keyName))
137
137
  continue;
138
138
  const ragSource = containsRagContent(prop.value);
@@ -162,7 +162,7 @@ exports.requireValidatedPrompt = (0, eslint_devkit_1.createRule)({
162
162
  for (const prop of optionsArg.properties) {
163
163
  if (prop.type !== eslint_devkit_1.AST_NODE_TYPES.Property)
164
164
  continue;
165
- const keyName = (0, prompt_props_1.getStaticPropName)(prop.key);
165
+ const keyName = (0, prompt_props_1.getStaticPropName)(prop);
166
166
  if (keyName === 'prompt') {
167
167
  const result = hasUnsafeUserInput(prop.value);
168
168
  if (result.unsafe) {
@@ -8,10 +8,13 @@ exports.SYSTEM_PROMPT_PROPS = new Set(['instructions', 'system']);
8
8
  function isSystemPromptProp(name) {
9
9
  return name !== null && exports.SYSTEM_PROMPT_PROPS.has(name);
10
10
  }
11
- function getStaticPropName(key) {
12
- if (key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier)
13
- return key.name;
14
- if (key.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof key.value === 'string')
15
- return key.value;
11
+ function getStaticPropName(prop) {
12
+ if (prop.computed)
13
+ return null;
14
+ if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Identifier)
15
+ return prop.key.name;
16
+ if (prop.key.type === eslint_devkit_1.AST_NODE_TYPES.Literal && typeof prop.key.value === 'string') {
17
+ return prop.key.value;
18
+ }
16
19
  return null;
17
20
  }