@dotenvx/dotenvx 2.38.1 → 3.0.0-beta.1
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 +186 -3315
- package/bin/dotenvx.cjs +34 -0
- package/config.cjs +1 -0
- package/config.d.ts +1 -0
- package/config.mjs +2 -0
- package/index.cjs +139 -0
- package/index.d.ts +66 -0
- package/index.mjs +3 -0
- package/lib/cli.cjs +43 -0
- package/lib/native-package.cjs +21 -0
- package/lib/platforms.cjs +18 -0
- package/{src/lib/helpers/redactOutput.js → lib/redactOutput.cjs} +2 -48
- package/lib/redaction.cjs +64 -0
- package/lib/validateOptions.cjs +57 -0
- package/native.cjs +23 -0
- package/package.json +57 -65
- package/CHANGELOG.md +0 -2727
- package/src/cli/actions/armor/down.js +0 -38
- package/src/cli/actions/armor/invite.js +0 -21
- package/src/cli/actions/armor/move.js +0 -43
- package/src/cli/actions/armor/open.js +0 -28
- package/src/cli/actions/armor/pull.js +0 -38
- package/src/cli/actions/armor/push.js +0 -38
- package/src/cli/actions/armor/status.js +0 -7
- package/src/cli/actions/armor/up.js +0 -38
- package/src/cli/actions/check.js +0 -78
- package/src/cli/actions/curl.js +0 -71
- package/src/cli/actions/decrypt.js +0 -119
- package/src/cli/actions/del.js +0 -54
- package/src/cli/actions/doctor.js +0 -22
- package/src/cli/actions/encrypt.js +0 -104
- package/src/cli/actions/ext/genexample.js +0 -36
- package/src/cli/actions/ext/gitignore.js +0 -106
- package/src/cli/actions/ext/prebuild.js +0 -7
- package/src/cli/actions/ext/precommit.js +0 -38
- package/src/cli/actions/ext/scan.js +0 -33
- package/src/cli/actions/feedback.js +0 -42
- package/src/cli/actions/get.js +0 -128
- package/src/cli/actions/init.js +0 -67
- package/src/cli/actions/keychain/down.js +0 -30
- package/src/cli/actions/keychain/pull.js +0 -30
- package/src/cli/actions/keychain/push.js +0 -30
- package/src/cli/actions/keychain/up.js +0 -30
- package/src/cli/actions/keypair.js +0 -84
- package/src/cli/actions/login.js +0 -64
- package/src/cli/actions/logout.js +0 -37
- package/src/cli/actions/ls.js +0 -76
- package/src/cli/actions/policy.js +0 -14
- package/src/cli/actions/primitivesCheck.js +0 -32
- package/src/cli/actions/primitivesProfile.js +0 -15
- package/src/cli/actions/primitivesRedact.js +0 -19
- package/src/cli/actions/protect.js +0 -75
- package/src/cli/actions/protectDocker.js +0 -30
- package/src/cli/actions/protectProcess.js +0 -126
- package/src/cli/actions/protectStdin.js +0 -80
- package/src/cli/actions/run.js +0 -203
- package/src/cli/actions/set.js +0 -103
- package/src/cli/actions/settings/device.js +0 -23
- package/src/cli/actions/settings/hostname.js +0 -20
- package/src/cli/actions/settings/off.js +0 -14
- package/src/cli/actions/settings/on.js +0 -14
- package/src/cli/actions/settings/path.js +0 -20
- package/src/cli/actions/settings/token.js +0 -23
- package/src/cli/actions/settings/username.js +0 -20
- package/src/cli/actions/update.js +0 -15
- package/src/cli/commandAction.js +0 -16
- package/src/cli/commands/armor.js +0 -129
- package/src/cli/commands/custody.js +0 -45
- package/src/cli/commands/ext.js +0 -88
- package/src/cli/commands/fileOptions.js +0 -22
- package/src/cli/commands/native.js +0 -54
- package/src/cli/commands/primitives.js +0 -73
- package/src/cli/commands/settings.js +0 -63
- package/src/cli/dotenvx.js +0 -443
- package/src/cli/help.js +0 -179
- package/src/db/device.js +0 -67
- package/src/db/session.js +0 -330
- package/src/lib/api/getAccount.js +0 -32
- package/src/lib/api/getConnectionResources.js +0 -21
- package/src/lib/api/getTeamConnections.js +0 -27
- package/src/lib/api/getTeamServices.js +0 -23
- package/src/lib/api/getTeams.js +0 -28
- package/src/lib/api/postArmorDown.js +0 -48
- package/src/lib/api/postArmorMove.js +0 -48
- package/src/lib/api/postArmorPull.js +0 -48
- package/src/lib/api/postArmorPush.js +0 -48
- package/src/lib/api/postArmorUp.js +0 -53
- package/src/lib/api/postConnectionKeypair.js +0 -23
- package/src/lib/api/postFeedback.js +0 -31
- package/src/lib/api/postLogout.js +0 -34
- package/src/lib/api/postOauthDeviceCode.js +0 -38
- package/src/lib/api/postOauthToken.js +0 -35
- package/src/lib/api/postTeamInvitation.js +0 -28
- package/src/lib/api/teamConnectionSetup.js +0 -31
- package/src/lib/config.d.ts +0 -1
- package/src/lib/config.js +0 -1
- package/src/lib/conventions/environment.js +0 -27
- package/src/lib/conventions/filepaths.js +0 -9
- package/src/lib/conventions/keynames.js +0 -38
- package/src/lib/custodians/index.js +0 -75
- package/src/lib/custodians/local/bitwarden.js +0 -165
- package/src/lib/custodians/local/file.js +0 -18
- package/src/lib/custodians/local/native/backend.js +0 -56
- package/src/lib/custodians/local/native/index.js +0 -28
- package/src/lib/custodians/local/native/store.js +0 -24
- package/src/lib/custodians/local/onepassword.js +0 -149
- package/src/lib/custodians/managed/armor/index.js +0 -14
- package/src/lib/custodians/managed/armor/store.js +0 -48
- package/src/lib/custodians/resolveLocalKey.js +0 -67
- package/src/lib/decryptors/armor/index.js +0 -23
- package/src/lib/decryptors/decryptor-worker.js +0 -6
- package/src/lib/decryptors/index.js +0 -69
- package/src/lib/envfile/discovery/discoverEnvFiles.js +0 -29
- package/src/lib/envfile/discovery/extractEnvKeys.js +0 -173
- package/src/lib/envfile/discovery/scanSource.js +0 -79
- package/src/lib/envfile/parsing/formatEnvfileSyntaxError.js +0 -24
- package/src/lib/envfile/parsing/readEnvfile.js +0 -43
- package/src/lib/envfile/parsing/resolveEnvfilePath.js +0 -5
- package/src/lib/envfile/rendering/normalizeEnvfile.js +0 -53
- package/src/lib/envfile/rendering/previewEnvfile.js +0 -43
- package/src/lib/envfile/rendering/renderEnvfile.js +0 -30
- package/src/lib/envfile/validation/diagnosticLocation.js +0 -29
- package/src/lib/envfile/validation/protectEnvfile.js +0 -40
- package/src/lib/envfile/validation/validateEnvfile.js +0 -14
- package/src/lib/events/backends/armor.js +0 -31
- package/src/lib/events/background.js +0 -59
- package/src/lib/events/catalog.js +0 -14
- package/src/lib/events/cli.js +0 -40
- package/src/lib/events/delivery.js +0 -89
- package/src/lib/events/index.js +0 -73
- package/src/lib/events/metadata.js +0 -25
- package/src/lib/events/sdk.js +0 -44
- package/src/lib/events/worker.js +0 -29
- package/src/lib/events/workerEnvironment.js +0 -14
- package/src/lib/helpers/armoredKeyDisplay.js +0 -10
- package/src/lib/helpers/arrayToTree.js +0 -27
- package/src/lib/helpers/buildApiError.js +0 -19
- package/src/lib/helpers/buildCommandEnvs.js +0 -40
- package/src/lib/helpers/buildConfigEnvs.js +0 -13
- package/src/lib/helpers/buildEnvs.js +0 -24
- package/src/lib/helpers/buildOauthError.js +0 -14
- package/src/lib/helpers/canonicalEnvFilename.js +0 -13
- package/src/lib/helpers/catchAndLog.js +0 -16
- package/src/lib/helpers/checklist.js +0 -50
- package/src/lib/helpers/chomp.js +0 -5
- package/src/lib/helpers/colorDepth.js +0 -23
- package/src/lib/helpers/conventions.js +0 -28
- package/src/lib/helpers/createElapsedStatus.js +0 -17
- package/src/lib/helpers/createProtectSpinner.js +0 -13
- package/src/lib/helpers/createSpinner.js +0 -40
- package/src/lib/helpers/cryptography/decryptKeyValue.js +0 -50
- package/src/lib/helpers/cryptography/index.js +0 -7
- package/src/lib/helpers/cryptography/isDotenvPublicKey.js +0 -7
- package/src/lib/helpers/cryptography/isPlainKey.js +0 -7
- package/src/lib/helpers/cryptography/mutateKeysSrc.js +0 -22
- package/src/lib/helpers/cryptography/mutateSrc.js +0 -24
- package/src/lib/helpers/custodySelect.js +0 -25
- package/src/lib/helpers/decryptDeviceValue.js +0 -7
- package/src/lib/helpers/detectEncoding.js +0 -22
- package/src/lib/helpers/detectEncodingSync.js +0 -22
- package/src/lib/helpers/dotenvOptionPaths.js +0 -25
- package/src/lib/helpers/dotenvPrivateKeyNames.js +0 -7
- package/src/lib/helpers/enclavedHint.js +0 -11
- package/src/lib/helpers/encryptDeviceValue.js +0 -7
- package/src/lib/helpers/envResolution/determine.js +0 -49
- package/src/lib/helpers/envResolution/index.js +0 -8
- package/src/lib/helpers/errors.js +0 -374
- package/src/lib/helpers/escape.js +0 -6
- package/src/lib/helpers/execute.js +0 -12
- package/src/lib/helpers/executeCommand.js +0 -208
- package/src/lib/helpers/executeDynamic.js +0 -86
- package/src/lib/helpers/executeExtension.js +0 -39
- package/src/lib/helpers/filterKeys.js +0 -15
- package/src/lib/helpers/findEnvFiles.js +0 -25
- package/src/lib/helpers/formatCode.js +0 -11
- package/src/lib/helpers/fsx.js +0 -110
- package/src/lib/helpers/guessPrivateKeyFilename.js +0 -15
- package/src/lib/helpers/hasPlaintextSecrets.js +0 -7
- package/src/lib/helpers/http.js +0 -14
- package/src/lib/helpers/installPrecommitHook.js +0 -82
- package/src/lib/helpers/installProtectFilter.js +0 -57
- package/src/lib/helpers/installProtectIgnore.js +0 -27
- package/src/lib/helpers/isPublicKey.js +0 -3
- package/src/lib/helpers/isTeamRequiredError.js +0 -10
- package/src/lib/helpers/jsonToEnv.js +0 -7
- package/src/lib/helpers/keypairMetadata.js +0 -90
- package/src/lib/helpers/kits/sample.js +0 -5
- package/src/lib/helpers/linuxSecretService.js +0 -52
- package/src/lib/helpers/listenForOpenKey.js +0 -46
- package/src/lib/helpers/logProtectedFiles.js +0 -9
- package/src/lib/helpers/logSetSummary.js +0 -21
- package/src/lib/helpers/macosKeychain.js +0 -52
- package/src/lib/helpers/mask.js +0 -22
- package/src/lib/helpers/maskEnvSrc.js +0 -15
- package/src/lib/helpers/maskProcessedEnvs.js +0 -29
- package/src/lib/helpers/matchesStoredKey.js +0 -5
- package/src/lib/helpers/nativeStoreError.js +0 -10
- package/src/lib/helpers/normalizeDotenvConfigConvention.js +0 -13
- package/src/lib/helpers/normalizeDotenvConfigIgnore.js +0 -18
- package/src/lib/helpers/normalizeDotenvConfigPath.js +0 -14
- package/src/lib/helpers/normalizeDotenvConfigQuiet.js +0 -13
- package/src/lib/helpers/normalizeToken.js +0 -5
- package/src/lib/helpers/openUrl.js +0 -7
- package/src/lib/helpers/packageJson.js +0 -3
- package/src/lib/helpers/parseWithDecryptor.js +0 -115
- package/src/lib/helpers/plaintextKeys.js +0 -9
- package/src/lib/helpers/precommitEnvPatterns.js +0 -1
- package/src/lib/helpers/prependPublicKey.js +0 -17
- package/src/lib/helpers/preserveShebang.js +0 -16
- package/src/lib/helpers/prompts.js +0 -169
- package/src/lib/helpers/protectSettings.js +0 -64
- package/src/lib/helpers/ptyCommand.js +0 -27
- package/src/lib/helpers/readEnvKey.js +0 -32
- package/src/lib/helpers/redact.js +0 -9
- package/src/lib/helpers/redactProcessOutput.js +0 -58
- package/src/lib/helpers/redactedValues.js +0 -29
- package/src/lib/helpers/removeDynamicHelpSection.js +0 -21
- package/src/lib/helpers/removeEnvKey.js +0 -51
- package/src/lib/helpers/removeLegacyProtectFilter.js +0 -43
- package/src/lib/helpers/removeOptionsHelpParts.js +0 -59
- package/src/lib/helpers/resolveBitwardenPassword.js +0 -165
- package/src/lib/helpers/resolveDirectoryFilepath.js +0 -16
- package/src/lib/helpers/resolveEnvKeysFile.js +0 -11
- package/src/lib/helpers/resolveHome.js +0 -12
- package/src/lib/helpers/resolveOnePassword.js +0 -82
- package/src/lib/helpers/sanitizeCommandForMetadata.js +0 -64
- package/src/lib/helpers/selectConnection.js +0 -51
- package/src/lib/helpers/selectConnectionResource.js +0 -41
- package/src/lib/helpers/selectEnvfileEnvs.js +0 -29
- package/src/lib/helpers/selectKeyStorage.js +0 -140
- package/src/lib/helpers/statusReporter.js +0 -8
- package/src/lib/helpers/storeKeyStorage.js +0 -39
- package/src/lib/helpers/teamChoicesFromMeta.js +0 -8
- package/src/lib/helpers/truncate.js +0 -10
- package/src/lib/helpers/uninstallPrecommitHook.js +0 -67
- package/src/lib/helpers/upsertEnvKey.js +0 -62
- package/src/lib/helpers/windowsCredentialManager.js +0 -166
- package/src/lib/main.d.ts +0 -509
- package/src/lib/main.js +0 -468
- package/src/lib/providers/index.js +0 -86
- package/src/lib/providers/native/index.js +0 -2
- package/src/lib/resolvers/envs.js +0 -416
- package/src/lib/resolvers/get.js +0 -87
- package/src/lib/resolvers/keypair.js +0 -135
- package/src/lib/resolvers/ls.js +0 -69
- package/src/lib/services/armorDown.js +0 -73
- package/src/lib/services/armorInvite.js +0 -36
- package/src/lib/services/armorMove.js +0 -55
- package/src/lib/services/armorOpen.js +0 -26
- package/src/lib/services/armorPull.js +0 -73
- package/src/lib/services/armorPush.js +0 -66
- package/src/lib/services/armorUp.js +0 -71
- package/src/lib/services/custodyTransfer.js +0 -50
- package/src/lib/services/doctor.js +0 -93
- package/src/lib/services/genexample.js +0 -112
- package/src/lib/services/init.js +0 -83
- package/src/lib/services/keychainDown.js +0 -60
- package/src/lib/services/keychainPull.js +0 -46
- package/src/lib/services/keychainPush.js +0 -51
- package/src/lib/services/keychainUp.js +0 -72
- package/src/lib/services/login.js +0 -51
- package/src/lib/services/logout.js +0 -26
- package/src/lib/services/prebuild.js +0 -91
- package/src/lib/services/precommit.js +0 -144
- package/src/lib/services/validate.js +0 -57
- package/src/lib/transforms/decrypt.js +0 -98
- package/src/lib/transforms/del.js +0 -58
- package/src/lib/transforms/encrypt.js +0 -164
- package/src/lib/transforms/set.js +0 -144
- package/src/shared/colors.js +0 -67
- package/src/shared/logger.js +0 -148
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const { scan } = require('@dotenvx/primitives')
|
|
3
|
-
const Errors = require('./errors')
|
|
4
|
-
|
|
5
|
-
function ignored (error, options) {
|
|
6
|
-
return (options.ignore || []).includes(error.code)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function readEnvKey (key, filepath, options = {}) {
|
|
10
|
-
let src
|
|
11
|
-
try {
|
|
12
|
-
src = fs.readFileSync(filepath)
|
|
13
|
-
} catch (_error) {
|
|
14
|
-
const error = new Errors({ envFilepath: filepath }).missingEnvFile()
|
|
15
|
-
if (ignored(error, options)) return undefined
|
|
16
|
-
if (options.strict) throw error
|
|
17
|
-
return undefined
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const { parsed } = scan(src)
|
|
21
|
-
const values = parsed[key]
|
|
22
|
-
const value = values ? values[values.length - 1] : undefined
|
|
23
|
-
if (value === undefined) {
|
|
24
|
-
const error = new Errors({ key }).missingKey()
|
|
25
|
-
if (ignored(error, options)) return undefined
|
|
26
|
-
if (options.strict) throw error
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return value
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = readEnvKey
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const fs = require('node:fs')
|
|
2
|
-
const { createRedactor } = require('./redactOutput')
|
|
3
|
-
|
|
4
|
-
const stateKey = Symbol.for('dotenvx.redactProcessOutput')
|
|
5
|
-
|
|
6
|
-
// Keep a possible secret prefix between writes, including split UTF-8 buffers.
|
|
7
|
-
function install (stream, secrets) {
|
|
8
|
-
if (stream[stateKey]) {
|
|
9
|
-
stream[stateKey].add(secrets)
|
|
10
|
-
return
|
|
11
|
-
}
|
|
12
|
-
const redactor = createRedactor(secrets)
|
|
13
|
-
const write = stream.write.bind(stream)
|
|
14
|
-
const end = stream.end.bind(stream)
|
|
15
|
-
const consume = (chunk, encoding) => redactor.write(typeof chunk === 'string' ? Buffer.from(chunk, encoding) : chunk)
|
|
16
|
-
// Do not release an unfinished secret prefix at shutdown.
|
|
17
|
-
const flush = () => redactor.flush(true)
|
|
18
|
-
|
|
19
|
-
stream.write = function (chunk, encoding, callback) {
|
|
20
|
-
if (typeof encoding === 'function') {
|
|
21
|
-
callback = encoding
|
|
22
|
-
encoding = undefined
|
|
23
|
-
}
|
|
24
|
-
if (!(typeof chunk === 'string' || chunk instanceof Uint8Array) || (callback !== undefined && typeof callback !== 'function')) {
|
|
25
|
-
return write(chunk, encoding, callback)
|
|
26
|
-
}
|
|
27
|
-
return write(consume(chunk, encoding), 'utf8', callback)
|
|
28
|
-
}
|
|
29
|
-
stream.end = function (chunk, encoding, callback) {
|
|
30
|
-
if (typeof chunk === 'function') {
|
|
31
|
-
callback = chunk
|
|
32
|
-
chunk = undefined
|
|
33
|
-
} else if (typeof encoding === 'function') {
|
|
34
|
-
callback = encoding
|
|
35
|
-
encoding = undefined
|
|
36
|
-
}
|
|
37
|
-
const output = chunk === undefined || chunk === null ? '' : consume(chunk, encoding)
|
|
38
|
-
return end(output + flush(), 'utf8', callback)
|
|
39
|
-
}
|
|
40
|
-
stream[stateKey] = redactor
|
|
41
|
-
process.on('beforeExit', () => {
|
|
42
|
-
const output = flush()
|
|
43
|
-
if (output) write(output)
|
|
44
|
-
})
|
|
45
|
-
process.on('exit', () => {
|
|
46
|
-
const output = flush()
|
|
47
|
-
if (output) {
|
|
48
|
-
try { fs.writeSync(stream.fd, output) } catch { /* The destination may already be closed. */ }
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
module.exports = function redactProcessOutput (secrets) {
|
|
54
|
-
const values = secrets.filter(value => typeof value === 'string' && value.length > 0)
|
|
55
|
-
if (!values.length) return
|
|
56
|
-
install(process.stdout, values)
|
|
57
|
-
install(process.stderr, values)
|
|
58
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
const isPublicKey = require('./isPublicKey')
|
|
2
|
-
|
|
3
|
-
function redactedValues (processedEnvs, schema, processEnv = {}, legacyRedact = false) {
|
|
4
|
-
if (!schema?.exists && !legacyRedact) return []
|
|
5
|
-
const result = new Set()
|
|
6
|
-
|
|
7
|
-
const rows = [...(processedEnvs || [])]
|
|
8
|
-
if (schema?.exists) {
|
|
9
|
-
rows.push({ injected: Object.fromEntries(Object.keys(schema.keys).map(key => [key, processEnv[key]])) })
|
|
10
|
-
}
|
|
11
|
-
for (const processedEnv of rows) {
|
|
12
|
-
const values = {
|
|
13
|
-
...(processedEnv.injected || {}),
|
|
14
|
-
...(processedEnv.existed || {})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
for (const [key, value] of Object.entries(values)) {
|
|
18
|
-
const redacted = schema?.exists ? (schema.keys[key]?.stdio.redacted ?? true) : !isPublicKey(key)
|
|
19
|
-
if (!redacted) continue
|
|
20
|
-
if (value === undefined || value === null || value === '') continue
|
|
21
|
-
|
|
22
|
-
result.add(`${value}`)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return [...result]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
module.exports = redactedValues
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Remove Arguments section from help text. example:
|
|
2
|
-
// Arguments:
|
|
3
|
-
// command dynamic command
|
|
4
|
-
// args dynamic command arguments
|
|
5
|
-
|
|
6
|
-
function removeDynamicHelpSection (lines) {
|
|
7
|
-
let argumentsHelpIndex
|
|
8
|
-
for (let i = 0; i < lines.length; i++) {
|
|
9
|
-
if (lines[i] === 'Arguments:') {
|
|
10
|
-
argumentsHelpIndex = i
|
|
11
|
-
break
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
if (argumentsHelpIndex) {
|
|
15
|
-
lines.splice(argumentsHelpIndex, 4) // remove Arguments and the following 3 lines
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return lines
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
module.exports = removeDynamicHelpSection
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
const fsx = require('./fsx')
|
|
4
|
-
|
|
5
|
-
function escapeForRegex (value) {
|
|
6
|
-
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
function removeEnvKey (key, keysFilepath = '.env.keys') {
|
|
10
|
-
const resolvedKeysFilepath = path.resolve(keysFilepath)
|
|
11
|
-
|
|
12
|
-
if (!fs.existsSync(resolvedKeysFilepath)) {
|
|
13
|
-
return {
|
|
14
|
-
changed: false,
|
|
15
|
-
key,
|
|
16
|
-
filepath: keysFilepath
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const src = fs.readFileSync(resolvedKeysFilepath, 'utf8')
|
|
21
|
-
const eol = src.includes('\r\n') ? '\r\n' : '\n'
|
|
22
|
-
const keyPattern = new RegExp(`^\\s*(?:export\\s+)?${escapeForRegex(key)}\\s*=`)
|
|
23
|
-
const envKeyPattern = /^\s*(?:export\s+)?[A-Za-z_][A-Za-z0-9_]*\s*=/
|
|
24
|
-
const lines = src.length > 0 ? src.split(/\r?\n/) : []
|
|
25
|
-
|
|
26
|
-
while (lines.length > 0 && lines[lines.length - 1] === '') {
|
|
27
|
-
lines.pop()
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const nextLines = lines.filter((line) => !keyPattern.test(line))
|
|
31
|
-
const changed = nextLines.length !== lines.length
|
|
32
|
-
|
|
33
|
-
if (changed) {
|
|
34
|
-
const hasRemainingKeys = nextLines.some((line) => envKeyPattern.test(line))
|
|
35
|
-
|
|
36
|
-
if (hasRemainingKeys) {
|
|
37
|
-
const nextSrc = `${nextLines.join(eol)}${eol}`
|
|
38
|
-
fsx.writeKeyFileSync(resolvedKeysFilepath, nextSrc)
|
|
39
|
-
} else {
|
|
40
|
-
fs.rmSync(resolvedKeysFilepath, { force: true })
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
changed,
|
|
46
|
-
key,
|
|
47
|
-
filepath: keysFilepath
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
module.exports = removeEnvKey
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const fs = require('fs')
|
|
3
|
-
const fsx = require('./fsx')
|
|
4
|
-
const patterns = require('./precommitEnvPatterns')
|
|
5
|
-
const { execFileSync } = require('child_process')
|
|
6
|
-
|
|
7
|
-
function isLegacy (command) {
|
|
8
|
-
const tokens = command.match(/'[^']*'|"[^"]*"|[^\s'";&|`$<>]+/g) || []
|
|
9
|
-
if (tokens.join(' ') !== command.trim()) return false
|
|
10
|
-
const args = tokens.map(token => /^['"]/.test(token) ? token.slice(1, -1) : token)
|
|
11
|
-
if (args.slice(-3).join(' ') !== 'precommit --clean %f') return false
|
|
12
|
-
const executable = args.slice(0, -3)
|
|
13
|
-
return (executable.length === 1 && path.basename(executable[0]) === 'dotenvx') ||
|
|
14
|
-
(executable.length === 2 && ['node', 'node.exe'].includes(path.basename(executable[0])) && path.basename(executable[1]) === 'dotenvx.js')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function removeLegacyProtectFilter (directory = process.cwd()) {
|
|
18
|
-
const git = (...args) => execFileSync('git', args, { cwd: directory, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim()
|
|
19
|
-
let commands
|
|
20
|
-
try {
|
|
21
|
-
commands = git('config', '--local', '--get-all', 'filter.dotenvx.clean').split('\n')
|
|
22
|
-
} catch (error) {
|
|
23
|
-
if (error.status === 128) return
|
|
24
|
-
if (error.status !== 1) throw error
|
|
25
|
-
commands = []
|
|
26
|
-
}
|
|
27
|
-
// Only remove an entirely recognized legacy registration, never custom shell commands.
|
|
28
|
-
if (!commands.every(isLegacy)) return
|
|
29
|
-
if (commands.length) git('config', '--local', '--unset-all', 'filter.dotenvx.clean')
|
|
30
|
-
try {
|
|
31
|
-
if (commands.length) git('config', '--local', '--fixed-value', '--unset-all', 'filter.dotenvx.required', 'true')
|
|
32
|
-
} catch (error) {
|
|
33
|
-
if (error.status !== 5) throw error
|
|
34
|
-
}
|
|
35
|
-
const attributesPath = path.resolve(directory, git('rev-parse', '--git-path', 'info/attributes'))
|
|
36
|
-
if (!fs.existsSync(attributesPath) || fs.lstatSync(attributesPath).isSymbolicLink()) return
|
|
37
|
-
const oldRules = patterns.map(pattern => `${pattern.includes('/') ? '**/' : ''}${pattern} filter=dotenvx`)
|
|
38
|
-
const source = fs.readFileSync(attributesPath, 'utf8')
|
|
39
|
-
const updated = source.split(/(?<=\n)/).map(line => oldRules.includes(line.replace(/\r?\n$/, '')) ? line.replace('filter=dotenvx', 'filter=dotenvx.protect') : line).join('')
|
|
40
|
-
if (updated !== source) fsx.writeFileXSync(attributesPath, updated)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
module.exports = removeLegacyProtectFilter
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// Remove [options] from usage/command lines and hide the Options: section.
|
|
2
|
-
|
|
3
|
-
function removeOptionsSection (lines) {
|
|
4
|
-
const start = lines.indexOf('Options:')
|
|
5
|
-
if (start === -1) return
|
|
6
|
-
|
|
7
|
-
let end = start + 1
|
|
8
|
-
while (end < lines.length && lines[end] !== '' && !lines[end].endsWith(':')) {
|
|
9
|
-
end++
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// drop trailing blank line after the Options block when present
|
|
13
|
-
if (lines[end] === '') end++
|
|
14
|
-
|
|
15
|
-
lines.splice(start, end - start)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function removeOptionsHelpParts (lines) {
|
|
19
|
-
for (let i = 0; i < lines.length; i++) {
|
|
20
|
-
lines[i] = lines[i].replace(' [options]', '')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
removeOptionsSection(lines)
|
|
24
|
-
|
|
25
|
-
let commandsStart = -1
|
|
26
|
-
for (let i = 0; i < lines.length; i++) {
|
|
27
|
-
if (lines[i] === 'Commands:') {
|
|
28
|
-
commandsStart = i + 1
|
|
29
|
-
break
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (commandsStart !== -1) {
|
|
34
|
-
const commands = []
|
|
35
|
-
|
|
36
|
-
for (let i = commandsStart; i < lines.length; i++) {
|
|
37
|
-
const line = lines[i]
|
|
38
|
-
if (line === '' || line.endsWith(':')) {
|
|
39
|
-
break
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const match = line.match(/^(\s{2})(\S(?:.*\S)?)\s{2,}(\S.*)$/)
|
|
43
|
-
if (match) {
|
|
44
|
-
commands.push({ index: i, indent: match[1], command: match[2], description: match[3] })
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (commands.length > 0) {
|
|
49
|
-
const maxCommandLength = commands.reduce((max, item) => Math.max(max, item.command.length), 0)
|
|
50
|
-
for (const item of commands) {
|
|
51
|
-
lines[item.index] = `${item.indent}${item.command.padEnd(maxCommandLength + 2)}${item.description}`
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return lines
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports = removeOptionsHelpParts
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
const { execFile, execFileSync } = require('child_process')
|
|
2
|
-
const Errors = require('./errors')
|
|
3
|
-
const prompts = require('./prompts')
|
|
4
|
-
const createSpinner = require('./createSpinner')
|
|
5
|
-
const createElapsedStatus = require('./createElapsedStatus')
|
|
6
|
-
|
|
7
|
-
const FIELDS = new Set(['username', 'password', 'uri'])
|
|
8
|
-
|
|
9
|
-
function execFileAsync (command, args, options) {
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
execFile(command, args, options, (error, stdout) => {
|
|
12
|
-
if (error) return reject(error)
|
|
13
|
-
resolve(stdout)
|
|
14
|
-
})
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function isSecretReference (value) {
|
|
19
|
-
return typeof value === 'string' && value.startsWith('bw://')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function parseSecretReference (value) {
|
|
23
|
-
const reference = value.slice('bw://'.length)
|
|
24
|
-
const separatorIndex = reference.lastIndexOf('/')
|
|
25
|
-
const item = reference.slice(0, separatorIndex)
|
|
26
|
-
const field = reference.slice(separatorIndex + 1)
|
|
27
|
-
|
|
28
|
-
if (separatorIndex < 1 || !field) {
|
|
29
|
-
throw new Error('invalid Bitwarden Password Manager reference')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!FIELDS.has(field)) {
|
|
33
|
-
throw new Error(`unsupported Bitwarden Password Manager field ${field}`)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return { item, field }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function session (options) {
|
|
40
|
-
if (options.session) return options.session
|
|
41
|
-
|
|
42
|
-
if (process.stdin.isTTY && process.stderr.isTTY) {
|
|
43
|
-
createSpinner.pause()
|
|
44
|
-
const password = await prompts.password({
|
|
45
|
-
message: 'Bitwarden master password',
|
|
46
|
-
prefix: '◇',
|
|
47
|
-
separator: '='
|
|
48
|
-
}, {
|
|
49
|
-
input: process.stdin,
|
|
50
|
-
output: process.stderr
|
|
51
|
-
})
|
|
52
|
-
createSpinner.resume()
|
|
53
|
-
if (options.startStatus) options.startStatus()
|
|
54
|
-
const passwordEnv = 'DOTENVX_BITWARDEN_PASSWORD'
|
|
55
|
-
options.session = secretValue(await execFileAsync('bw', ['unlock', '--passwordenv', passwordEnv, '--raw'], {
|
|
56
|
-
encoding: 'utf8',
|
|
57
|
-
windowsHide: true,
|
|
58
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
59
|
-
env: { ...process.env, [passwordEnv]: password }
|
|
60
|
-
}))
|
|
61
|
-
return options.session
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if (!options.session) {
|
|
65
|
-
const error = new Error('Bitwarden Password Manager requires an unlocked BW_SESSION')
|
|
66
|
-
error.code = 'BW_SESSION_MISSING'
|
|
67
|
-
throw error
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function resolutionError (key, error) {
|
|
72
|
-
let message
|
|
73
|
-
if (error && error.code === 'ENOENT') {
|
|
74
|
-
message = `Bitwarden Password Manager CLI is not installed and could not resolve ${key}`
|
|
75
|
-
} else if (error && error.code === 'BW_SESSION_MISSING') {
|
|
76
|
-
message = `Bitwarden Password Manager is locked and could not resolve ${key}; run 'export BW_SESSION="$(bw unlock --raw)"'`
|
|
77
|
-
} else if (error && error.message && error.message.startsWith('unsupported Bitwarden Password Manager field')) {
|
|
78
|
-
message = `${error.message} for ${key}`
|
|
79
|
-
} else if (error && error.message === 'invalid Bitwarden Password Manager reference') {
|
|
80
|
-
message = `invalid Bitwarden Password Manager reference for ${key}`
|
|
81
|
-
} else {
|
|
82
|
-
message = `Bitwarden Password Manager CLI failed to resolve ${key}`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return new Errors({
|
|
86
|
-
message,
|
|
87
|
-
help: 'fix: [https://bitwarden.com/help/cli/]'
|
|
88
|
-
}).bitwardenFailed()
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
function secretValue (stdout) {
|
|
92
|
-
return stdout.replace(/\r?\n$/, '')
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async function resolveBitwardenPassword (parsed, options = {}) {
|
|
96
|
-
const errors = []
|
|
97
|
-
const unresolved = []
|
|
98
|
-
options.session = options.session || process.env.BW_SESSION
|
|
99
|
-
let stopStatus
|
|
100
|
-
const startStatus = () => {
|
|
101
|
-
if (!stopStatus) stopStatus = createElapsedStatus(options.onStatus, 'awaiting bitwarden')
|
|
102
|
-
}
|
|
103
|
-
options.startStatus = startStatus
|
|
104
|
-
|
|
105
|
-
try {
|
|
106
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
107
|
-
if (!isSecretReference(value)) continue
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
const { item, field } = parseSecretReference(value)
|
|
111
|
-
if (options.session) startStatus()
|
|
112
|
-
const bwSession = await session(options)
|
|
113
|
-
const stdout = await execFileAsync('bw', ['get', field, item], {
|
|
114
|
-
encoding: 'utf8',
|
|
115
|
-
windowsHide: true,
|
|
116
|
-
env: { ...process.env, BW_SESSION: bwSession }
|
|
117
|
-
})
|
|
118
|
-
parsed[key] = secretValue(stdout)
|
|
119
|
-
} catch (error) {
|
|
120
|
-
if (error && error.code === 'PROMPT_CANCELLED') throw error
|
|
121
|
-
errors.push(resolutionError(key, error))
|
|
122
|
-
unresolved.push(key)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
} finally {
|
|
126
|
-
if (stopStatus) {
|
|
127
|
-
stopStatus()
|
|
128
|
-
if (options.onStatus) options.onStatus('injecting')
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return { errors, unresolved }
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function resolveBitwardenPasswordSync (parsed) {
|
|
136
|
-
const errors = []
|
|
137
|
-
const unresolved = []
|
|
138
|
-
|
|
139
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
140
|
-
if (!isSecretReference(value)) continue
|
|
141
|
-
|
|
142
|
-
try {
|
|
143
|
-
const { item, field } = parseSecretReference(value)
|
|
144
|
-
if (!process.env.BW_SESSION) {
|
|
145
|
-
const error = new Error('Bitwarden Password Manager requires an unlocked BW_SESSION')
|
|
146
|
-
error.code = 'BW_SESSION_MISSING'
|
|
147
|
-
throw error
|
|
148
|
-
}
|
|
149
|
-
const stdout = execFileSync('bw', ['get', field, item], {
|
|
150
|
-
encoding: 'utf8',
|
|
151
|
-
windowsHide: true,
|
|
152
|
-
stdio: ['ignore', 'pipe', 'pipe']
|
|
153
|
-
})
|
|
154
|
-
parsed[key] = secretValue(stdout)
|
|
155
|
-
} catch (error) {
|
|
156
|
-
errors.push(resolutionError(key, error))
|
|
157
|
-
unresolved.push(key)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return { errors, unresolved }
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
module.exports = resolveBitwardenPassword
|
|
165
|
-
module.exports.sync = resolveBitwardenPasswordSync
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const fs = require('fs')
|
|
2
|
-
const path = require('path')
|
|
3
|
-
|
|
4
|
-
function resolveDirectoryFilepath (filepath, filename) {
|
|
5
|
-
try {
|
|
6
|
-
if (fs.statSync(filepath).isDirectory()) {
|
|
7
|
-
return path.join(filepath, filename)
|
|
8
|
-
}
|
|
9
|
-
} catch (_error) {
|
|
10
|
-
// Preserve missing paths so the existing error handling can report them.
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return filepath
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = resolveDirectoryFilepath
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const resolveDirectoryFilepath = require('./resolveDirectoryFilepath')
|
|
2
|
-
|
|
3
|
-
function resolveEnvKeysFile (envKeysFile) {
|
|
4
|
-
if (Array.isArray(envKeysFile)) {
|
|
5
|
-
return envKeysFile.map(filepath => resolveDirectoryFilepath(filepath, '.env.keys'))
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return envKeysFile && resolveDirectoryFilepath(envKeysFile, '.env.keys')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
module.exports = resolveEnvKeysFile
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
const { execFile, execFileSync } = require('child_process')
|
|
2
|
-
const Errors = require('./errors')
|
|
3
|
-
const createElapsedStatus = require('./createElapsedStatus')
|
|
4
|
-
|
|
5
|
-
function execFileAsync (command, args, options) {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
execFile(command, args, options, (error, stdout) => {
|
|
8
|
-
if (error) return reject(error)
|
|
9
|
-
resolve(stdout)
|
|
10
|
-
})
|
|
11
|
-
})
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function isSecretReference (value) {
|
|
15
|
-
return typeof value === 'string' && value.startsWith('op://')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function resolutionError (key, error) {
|
|
19
|
-
const message = error && error.code === 'ENOENT'
|
|
20
|
-
? `1Password CLI is not installed and could not resolve ${key}`
|
|
21
|
-
: `1Password CLI failed to resolve ${key}`
|
|
22
|
-
|
|
23
|
-
return new Errors({ message }).onePasswordFailed()
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function resolveOnePassword (parsed, options = {}) {
|
|
27
|
-
const errors = []
|
|
28
|
-
const unresolved = []
|
|
29
|
-
const hasSecretReferences = Object.values(parsed).some(isSecretReference)
|
|
30
|
-
const stopStatus = hasSecretReferences
|
|
31
|
-
? createElapsedStatus(options.onStatus, 'awaiting 1password')
|
|
32
|
-
: null
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
36
|
-
if (!isSecretReference(value)) continue
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
const stdout = await execFileAsync('op', ['read', value, '--no-newline'], {
|
|
40
|
-
encoding: 'utf8',
|
|
41
|
-
windowsHide: true
|
|
42
|
-
})
|
|
43
|
-
parsed[key] = stdout
|
|
44
|
-
} catch (error) {
|
|
45
|
-
errors.push(resolutionError(key, error))
|
|
46
|
-
unresolved.push(key)
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
} finally {
|
|
50
|
-
if (stopStatus) {
|
|
51
|
-
stopStatus()
|
|
52
|
-
if (options.onStatus) options.onStatus('injecting')
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return { errors, unresolved }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function resolveOnePasswordSync (parsed) {
|
|
60
|
-
const errors = []
|
|
61
|
-
const unresolved = []
|
|
62
|
-
|
|
63
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
64
|
-
if (!isSecretReference(value)) continue
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
parsed[key] = execFileSync('op', ['read', value, '--no-newline'], {
|
|
68
|
-
encoding: 'utf8',
|
|
69
|
-
windowsHide: true,
|
|
70
|
-
stdio: ['ignore', 'pipe', 'pipe']
|
|
71
|
-
})
|
|
72
|
-
} catch (error) {
|
|
73
|
-
errors.push(resolutionError(key, error))
|
|
74
|
-
unresolved.push(key)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return { errors, unresolved }
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
module.exports = resolveOnePassword
|
|
82
|
-
module.exports.sync = resolveOnePasswordSync
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
function commandParts (command) {
|
|
2
|
-
if (Array.isArray(command)) {
|
|
3
|
-
return command.map(arg => `${arg}`)
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const parts = []
|
|
7
|
-
const src = `${command}`
|
|
8
|
-
const regex = /"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+)/g
|
|
9
|
-
let match
|
|
10
|
-
|
|
11
|
-
while ((match = regex.exec(src)) !== null) {
|
|
12
|
-
parts.push(match[1] || match[2] || match[3])
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return parts
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function flagName (part) {
|
|
19
|
-
if (!part.startsWith('--')) return null
|
|
20
|
-
return part.slice(2).split('=')[0].toLowerCase()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function isSecretFlag (part) {
|
|
24
|
-
const name = flagName(part)
|
|
25
|
-
if (!name) return false
|
|
26
|
-
if (name === 'pass' || name === 'password' || name === 'passphrase' || name === 'pwd') return true
|
|
27
|
-
|
|
28
|
-
return name.includes('token') ||
|
|
29
|
-
name.includes('password') ||
|
|
30
|
-
name.includes('secret') ||
|
|
31
|
-
name.includes('api-key') ||
|
|
32
|
-
name.includes('apikey') ||
|
|
33
|
-
name.includes('private-key')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function sanitizeCommandForMetadata (command) {
|
|
37
|
-
const parts = commandParts(command)
|
|
38
|
-
const sanitized = []
|
|
39
|
-
|
|
40
|
-
for (let i = 0; i < parts.length; i++) {
|
|
41
|
-
const part = parts[i]
|
|
42
|
-
|
|
43
|
-
if (isSecretFlag(part) && part.includes('=')) {
|
|
44
|
-
const name = part.split('=')[0]
|
|
45
|
-
sanitized.push(`${name}=[REDACTED]`)
|
|
46
|
-
continue
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (isSecretFlag(part)) {
|
|
50
|
-
sanitized.push(part)
|
|
51
|
-
if (i + 1 < parts.length) {
|
|
52
|
-
sanitized.push('[REDACTED]')
|
|
53
|
-
i++
|
|
54
|
-
}
|
|
55
|
-
continue
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
sanitized.push(part)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return sanitized.join(' ')
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
module.exports = sanitizeCommandForMetadata
|