@kaynooo/env-tools 0.7.0 → 0.7.2
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/ev.js +48 -9
- package/dist/redact.js +5 -1
- package/package.json +1 -1
package/dist/ev.js
CHANGED
|
@@ -784,14 +784,57 @@ var WORD_BREAKS = /[^a-zA-Z\d]+|(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/;
|
|
|
784
784
|
function isSecretName(name) {
|
|
785
785
|
return SECRET_PART.test(name) || name.split(WORD_BREAKS).some((word) => SECRET_WORDS.has(word.toLowerCase()));
|
|
786
786
|
}
|
|
787
|
+
// ../kit/src/sessions.ts
|
|
788
|
+
var {Glob } = globalThis.Bun;
|
|
789
|
+
var SESSION_FILES = new Glob("*.json");
|
|
790
|
+
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
787
791
|
// package.json
|
|
788
|
-
var version = "0.7.
|
|
792
|
+
var version = "0.7.2";
|
|
789
793
|
|
|
790
794
|
// src/commands/audit.ts
|
|
791
795
|
import { stat as stat4 } from "fs/promises";
|
|
792
796
|
import { relative, resolve } from "path";
|
|
793
797
|
import process7 from "process";
|
|
794
798
|
|
|
799
|
+
// ../kit/src/shell.ts
|
|
800
|
+
var SEPARATORS = new Set([`
|
|
801
|
+
`, ";", "|"]);
|
|
802
|
+
var PLAIN_BREAKERS = new Set(["<", ">", "(", ")", "&", "|"]);
|
|
803
|
+
var GLOB_CHARS = new Set(["*", "?", "["]);
|
|
804
|
+
var COMMENT_PREFIXES = new Set([";", "&", "|", "(", ")"]);
|
|
805
|
+
var SAFE_WORD = /^[\w@%+=:,./-]+$/;
|
|
806
|
+
var DOUBLE_QUOTED_ESCAPES = new Set(["$", "`", '"', "\\"]);
|
|
807
|
+
var KEYWORDS = new Set(["then", "do", "else", "if", "elif", "while", "until", "!", "{", "}"]);
|
|
808
|
+
var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ash", "ksh"]);
|
|
809
|
+
var COMMAND_STRING_PROGRAMS = new Set([...SHELLS, "su", "runuser"]);
|
|
810
|
+
var SHELL_VALUE_OPTIONS = new Set(["-o", "-O", "--rcfile", "--init-file"]);
|
|
811
|
+
var PRINTERS = new Set(["echo", "printf"]);
|
|
812
|
+
var FIND_EXEC = new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
813
|
+
function wrapper(short = "", long = [], operands = 0) {
|
|
814
|
+
return { short, long, operands };
|
|
815
|
+
}
|
|
816
|
+
var WRAPPERS = new Map([
|
|
817
|
+
["command", wrapper()],
|
|
818
|
+
["builtin", wrapper()],
|
|
819
|
+
["nohup", wrapper()],
|
|
820
|
+
["setsid", wrapper()],
|
|
821
|
+
["busybox", wrapper()],
|
|
822
|
+
["exec", wrapper("a")],
|
|
823
|
+
["time", wrapper("fo", ["--format", "--output"])],
|
|
824
|
+
["env", wrapper("uCS", ["--unset", "--chdir", "--split-string", "--argv0"])],
|
|
825
|
+
["sudo", wrapper("ughpCTrtUDR", ["--user", "--group", "--host", "--prompt", "--close-from", "--command-timeout", "--role", "--type", "--other-user", "--chdir", "--chroot"])],
|
|
826
|
+
["doas", wrapper("uC")],
|
|
827
|
+
["timeout", wrapper("sk", ["--signal", "--kill-after"], 1)],
|
|
828
|
+
["nice", wrapper("n", ["--adjustment"])],
|
|
829
|
+
["ionice", wrapper("cnpPu", ["--class", "--classdata", "--pid", "--pgid", "--uid"])],
|
|
830
|
+
["stdbuf", wrapper("ioe", ["--input", "--output", "--error"])],
|
|
831
|
+
["chroot", wrapper("", ["--userspec", "--groups"], 1)],
|
|
832
|
+
["xargs", wrapper("IndsEaPL", ["--max-args", "--max-procs", "--max-chars", "--delimiter", "--arg-file", "--eof", "--max-lines", "--process-slot-var"])]
|
|
833
|
+
]);
|
|
834
|
+
function shellQuote(word) {
|
|
835
|
+
return SAFE_WORD.test(word) && !word.startsWith("=") ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
836
|
+
}
|
|
837
|
+
|
|
795
838
|
// src/audit.ts
|
|
796
839
|
import { readdir as readdir2, stat as stat2 } from "fs/promises";
|
|
797
840
|
import { dirname as dirname2, join as join2 } from "path";
|
|
@@ -1513,7 +1556,6 @@ var options = {
|
|
|
1513
1556
|
json: jsonOption("the findings and the folders it could not read"),
|
|
1514
1557
|
fix: { type: "boolean", description: "move inline compose secrets into a .env and shut other accounts out" }
|
|
1515
1558
|
};
|
|
1516
|
-
var SHELL_SAFE = /^[\w./-]+$/;
|
|
1517
1559
|
var MAX_UNREAD_LISTED = 3;
|
|
1518
1560
|
var CHECKS = {
|
|
1519
1561
|
same: "docker compose config resolves the same",
|
|
@@ -1528,9 +1570,6 @@ async function isFolder(path) {
|
|
|
1528
1570
|
return false;
|
|
1529
1571
|
}
|
|
1530
1572
|
}
|
|
1531
|
-
function quoted2(path) {
|
|
1532
|
-
return SHELL_SAFE.test(path) ? path : `'${path.replaceAll("'", "'\\''")}'`;
|
|
1533
|
-
}
|
|
1534
1573
|
function shown(path) {
|
|
1535
1574
|
return path.startsWith(`${process7.cwd()}/`) ? relative(process7.cwd(), path) : path;
|
|
1536
1575
|
}
|
|
@@ -1549,9 +1588,9 @@ async function fixAll(exposed, json) {
|
|
|
1549
1588
|
...fix === undefined || fix.moved.length === 0 ? [] : [`moved ${fix.moved.join(", ")} into ${shown(fix.env)}`],
|
|
1550
1589
|
...fix?.left.map(({ key, why }) => `left ${key} in place: ${why}`) ?? [],
|
|
1551
1590
|
...fix?.check === undefined ? [] : [CHECKS[fix.check]],
|
|
1552
|
-
...open.map((file) => `another account owns ${file === path ? "it" : shown(file)}, so it stays readable: sudo chmod go-rwx ${
|
|
1591
|
+
...open.map((file) => `another account owns ${file === path ? "it" : shown(file)}, so it stays readable: sudo chmod go-rwx ${shellQuote(shown(file))}`),
|
|
1553
1592
|
...readable && !open.includes(path) ? ["now unreadable by other accounts"] : [],
|
|
1554
|
-
...tracked ? [`tracked by git: git rm --cached ${
|
|
1593
|
+
...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown(path))}, then ignore it`] : []
|
|
1555
1594
|
];
|
|
1556
1595
|
console.log(`${shown(path)}
|
|
1557
1596
|
${lines.join(`
|
|
@@ -1593,8 +1632,8 @@ async function audit2(args) {
|
|
|
1593
1632
|
const sudo = uid !== undefined && uid !== 0 && (await stat4(path)).uid !== uid ? "sudo " : "";
|
|
1594
1633
|
const problems = [
|
|
1595
1634
|
...secrets === undefined ? [] : [`writes out ${secrets.join(", ")}: ev audit --fix moves the values into a .env beside it`],
|
|
1596
|
-
...readable ? [group === true ? `readable by its group or an ACL: ${sudo}chmod go-rwx ${
|
|
1597
|
-
...tracked ? [`tracked by git: git rm --cached ${
|
|
1635
|
+
...readable ? [group === true ? `readable by its group or an ACL: ${sudo}chmod go-rwx ${shellQuote(shown(path))}` : `readable by any account: ${sudo}chmod o-rwx ${shellQuote(shown(path))}`] : [],
|
|
1636
|
+
...tracked ? [`tracked by git: git rm --cached ${shellQuote(shown(path))}, then ignore it`] : []
|
|
1598
1637
|
];
|
|
1599
1638
|
console.log(`${shown(path)}
|
|
1600
1639
|
${problems.join(`
|
package/dist/redact.js
CHANGED
|
@@ -784,8 +784,12 @@ var WORD_BREAKS = /[^a-zA-Z\d]+|(?<=[a-z\d])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/;
|
|
|
784
784
|
function isSecretName(name) {
|
|
785
785
|
return SECRET_PART.test(name) || name.split(WORD_BREAKS).some((word) => SECRET_WORDS.has(word.toLowerCase()));
|
|
786
786
|
}
|
|
787
|
+
// ../kit/src/sessions.ts
|
|
788
|
+
var {Glob } = globalThis.Bun;
|
|
789
|
+
var SESSION_FILES = new Glob("*.json");
|
|
790
|
+
var ACCOUNT_DIRS = new Glob("*/sessions");
|
|
787
791
|
// package.json
|
|
788
|
-
var version = "0.7.
|
|
792
|
+
var version = "0.7.2";
|
|
789
793
|
|
|
790
794
|
// src/files.ts
|
|
791
795
|
import { chmod, chown, readdir, realpath, rename, rm, stat, writeFile } from "fs/promises";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaynooo/env-tools",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.2",
|
|
5
5
|
"description": "ev lists and edits .env files with secrets masked, redact masks secrets in any piped output.",
|
|
6
6
|
"author": "Kaynooo <contact@kaynooo.fr>",
|
|
7
7
|
"license": "MIT",
|