@dotenvx/dotenvx 1.39.1 → 1.40.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/CHANGELOG.md +13 -1
- package/LICENSE +9 -1
- package/README.md +54 -1
- package/package.json +1 -1
- package/src/cli/actions/ext/scan.js +7 -3
- package/src/lib/helpers/dotenvParse.js +13 -3
- package/src/lib/helpers/isFullyEncrypted.js +14 -5
- package/src/lib/services/precommit.js +14 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.
|
|
5
|
+
[Unreleased](https://github.com/dotenvx/dotenvx/compare/v1.40.1...main)
|
|
6
|
+
|
|
7
|
+
## [1.40.1](https://github.com/dotenvx/dotenvx/compare/v1.40.0...v1.40.1)
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
* Patch `ext scan` command ([#570](https://github.com/dotenvx/dotenvx/pull/570))
|
|
12
|
+
|
|
13
|
+
## [1.40.0](https://github.com/dotenvx/dotenvx/compare/v1.39.1...v1.40.0)
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
* Smarter `ext precommit` and `ext prebuild` – catch duplicate KEYs in the same .env file where one is mistakenly left unencrypted ([#567](https://github.com/dotenvx/dotenvx/pull/567))
|
|
6
18
|
|
|
7
19
|
## [1.39.1](https://github.com/dotenvx/dotenvx/compare/v1.39.0...v1.39.1)
|
|
8
20
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
BSD 3-Clause License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2024,
|
|
3
|
+
Copyright (c) 2024, Dotenvx LLC
|
|
4
4
|
|
|
5
5
|
Redistribution and use in source and binary forms, with or without
|
|
6
6
|
modification, are permitted provided that the following conditions are met:
|
|
@@ -26,3 +26,11 @@ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
26
26
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
27
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
28
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
Dotenvx is an Open Source project licensed under the BSD 3-Clause above.
|
|
33
|
+
|
|
34
|
+
Dotenvx Pro is source-available with a commercial-friendly license. You can find
|
|
35
|
+
the full commercial license in `COMMERCIAL-LICENSE.txt`. See https://dotenvx.com
|
|
36
|
+
for features and purchasing options.
|
package/README.md
CHANGED
|
@@ -796,6 +796,59 @@ Advanced CLI commands.
|
|
|
796
796
|
Hello World
|
|
797
797
|
```
|
|
798
798
|
|
|
799
|
+
</details>
|
|
800
|
+
* <details><summary>`run` - Multiline</summary><br>
|
|
801
|
+
|
|
802
|
+
Dotenvx supports multiline values. This is particularly useful in conjunction with Docker - which [does not support multiline values](https://stackoverflow.com/questions/50299617/set-multiline-environment-variable-with-dockerfile/79578348#79578348).
|
|
803
|
+
|
|
804
|
+
```ini
|
|
805
|
+
# .env
|
|
806
|
+
MULTILINE_PEM="-----BEGIN PUBLIC KEY-----
|
|
807
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnNl1tL3QjKp3DZWM0T3u
|
|
808
|
+
LgGJQwu9WqyzHKZ6WIA5T+7zPjO1L8l3S8k8YzBrfH4mqWOD1GBI8Yjq2L1ac3Y/
|
|
809
|
+
bTdfHN8CmQr2iDJC0C6zY8YV93oZB3x0zC/LPbRYpF8f6OqX1lZj5vo2zJZy4fI/
|
|
810
|
+
kKcI5jHYc8VJq+KCuRZrvn+3V+KuL9tF9v8ZgjF2PZbU+LsCy5Yqg1M8f5Jp5f6V
|
|
811
|
+
u4QuUoobAgMBAAE=
|
|
812
|
+
-----END PUBLIC KEY-----"
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
```js
|
|
816
|
+
// index.js
|
|
817
|
+
console.log('MULTILINE_PEM', process.env.MULTILINE_PEM)
|
|
818
|
+
```
|
|
819
|
+
|
|
820
|
+
```sh
|
|
821
|
+
$ dotenvx run -- node index.js
|
|
822
|
+
MULTILINE_PEM -----BEGIN PUBLIC KEY-----
|
|
823
|
+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnNl1tL3QjKp3DZWM0T3u
|
|
824
|
+
LgGJQwu9WqyzHKZ6WIA5T+7zPjO1L8l3S8k8YzBrfH4mqWOD1GBI8Yjq2L1ac3Y/
|
|
825
|
+
bTdfHN8CmQr2iDJC0C6zY8YV93oZB3x0zC/LPbRYpF8f6OqX1lZj5vo2zJZy4fI/
|
|
826
|
+
kKcI5jHYc8VJq+KCuRZrvn+3V+KuL9tF9v8ZgjF2PZbU+LsCy5Yqg1M8f5Jp5f6V
|
|
827
|
+
u4QuUoobAgMBAAE=
|
|
828
|
+
-----END PUBLIC KEY-----
|
|
829
|
+
```
|
|
830
|
+
|
|
831
|
+
</details>
|
|
832
|
+
* <details><summary>`run` - Contextual Help</summary><br>
|
|
833
|
+
|
|
834
|
+
Unlike other dotenv libraries, dotenvx attempts to unblock you with contextual help.
|
|
835
|
+
|
|
836
|
+
For example, when missing a custom .env file:
|
|
837
|
+
|
|
838
|
+
```sh
|
|
839
|
+
$ dotenvx run -f .env.missing -- echo $HELLO
|
|
840
|
+
[MISSING_ENV_FILE] missing .env.missing file (/Users/scottmotte/Code/dotenvx/playground/apr-16/.env.missing)
|
|
841
|
+
[MISSING_ENV_FILE] https://github.com/dotenvx/dotenvx/issues/484 and re-run [dotenvx run -- echo]
|
|
842
|
+
```
|
|
843
|
+
|
|
844
|
+
or when missing a KEY:
|
|
845
|
+
|
|
846
|
+
```sh
|
|
847
|
+
$ echo "HELLO=World" > .env
|
|
848
|
+
$ dotenvx get GOODBYE
|
|
849
|
+
[MISSING_KEY] missing GOODBYE key
|
|
850
|
+
```
|
|
851
|
+
|
|
799
852
|
</details>
|
|
800
853
|
* <details><summary>`run` - multiple `-f` flags</summary><br>
|
|
801
854
|
|
|
@@ -2289,7 +2342,7 @@ Use dotenvx directly in code.
|
|
|
2289
2342
|
|
|
2290
2343
|
### Pro 🏆
|
|
2291
2344
|
|
|
2292
|
-
*Secrets Management – Done Right.
|
|
2345
|
+
*Secrets Management – Done Right. Encrypted, Cloaked, Secrets as Code.*
|
|
2293
2346
|
|
|
2294
2347
|
* <details><summary>`pro keypair`</summary><br>
|
|
2295
2348
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const childProcess = require('child_process')
|
|
2
2
|
|
|
3
3
|
const { logger } = require('./../../../shared/logger')
|
|
4
|
+
const chomp = require('./../../../lib/helpers/chomp')
|
|
4
5
|
|
|
5
6
|
function scan () {
|
|
6
7
|
const options = this.opts()
|
|
@@ -17,11 +18,14 @@ function scan () {
|
|
|
17
18
|
return
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
let output = ''
|
|
20
22
|
try {
|
|
21
|
-
|
|
22
|
-
logger.blank(output)
|
|
23
|
+
output = childProcess.execSync('gitleaks detect --no-banner --verbose 2>&1').toString() // gitleaks sends exit code 1 but puts data on stdout for failures, so we catch later and resurface the stdout
|
|
24
|
+
logger.blank(chomp(output))
|
|
23
25
|
} catch (error) {
|
|
24
|
-
|
|
26
|
+
if (error.stdout) {
|
|
27
|
+
console.error(chomp(error.stdout.toString()))
|
|
28
|
+
}
|
|
25
29
|
|
|
26
30
|
process.exit(1)
|
|
27
31
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// historical dotenv.parse - https://github.com/motdotla/dotenv)
|
|
2
2
|
const LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg
|
|
3
3
|
|
|
4
|
-
function dotenvParse (src, skipExpandForDoubleQuotes = false, skipConvertingWindowsNewlines = false) {
|
|
4
|
+
function dotenvParse (src, skipExpandForDoubleQuotes = false, skipConvertingWindowsNewlines = false, collectAllValues = false) {
|
|
5
5
|
const obj = {}
|
|
6
6
|
|
|
7
7
|
// Convert buffer to string
|
|
@@ -35,8 +35,18 @@ function dotenvParse (src, skipExpandForDoubleQuotes = false, skipConvertingWind
|
|
|
35
35
|
value = value.replace(/\\t/g, '\t') // tabs
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
if (collectAllValues) {
|
|
39
|
+
// handle scenario where user mistakenly includes plaintext duplicate in .env:
|
|
40
|
+
//
|
|
41
|
+
// # .env
|
|
42
|
+
// HELLO="World"
|
|
43
|
+
// HELLO="enrypted:1234"
|
|
44
|
+
obj[key] = obj[key] || []
|
|
45
|
+
obj[key].push(value)
|
|
46
|
+
} else {
|
|
47
|
+
// Add to object
|
|
48
|
+
obj[key] = value
|
|
49
|
+
}
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
return obj
|
|
@@ -3,12 +3,21 @@ const isEncrypted = require('./isEncrypted')
|
|
|
3
3
|
const isPublicKey = require('./isPublicKey')
|
|
4
4
|
|
|
5
5
|
function isFullyEncrypted (src) {
|
|
6
|
-
const parsed = dotenvParse(src)
|
|
6
|
+
const parsed = dotenvParse(src, false, false, true) // collect all values
|
|
7
7
|
|
|
8
|
-
for (const [key,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (const [key, values] of Object.entries(parsed)) {
|
|
9
|
+
// handle scenario where user mistakenly includes plaintext duplicate in .env:
|
|
10
|
+
//
|
|
11
|
+
// # .env
|
|
12
|
+
// HELLO="World"
|
|
13
|
+
// HELLO="enrypted:1234"
|
|
14
|
+
//
|
|
15
|
+
// key => [value1, ...]
|
|
16
|
+
for (const value of values) {
|
|
17
|
+
const result = isEncrypted(value) || isPublicKey(key, value)
|
|
18
|
+
if (!result) {
|
|
19
|
+
return false
|
|
20
|
+
}
|
|
12
21
|
}
|
|
13
22
|
}
|
|
14
23
|
|
|
@@ -93,11 +93,24 @@ class Precommit {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
_isInGitRepo () {
|
|
97
|
+
try {
|
|
98
|
+
childProcess.execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' })
|
|
99
|
+
return true
|
|
100
|
+
} catch {
|
|
101
|
+
return false
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
96
105
|
_isFileToBeCommitted (filePath) {
|
|
97
106
|
try {
|
|
107
|
+
if (!this._isInGitRepo()) {
|
|
108
|
+
// consider file to be committed if there is an error (not a git repo)
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
|
|
98
112
|
const output = childProcess.execSync('git diff HEAD --name-only').toString()
|
|
99
113
|
const files = output.split('\n')
|
|
100
|
-
|
|
101
114
|
return files.includes(filePath)
|
|
102
115
|
} catch (error) {
|
|
103
116
|
// consider file to be committed if there is an error (not using git)
|