diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/package.json b/packages/@secretlint/secretlint-rule-preset-recommend/package.json index c15208a66..f3f61e3d6 100644 --- a/packages/@secretlint/secretlint-rule-preset-recommend/package.json +++ b/packages/@secretlint/secretlint-rule-preset-recommend/package.json @@ -43,7 +43,7 @@ "build": "rollup --config", "build:tsc": "tsc -p . --noEmit", "clean": "rimraf module/", - "sync-canary": "cp ../secretlint-rule-preset-canary/src/index.ts src/ && sed -i '' -e 's/\\@secretlint\\/secretlint-rule-preset-canary/\\@secretlint\\/secretlint-rule-preset-recommend/' src/index.ts && cp -r ../secretlint-rule-preset-canary/test/ test && node cp-canary-deps.cjs && yarn install && npm run build && npm run updateSnapshot", + "sync-canary": "cp ../secretlint-rule-preset-canary/src/index.ts src/ && sed -i '' -e 's/\\@secretlint\\/secretlint-rule-preset-canary/\\@secretlint\\/secretlint-rule-preset-recommend/' src/index.ts && cp -r ../secretlint-rule-preset-canary/test/ test && sed -i '' -e 's/\\@secretlint\\/secretlint-rule-preset-canary/\\@secretlint\\/secretlint-rule-preset-recommend/' test/index.test.ts && node cp-canary-deps.cjs && yarn install && npm run build && npm run updateSnapshot", "prepublishOnly": "npm run clean && npm run build", "prettier": "prettier --write \"**/*.{js,jsx,ts,tsx,css}\"", "prepublish": "npm run --if-present build", @@ -90,4 +90,4 @@ "publishConfig": { "access": "public" } -} +} \ No newline at end of file diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/src/index.ts b/packages/@secretlint/secretlint-rule-preset-recommend/src/index.ts index d54877317..2ebbe4165 100644 --- a/packages/@secretlint/secretlint-rule-preset-recommend/src/index.ts +++ b/packages/@secretlint/secretlint-rule-preset-recommend/src/index.ts @@ -4,6 +4,7 @@ import { creator as ruleGCP } from "@secretlint/secretlint-rule-gcp"; import { creator as ruleNpm } from "@secretlint/secretlint-rule-npm"; import { creator as ruleSlack } from "@secretlint/secretlint-rule-slack"; import { creator as ruleBasicAuth } from "@secretlint/secretlint-rule-basicauth"; +import { creator as ruleOpenAi } from "@secretlint/secretlint-rule-openai"; import { creator as rulePrivateKey } from "@secretlint/secretlint-rule-privatekey"; import { creator as ruleSendgrid } from "@secretlint/secretlint-rule-sendgrid"; import { creator as ruleShopify } from "@secretlint/secretlint-rule-shopify"; @@ -20,6 +21,7 @@ export const rules = [ ruleSendgrid, ruleShopify, ruleGitHub, + ruleOpenAi, ruleFilterComments, ]; export type Options = {}; diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/test/index.test.ts b/packages/@secretlint/secretlint-rule-preset-recommend/test/index.test.ts index 44cd8700b..da57d96fb 100644 --- a/packages/@secretlint/secretlint-rule-preset-recommend/test/index.test.ts +++ b/packages/@secretlint/secretlint-rule-preset-recommend/test/index.test.ts @@ -6,7 +6,7 @@ import test from "node:test"; import { creator as rule } from "../module/index.js"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); -test("Snapshot Testing", async (t) => { +test("@secretlint/secretlint-rule-preset-recommend", async (t) => { const snapshot = (await import("@secretlint/tester")).snapshot; const eachRulesDir = fs .readdirSync(path.join(__dirname, "snapshots"), { diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ng.secret/input.txt b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ng.secret/input.txt new file mode 100644 index 000000000..6746cce60 --- /dev/null +++ b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ng.secret/input.txt @@ -0,0 +1 @@ +sk-sUeBP9asw6GiYHXqtg70T3BlbkFJJuLwJFco90bOpU0Ntest diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ng.secret/output.json b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ng.secret/output.json new file mode 100644 index 000000000..a0a18dd89 --- /dev/null +++ b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ng.secret/output.json @@ -0,0 +1,33 @@ +{ + "filePath": "[SNAPSHOT]/ng.secret/input.txt", + "messages": [ + { + "message": "found OpenAI API token: sk-sUeBP9asw6GiYHXqtg70T3BlbkFJJuLwJFco90bOpU0Ntest", + "range": [ + 0, + 51 + ], + "type": "message", + "ruleId": "@secretlint/secretlint-rule-openai", + "ruleParentId": "@secretlint/secretlint-rule-preset-recommend", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 51 + } + }, + "severity": "error", + "messageId": "OPENAI_TOKEN", + "docsUrl": "https://github.com/secretlint/secretlint/blob/master/packages/%40secretlint/secretlint-rule-openai/README.md#OPENAI_TOKEN", + "data": { + "TOKEN": "sk-sUeBP9asw6GiYHXqtg70T3BlbkFJJuLwJFco90bOpU0Ntest" + } + } + ], + "sourceContent": "sk-sUeBP9asw6GiYHXqtg70T3BlbkFJJuLwJFco90bOpU0Ntest\n", + "sourceContentType": "text" +} \ No newline at end of file diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ok.valid/input.txt b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ok.valid/input.txt new file mode 100644 index 000000000..6cba92669 --- /dev/null +++ b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ok.valid/input.txt @@ -0,0 +1 @@ +sk-sUeBP9asw6GiYHXqtg70abcdefghJuLwJFco90bOpU0Ntest diff --git a/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ok.valid/output.json b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ok.valid/output.json new file mode 100644 index 000000000..ffe419f20 --- /dev/null +++ b/packages/@secretlint/secretlint-rule-preset-recommend/test/snapshots/secretlint-rule-openai/ok.valid/output.json @@ -0,0 +1,6 @@ +{ + "filePath": "[SNAPSHOT]/ok.valid/input.txt", + "messages": [], + "sourceContent": "sk-sUeBP9asw6GiYHXqtg70abcdefghJuLwJFco90bOpU0Ntest\n", + "sourceContentType": "text" +} \ No newline at end of file