From 06bb7dae1a54e4d696db63bcd211750f1d82033a Mon Sep 17 00:00:00 2001 From: Nicholas Deis Date: Fri, 29 Nov 2024 19:31:41 -0700 Subject: [PATCH] Add declaration files --- .npmignore | 4 +++- dist/index.d.ts | 10 ++++++++++ dist/no-pattern-match.d.ts | 3 +++ dist/regexes.d.ts | 24 ++++++++++++++++++++++++ dist/utils.d.ts | 35 +++++++++++++++++++++++++++++++++++ package.json | 9 ++++----- src/index.ts | 6 +++--- tsconfig.json | 3 ++- 8 files changed, 84 insertions(+), 10 deletions(-) create mode 100644 dist/index.d.ts create mode 100644 dist/no-pattern-match.d.ts create mode 100644 dist/regexes.d.ts create mode 100644 dist/utils.d.ts diff --git a/.npmignore b/.npmignore index 21acf7b..57e0770 100644 --- a/.npmignore +++ b/.npmignore @@ -3,4 +3,6 @@ tests/* *.log staging/* .travis.yml -.github/* \ No newline at end of file +.github/* +src/* +tsconfig.json diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..0bd8e4b --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,10 @@ +import type { Rule } from "eslint"; +declare const meta: { + name: string; + version: string; +}; +declare const rules: { + "no-pattern-match": Rule.RuleModule; + "no-secrets": Rule.RuleModule; +}; +export { meta, rules }; diff --git a/dist/no-pattern-match.d.ts b/dist/no-pattern-match.d.ts new file mode 100644 index 0000000..39352e0 --- /dev/null +++ b/dist/no-pattern-match.d.ts @@ -0,0 +1,3 @@ +import type { Rule } from "eslint"; +declare const noPatternMatch: Rule.RuleModule; +export default noPatternMatch; diff --git a/dist/regexes.d.ts b/dist/regexes.d.ts new file mode 100644 index 0000000..99ef249 --- /dev/null +++ b/dist/regexes.d.ts @@ -0,0 +1,24 @@ +/** + * From https://github.com/dxa4481/truffleHogRegexes/blob/master/truffleHogRegexes/regexes.json + */ +declare const _default: { + "Slack Token": RegExp; + "RSA private key": RegExp; + "SSH (OPENSSH) private key": RegExp; + "SSH (DSA) private key": RegExp; + "SSH (EC) private key": RegExp; + "PGP private key block": RegExp; + "Facebook Oauth": RegExp; + "Twitter Oauth": RegExp; + GitHub: RegExp; + "Google Oauth": RegExp; + "AWS API Key": RegExp; + "Heroku API Key": RegExp; + "Generic Secret": RegExp; + "Generic API Key": RegExp; + "Slack Webhook": RegExp; + "Google (GCP) Service-account": RegExp; + "Twilio API Key": RegExp; + "Password in URL": RegExp; +}; +export default _default; diff --git a/dist/utils.d.ts b/dist/utils.d.ts new file mode 100644 index 0000000..bc2e24f --- /dev/null +++ b/dist/utils.d.ts @@ -0,0 +1,35 @@ +export declare const DEFAULT_ADDTIONAL_REGEXES: {}; +type PlainObject = { + [key: string | number]: any; +}; +export declare function isPlainObject(obj: any): obj is PlainObject; +export declare function plainObjectOption(value: any, name: string, defaultValue: PlainObject): PlainObject; +export declare function validateRecordOfRegex(recordOfRegex: PlainObject): Record; +export declare function checkOptions({ tolerance, additionalRegexes, ignoreContent, ignoreModules, ignoreIdentifiers, additionalDelimiters, ignoreCase, }: { + tolerance: any; + additionalRegexes: any; + ignoreContent: any; + ignoreModules: any; + ignoreIdentifiers: any; + additionalDelimiters: any; + ignoreCase: any; +}): { + tolerance: number; + additionalRegexes: Record; + ignoreContent: RegExp[]; + ignoreModules: any; + ignoreIdentifiers: RegExp[]; + additionalDelimiters: RegExp[]; + ignoreCase: any; +}; +/** + * From https://github.com/dxa4481/truffleHog/blob/dev/truffleHog/truffleHog.py#L85 + * @param {*} str + */ +export declare function shannonEntropy(str: string): number; +export declare function isModulePathString(node: any): boolean; +export declare function getIdentifierName(node: any): false | string; +export declare const HIGH_ENTROPY = "HIGH_ENTROPY"; +export declare const PATTERN_MATCH = "PATTERN_MATCH"; +export declare const FULL_TEXT_MATCH = "FULL_TEXT_MATCH"; +export {}; diff --git a/package.json b/package.json index 220cc1c..25d9a70 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "eslint-plugin-no-secrets", - "version": "1.4.2", + "version": "2.1.0", "description": "An eslint rule that searches for potential secrets/keys in code", "main": "./dist/index.js", - "types": "index.d.ts", + "types": "./dist/index.d.ts", "scripts": { "build": "tsc", - "test": "npm run test:unit && npm run build && npm run test:staging", + "test": "npm run test:unit && npm run test:staging", "test:unit": "ts-node tests/lib/rules", - "test:staging": "node ./staging/staging.spec.js" + "test:staging": "npm run build && node ./staging/staging.spec.js" }, "keywords": [ "eslint", @@ -16,7 +16,6 @@ "security", "secure", "secrets", - "security", "lint", "eslintplugin" ], diff --git a/src/index.ts b/src/index.ts index 1edc5b3..b38d375 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import type { Rule } from "eslint"; +import type { Rule, ESLint } from "eslint"; import { getIdentifierName, shannonEntropy, @@ -34,9 +34,9 @@ function shouldIgnore(value: string, toIgnore) { return false; } -const meta = { +const meta: ESLint.Plugin["meta"] = { name: "eslint-plugin-no-secrets", - version: "1.0.0-eslint9", + version: "2.1.0", }; const noSecrets: Rule.RuleModule = { diff --git a/tsconfig.json b/tsconfig.json index bea5beb..6a96223 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,8 @@ "forceConsistentCasingInFileNames": true, "strict": false, - "skipLibCheck": true + "skipLibCheck": true, + "declaration": true }, "include": [ "./src/**/*"