detect-secrets 0.0.0-development

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 ADDED
@@ -0,0 +1,196 @@
1
+ {
2
+ "name": "detect-secrets",
3
+ "version": "0.0.0-development",
4
+ "description": "A developer-friendly secrets detection tool for CI and pre-commit hooks based on Yelp's detect-secrets",
5
+ "bin": {
6
+ "detect-secrets-launcher": "./bin/detect-secrets-launcher.js"
7
+ },
8
+ "engines": {
9
+ "npm": ">=11.10.0",
10
+ "node": ">=24.0.0"
11
+ },
12
+ "scripts": {
13
+ "lint": "eslint .",
14
+ "lint:fix": "eslint . --fix",
15
+ "format": "prettier-standard '**/*.js'",
16
+ "test": "jest",
17
+ "test:watch": "jest --watch",
18
+ "coverage:view": "open-cli coverage/lcov-report/index.html",
19
+ "commit": "git-cz",
20
+ "docs": "npm run docs:code && npm run docs:api",
21
+ "docs:api": "doxdox *.js --layout bootstrap --output docs/index.html",
22
+ "docs:code": "docco *.js --output docs/code",
23
+ "build": "echo \"No build step configured\"",
24
+ "lint:markdown": "markdownlint -c .github/.markdownlint.yml '**/**.md'",
25
+ "version": "changeset version",
26
+ "release": "changeset publish"
27
+ },
28
+ "author": {
29
+ "name": "Liran Tal",
30
+ "email": "liran.tal@gmail.com",
31
+ "url": "https://github.com/lirantal"
32
+ },
33
+ "license": "Apache-2.0",
34
+ "keywords": [
35
+ "secrets",
36
+ "precommit",
37
+ "leak",
38
+ "git",
39
+ "credentials",
40
+ "yelp",
41
+ "detect-secrets"
42
+ ],
43
+ "homepage": "https://github.com/lirantal/detect-secrets",
44
+ "bugs": {
45
+ "url": "https://github.com/lirantal/detect-secrets/issues"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/lirantal/detect-secrets.git"
50
+ },
51
+ "dependencies": {
52
+ "debug": "^4.3.3",
53
+ "which": "^2.0.2"
54
+ },
55
+ "devDependencies": {
56
+ "@commitlint/cli": "^7.2.1",
57
+ "@commitlint/config-conventional": "^7.1.2",
58
+ "babel-eslint": "^10.0.1",
59
+ "babel-plugin-syntax-async-functions": "^6.13.0",
60
+ "babel-plugin-transform-regenerator": "^6.26.0",
61
+ "babel-preset-env": "^1.6.1",
62
+ "babel-preset-es2015": "^6.24.1",
63
+ "commitizen": "^2.9.5",
64
+ "cz-conventional-changelog": "^1.2.0",
65
+ "docco": "^0.9.2",
66
+ "doxdox": "^2.0.1",
67
+ "eslint": "^5.10.0",
68
+ "eslint-config-standard": "^12.0.0",
69
+ "eslint-plugin-import": "^2.14.0",
70
+ "eslint-plugin-jest": "^22.1.2",
71
+ "eslint-plugin-node": "^8.0.0",
72
+ "eslint-plugin-promise": "^4.0.1",
73
+ "eslint-plugin-security": "^1.4.0",
74
+ "eslint-plugin-standard": "^4.0.0",
75
+ "husky": "^1.2.1",
76
+ "jest": "23.6",
77
+ "lint-staged": "^8.1.0",
78
+ "opn-cli": "^3.1.0",
79
+ "prettier-standard": "^8.0.1",
80
+ "@changesets/changelog-github": "^0.6.0",
81
+ "@changesets/cli": "^2.31.0",
82
+ "markdownlint-cli": "0.49.1",
83
+ "semantic-release": "25.0.9"
84
+ },
85
+ "jest": {
86
+ "testEnvironment": "node",
87
+ "verbose": true,
88
+ "notify": true,
89
+ "collectCoverage": true,
90
+ "coverageThreshold": {
91
+ "global": {
92
+ "branches": 80,
93
+ "functions": 80,
94
+ "lines": 80,
95
+ "statements": 80
96
+ }
97
+ },
98
+ "testPathIgnorePatterns": [
99
+ "/__tests__/.*/__fixtures__/.*"
100
+ ],
101
+ "collectCoverageFrom": [
102
+ "index.js",
103
+ "src/**/*.{js,ts}"
104
+ ],
105
+ "testMatch": [
106
+ "**/*.test.js"
107
+ ]
108
+ },
109
+ "husky": {
110
+ "hooks": {
111
+ "commit-msg": "commitlint --env HUSKY_GIT_PARAMS",
112
+ "pre-commit": "lint-staged",
113
+ "post-merge": "npm install",
114
+ "pre-push": "npm run lint && npm run test"
115
+ }
116
+ },
117
+ "lint-staged": {
118
+ "linters": {
119
+ "**/*.js": [
120
+ "prettier-standard",
121
+ "git add"
122
+ ]
123
+ }
124
+ },
125
+ "commitlint": {
126
+ "extends": [
127
+ "@commitlint/config-conventional"
128
+ ]
129
+ },
130
+ "config": {
131
+ "commitizen": {
132
+ "path": "./node_modules/cz-conventional-changelog"
133
+ }
134
+ },
135
+ "standard": {
136
+ "env": [
137
+ "jest"
138
+ ],
139
+ "parser": "babel-eslint",
140
+ "ignore": [
141
+ "**/out/"
142
+ ]
143
+ },
144
+ "eslintIgnore": [
145
+ "coverage/**"
146
+ ],
147
+ "eslintConfig": {
148
+ "env": {
149
+ "node": true,
150
+ "es6": true,
151
+ "jest": true
152
+ },
153
+ "plugins": [
154
+ "import",
155
+ "standard",
156
+ "node",
157
+ "security",
158
+ "jest"
159
+ ],
160
+ "extends": [
161
+ "standard",
162
+ "plugin:node/recommended"
163
+ ],
164
+ "rules": {
165
+ "no-process-exit": "warn",
166
+ "jest/no-disabled-tests": "error",
167
+ "jest/no-focused-tests": "error",
168
+ "jest/no-identical-title": "error",
169
+ "node/no-unsupported-features": "off",
170
+ "node/no-unpublished-require": "off",
171
+ "security/detect-non-literal-fs-filename": "error",
172
+ "security/detect-unsafe-regex": "error",
173
+ "security/detect-buffer-noassert": "error",
174
+ "security/detect-child-process": "error",
175
+ "security/detect-disable-mustache-escape": "error",
176
+ "security/detect-eval-with-expression": "error",
177
+ "security/detect-no-csrf-before-method-override": "error",
178
+ "security/detect-non-literal-regexp": "error",
179
+ "security/detect-object-injection": "warn",
180
+ "security/detect-possible-timing-attacks": "error",
181
+ "security/detect-pseudoRandomBytes": "error",
182
+ "space-before-function-paren": "off",
183
+ "object-curly-spacing": "off"
184
+ },
185
+ "parserOptions": {
186
+ "ecmaVersion": 8,
187
+ "ecmaFeatures": {
188
+ "impliedStrict": true
189
+ }
190
+ }
191
+ },
192
+ "publishConfig": {
193
+ "provenance": true,
194
+ "access": "public"
195
+ }
196
+ }
package/src/cli.js ADDED
@@ -0,0 +1,26 @@
1
+ /* eslint-disable security/detect-child-process */
2
+ /* eslint-disable no-process-exit */
3
+ 'use strict'
4
+
5
+ const {isExecutableAvailableInPath, executeStrategy} = require('../src/strategies')
6
+
7
+ function start(executableStrategies) {
8
+ let strategyExitCode = 0
9
+ let strategiesInvoked = false
10
+ executableStrategies.forEach(strategy => {
11
+ const strategyExists = isExecutableAvailableInPath(strategy.filePath)
12
+ if (strategyExists && !strategiesInvoked) {
13
+ strategiesInvoked = true
14
+ strategyExitCode = executeStrategy(strategy)
15
+ }
16
+ })
17
+
18
+ return {
19
+ strategyExitCode,
20
+ strategiesInvoked
21
+ }
22
+ }
23
+
24
+ module.exports = {
25
+ start
26
+ }
@@ -0,0 +1,63 @@
1
+ /* eslint-disable security/detect-child-process */
2
+ /* eslint-disable no-process-exit */
3
+ 'use strict'
4
+
5
+ const ChildProcess = require('child_process')
6
+ const debug = require('debug')('detect-secrets')
7
+ const which = require('which')
8
+
9
+ function isExecutableAvailableInPath(executable) {
10
+ debug(`checking if the executable ${executable} exists`)
11
+ let resolved
12
+ try {
13
+ resolved = which.sync(executable)
14
+ debug(`found executable ${executable} at: ${resolved}`)
15
+ } catch (error) {
16
+ debug(error)
17
+ }
18
+
19
+ if (!resolved) {
20
+ return false
21
+ }
22
+
23
+ return true
24
+ }
25
+
26
+ function executeStrategy(strategy) {
27
+ let hookCommandArguments = process.argv.slice(2)
28
+ debug(
29
+ `received ${hookCommandArguments.length} command arguments: ${JSON.stringify(
30
+ hookCommandArguments
31
+ )}`
32
+ )
33
+
34
+ if (strategy.prefixCommandArguments && strategy.prefixCommandArguments.length > 0) {
35
+ hookCommandArguments = strategy.prefixCommandArguments.concat(hookCommandArguments)
36
+ }
37
+
38
+ debug(`executing [${strategy.filePath}] with command arguments:`)
39
+ debug(hookCommandArguments)
40
+
41
+ const spawnResult = ChildProcess.spawnSync(strategy.filePath, hookCommandArguments, {
42
+ shell: true
43
+ })
44
+
45
+ debug(`exited with code: ${spawnResult.status}`)
46
+ console.log(spawnResult.stdout.toString('utf-8'))
47
+ console.error(spawnResult.stderr.toString('utf-8'))
48
+
49
+ const stderr = spawnResult.stderr.toString('utf-8')
50
+ const stringFound = stderr.match(/The baseline file was updated/g)
51
+ if (stringFound) {
52
+ // force a 0 status code as this isn't an actual error
53
+ // ref: https://github.com/Yelp/detect-secrets/issues/212
54
+ return 0
55
+ }
56
+
57
+ return spawnResult.status
58
+ }
59
+
60
+ module.exports = {
61
+ isExecutableAvailableInPath,
62
+ executeStrategy
63
+ }