@cratis/pi 7.168.0 → 7.168.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.
|
@@ -41,95 +41,69 @@ parser_failed() {
|
|
|
41
41
|
command_text="$(jq -r '.tool_input.command // empty' <<<"$input")" || parser_failed
|
|
42
42
|
[ -n "$command_text" ] || exit 0
|
|
43
43
|
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
# split of the unquoted text, so it can miss a word the awk analysis would see, never the reverse.
|
|
54
|
-
protected_target_name() {
|
|
55
|
-
local lowered base
|
|
56
|
-
[ -d "$1" ] && return 1
|
|
57
|
-
lowered="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" || return 1
|
|
58
|
-
base="${lowered##*/}"
|
|
59
|
-
case "$base" in
|
|
60
|
-
.env.example|.env.sample|.env.template|.env.dist|.env.default|.env.defaults) return 1 ;;
|
|
61
|
-
.env|.env.*|*.env|.envrc|id_rsa|id_ed25519|id_ecdsa|id_dsa|*.pem|*.key|*.p12|*.pfx|*.jks|*.keystore|*.kdbx|.netrc|.npmrc|.pgpass|.pypirc|.git-credentials|kubeconfig|*.kubeconfig|credentials|credentials.json|secrets.yaml|secrets.yml|token|token.json|tokens.json|github_token) return 0 ;;
|
|
62
|
-
esac
|
|
63
|
-
case "/$lowered" in
|
|
64
|
-
*/.kube/*|*/.aws/credentials|*/.docker/config.json|/run/secrets/*|/var/run/secrets/*) return 0 ;;
|
|
65
|
-
esac
|
|
66
|
-
return 1
|
|
67
|
-
}
|
|
68
|
-
# Follows a chain of links one step at a time (bash 3.2, BSD readlink: no readlink -f, no realpath). Returns
|
|
69
|
-
# 0 when the chain ends at a protected name or cannot be followed, 1 when it is harmless.
|
|
70
|
-
link_chain_protected() {
|
|
44
|
+
# Filesystem resolution only returns link targets. The awk classifier below judges both these targets
|
|
45
|
+
# and decoded command words, so file-name exceptions cannot diverge between the two paths.
|
|
46
|
+
IFS= read -r -d '' link_program <<'LINKS' || true
|
|
47
|
+
emit_target() {
|
|
48
|
+
[ -d "$1" ] && return 0
|
|
49
|
+
case "$1" in *'
|
|
50
|
+
'*) printf 'E\n' ;; *) printf 'P:%s\n' "$1" ;; esac
|
|
51
|
+
}
|
|
52
|
+
link_chain_targets() {
|
|
71
53
|
local current="$1" hops=0 target parent
|
|
72
54
|
while [ -L "$current" ]; do
|
|
73
55
|
hops=$((hops + 1))
|
|
74
|
-
[ "$hops" -le 16 ] || return
|
|
75
|
-
target="$(readlink -- "$current")" || return
|
|
56
|
+
[ "$hops" -le 16 ] || { printf 'E\n'; return; }
|
|
57
|
+
target="$(readlink -- "$current")" || { printf 'E\n'; return; }
|
|
76
58
|
case "$target" in
|
|
77
59
|
/*) current="$target" ;;
|
|
78
60
|
*) parent="${current%/*}"; [ "$parent" != "$current" ] || parent=.; current="$parent/$target" ;;
|
|
79
61
|
esac
|
|
80
|
-
|
|
62
|
+
emit_target "$current"
|
|
81
63
|
done
|
|
82
|
-
return 1
|
|
83
64
|
}
|
|
84
|
-
|
|
65
|
+
linked_targets_word() {
|
|
85
66
|
local word="$1" directory resolved logical
|
|
86
|
-
[ -n "$word" ] || return
|
|
67
|
+
[ -n "$word" ] || return 0
|
|
87
68
|
case "$word" in
|
|
88
|
-
--*) return
|
|
89
|
-
-?*) word="${word#-?}"; [ -n "$word" ] || return
|
|
69
|
+
--*) return 0 ;;
|
|
70
|
+
-?*) word="${word#-?}"; [ -n "$word" ] || return 0 ;;
|
|
90
71
|
esac
|
|
91
|
-
if [ -L "$word" ]; then
|
|
92
|
-
case "$word" in */*) ;; *) return
|
|
72
|
+
if [ -L "$word" ]; then link_chain_targets "$word"; return; fi
|
|
73
|
+
case "$word" in */*) ;; *) return 0 ;; esac
|
|
93
74
|
directory="${word%/*}"; [ -n "$directory" ] || directory=/
|
|
94
|
-
[ -d "$directory" ] || return
|
|
95
|
-
resolved="$(cd -P -- "$directory" 2>/dev/null && pwd -P)" || return
|
|
96
|
-
logical="$(cd -- "$directory" 2>/dev/null && pwd)" || return
|
|
97
|
-
[ "$resolved" != "$logical" ] || return
|
|
75
|
+
[ -d "$directory" ] || return 0
|
|
76
|
+
resolved="$(cd -P -- "$directory" 2>/dev/null && pwd -P)" || return 0
|
|
77
|
+
logical="$(cd -- "$directory" 2>/dev/null && pwd)" || return 0
|
|
78
|
+
[ "$resolved" != "$logical" ] || return 0
|
|
98
79
|
resolved="$resolved/${word##*/}"
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
fi
|
|
122
|
-
probe_lower="$(printf '%s' "$probe" | tr '[:upper:]' '[:lower:]')" || parser_failed
|
|
123
|
-
case "$probe_lower" in
|
|
124
|
-
*kubectl*|*printenv*|*env*|*docker*|*podman*|*"gh "*|*vault*|*pulumi*|*show-secret*|*aws*|*"az "*|*gcloud*|*kubeconfig*|*.kube*|\
|
|
125
|
-
*sh*|*extglob*|*set*|*emulate*|*'-o'*|*'+o'*|*globignore*|*export*|*declare*|*id_rsa*|*id_ed25519*|*id_ecdsa*|*id_dsa*|*.pem*|*.key*|*.p12*|*.pfx*|*.jks*|*.kdbx*|*token*|*.netrc*|*.npmrc*|\
|
|
126
|
-
*credential*|*.pgpass*|*pypirc*|*secrets*|*oc*) ;;
|
|
127
|
-
*)
|
|
128
|
-
case "$command_text" in
|
|
80
|
+
emit_target "$resolved"
|
|
81
|
+
link_chain_targets "$resolved"
|
|
82
|
+
}
|
|
83
|
+
unset CDPATH
|
|
84
|
+
cd -- "$1" 2>/dev/null || exit 0
|
|
85
|
+
shift
|
|
86
|
+
[ "$#" -le 5000 ] || { printf 'E\n'; exit 0; }
|
|
87
|
+
for link_word in "$@"; do linked_targets_word "$link_word"; done
|
|
88
|
+
LINKS
|
|
89
|
+
|
|
90
|
+
# Without a supplied working directory there are no literal links to resolve. Keep the cheap textual
|
|
91
|
+
# pre-filter, but always parse bulk-reader families: even a root operand can cover mounted secrets.
|
|
92
|
+
command_cwd="$(jq -r '.cwd // empty' <<<"$input")" || parser_failed
|
|
93
|
+
if [ -z "$command_cwd" ]; then
|
|
94
|
+
probe=${command_text//\\$'\n'/}
|
|
95
|
+
probe=${probe//[\'\"\\]/}
|
|
96
|
+
probe_lower="$(printf '%s' "$probe" | tr '[:upper:]' '[:lower:]')" || parser_failed
|
|
97
|
+
case "$probe_lower" in
|
|
98
|
+
*kubectl*|*printenv*|*env*|*docker*|*podman*|*"gh "*|*vault*|*pulumi*|*show-secret*|*aws*|*"az "*|*gcloud*|*kubeconfig*|*.kube*|\
|
|
99
|
+
*sh*|*extglob*|*set*|*emulate*|*'-o'*|*'+o'*|*globignore*|*export*|*declare*|*id_rsa*|*id_ed25519*|*id_ecdsa*|*id_dsa*|*.pem*|*.key*|*.p12*|*.pfx*|*.jks*|*.kdbx*|*token*|*.netrc*|*.npmrc*|\
|
|
100
|
+
*credential*|*.pgpass*|*pypirc*|*secrets*|*oc*|*grep*|*rg*|*ag*|*find*|*tar*|*cp*|*rsync*|*zip*|*diff*|*cd*) ;;
|
|
101
|
+
*) case "$command_text" in
|
|
129
102
|
*'$'*|*'*'*|*'?'*|*'['*|*'{'*|*'('*|*'^'*|*'~'*|*'`'*) ;;
|
|
130
103
|
*) exit 0 ;;
|
|
131
104
|
esac ;;
|
|
132
|
-
esac
|
|
105
|
+
esac
|
|
106
|
+
fi
|
|
133
107
|
|
|
134
108
|
IFS= read -r -d '' awk_program <<'AWK' || true
|
|
135
109
|
function report(what, alt) {
|
|
@@ -137,9 +111,11 @@ function report(what, alt) {
|
|
|
137
111
|
seen[what] = 1
|
|
138
112
|
reports = reports sprintf("%s\t%s\n", what, alt)
|
|
139
113
|
}
|
|
140
|
-
function enqueue(text) {
|
|
114
|
+
function enqueue(text, k) {
|
|
141
115
|
if (text == "" || queued >= 64) return
|
|
142
116
|
queue[++queued] = text
|
|
117
|
+
QUEUE_COUNT[queued] = ncd
|
|
118
|
+
for (k = 1; k <= ncd; k++) QUEUE_DIR[queued, k] = cwd_at(k)
|
|
143
119
|
}
|
|
144
120
|
function base(word) { word = tolower(word); sub(/.*\//, "", word); return word }
|
|
145
121
|
|
|
@@ -308,18 +284,23 @@ function regex_flag(w) {
|
|
|
308
284
|
return w ~ /^--(ignore-case|no-ignore-case|word-regexp|line-regexp|fixed-strings|basic-regexp|extended-regexp|perl-regexp|invert-match|line-number|no-line-number|count|files-with-matches|files-without-match|only-matching|quiet|silent|text|binary|no-messages|with-filename|no-filename|heading|no-heading|no-ignore|hidden|no-hidden|recursive|help|version|color|colour)$/
|
|
309
285
|
}
|
|
310
286
|
function regex_value(w) {
|
|
311
|
-
return w ~ /^--(file|glob|iglob|include|exclude|exclude-dir|type|type-not|type-add|type-clear|max-count|max-depth|maxdepth|max-filesize|encoding|engine|pre|pre-glob|sort|sortr|threads|replace|label|colors|after-context|before-context|context|ignore-file|path-separator|hostname-bin)$/
|
|
287
|
+
return w ~ /^--(file|glob|iglob|include|exclude|exclude-dir|type|type-not|type-add|type-clear|max-count|max-depth|maxdepth|max-filesize|encoding|engine|pre|pre-glob|sort|sortr|threads|replace|label|directories|colors|after-context|before-context|context|ignore-file|path-separator|hostname-bin)$/
|
|
312
288
|
}
|
|
313
289
|
function regex_short_flag(b, c) {
|
|
314
290
|
return c ~ /^[EFGPivwxcnNlLoqsaHIhVzuUSyZ0]$/ || (c ~ /^[rRT]$/ && b != "rg")
|
|
315
291
|
}
|
|
316
292
|
function regex_slots(A, s, n, b, k, j, w, c, explicit, ended, attached, uncertain) {
|
|
317
|
-
delete RP; delete ROPER
|
|
293
|
+
delete RP; delete ROPER; regex_input = 0
|
|
318
294
|
b = base(A[s])
|
|
319
295
|
if (A[s] == "git" && A[s + 1] == "grep") { s++; b = "grep" }
|
|
320
296
|
if (b !~ /^(grep|egrep|fgrep|rg|ag)$/) return
|
|
321
297
|
for (k = s + 1; k <= n; k++) {
|
|
322
298
|
w = A[k]
|
|
299
|
+
if (w ~ /^[0-9]*[<>]/ && tolower(substr(mask_of(A, k), 1, 1)) == "u") {
|
|
300
|
+
if (w ~ /^[0-9]*</) regex_input = 1
|
|
301
|
+
if (w ~ /^[0-9]*[<>]+&?-?$/) k++
|
|
302
|
+
continue
|
|
303
|
+
}
|
|
323
304
|
if (!ended && w == "--") { ended = 1; continue }
|
|
324
305
|
if (!ended && w ~ /^--/) {
|
|
325
306
|
if (w ~ /^--(regexp|file)(=|$)/) explicit = 1
|
|
@@ -654,9 +635,20 @@ function nonreader(A, M, n, i, w, first, read) {
|
|
|
654
635
|
}
|
|
655
636
|
return 1
|
|
656
637
|
}
|
|
638
|
+
function check_links(A, n, k, cmd, line, kind) {
|
|
639
|
+
if (ENVIRON["GS_CWD"] == "") return
|
|
640
|
+
cmd = "bash -c " shell_quote(ENVIRON["GS_LINK_PROGRAM"]) " guard-links " shell_quote(ENVIRON["GS_CWD"])
|
|
641
|
+
for (k = 1; k <= n; k++) cmd = cmd " " shell_quote(A[k])
|
|
642
|
+
while ((cmd | getline line) > 0) {
|
|
643
|
+
kind = substr(line, 1, 2) == "P:" ? sensitive_path(substr(line, 3)) : "an unresolved link target"
|
|
644
|
+
if (kind != "") report("a symbolic link resolves to " kind, "name the real non-credential file; do not read a protected file through a link")
|
|
645
|
+
}
|
|
646
|
+
if (close(cmd) != 0) report("link resolution failed", "name the real non-credential file")
|
|
647
|
+
}
|
|
657
648
|
function end_cmd( k, m, w, j, hit, exempt, path_git, paths_only, test_filter) {
|
|
658
649
|
flush_word()
|
|
659
650
|
if (nw > 0) {
|
|
651
|
+
check_links(W, nw)
|
|
660
652
|
commands++
|
|
661
653
|
delete PROBE_WORDS; PROBE_COUNT = nw
|
|
662
654
|
for (k = 1; k <= nw; k++) PROBE_WORDS[k] = W[k]
|
|
@@ -703,6 +695,7 @@ function end_cmd( k, m, w, j, hit, exempt, path_git, paths_only, test_filter)
|
|
|
703
695
|
V[++m] = w; VM[m] = WM[k]
|
|
704
696
|
}
|
|
705
697
|
if (m > 0) { check_inputs(V, 1, m); analyze(V, 1, m) }
|
|
698
|
+
nwrap = 0
|
|
706
699
|
delete W; delete WP; delete WM; delete WU; delete V; delete VM; nw = 0
|
|
707
700
|
}
|
|
708
701
|
function cmdsub(s, i, n, start, depth, c, j) {
|
|
@@ -782,6 +775,10 @@ function read_heredocs(s, i, n, h, e, line, cmp, body, hit) {
|
|
|
782
775
|
return i
|
|
783
776
|
}
|
|
784
777
|
function tokenize(s, i, n, c, c2, j, dash, delim) {
|
|
778
|
+
delete CWD; ncd = QUEUE_COUNT[qi]
|
|
779
|
+
for (i = 1; i <= ncd; i++) CWD[i] = QUEUE_DIR[qi, i]
|
|
780
|
+
effective_dir = CWD[1]; cwd_depth = 0; cwd_conditional = 0; nwrap = 0
|
|
781
|
+
clear_pipeline(); pipe_input = 0
|
|
785
782
|
n = length(s); i = 1; nw = 0; word = ""; wmask = ""; inword = 0; wquoted = 0; wplain = 0; wunquoted = 0; nheredoc = 0; hd_shell = 0; hd_interp = 0; quote_boundary = 0
|
|
786
783
|
delete W; delete WP; delete WM
|
|
787
784
|
while (i <= n) {
|
|
@@ -831,7 +828,7 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
|
|
|
831
828
|
}
|
|
832
829
|
if (c == " " || c == "\t" || c == "\r") { flush_word(); i++; continue }
|
|
833
830
|
if (c == "\n") {
|
|
834
|
-
end_cmd(); i++
|
|
831
|
+
end_cmd(); clear_pipeline(); pipe_input = 0; cwd_conditional = 0; i++
|
|
835
832
|
if (nheredoc > 0) i = read_heredocs(s, i, n)
|
|
836
833
|
continue
|
|
837
834
|
}
|
|
@@ -843,6 +840,17 @@ function tokenize(s, i, n, c, c2, j, dash, delim) {
|
|
|
843
840
|
}
|
|
844
841
|
if (c == ";" || c == "&" || c == "|" || c == "(" || c == ")") {
|
|
845
842
|
end_cmd()
|
|
843
|
+
c2 = substr(s, i + 1, 1)
|
|
844
|
+
if (c == "(") push_cwd_scope()
|
|
845
|
+
else if (c == ")") pop_cwd_scope()
|
|
846
|
+
else if (c == "|" && c2 != "|") {
|
|
847
|
+
pipe_input = 1
|
|
848
|
+
if (c2 == "&") i++
|
|
849
|
+
} else {
|
|
850
|
+
clear_pipeline(); pipe_input = 0
|
|
851
|
+
cwd_conditional = (c ~ /[&|]/ && c2 == c)
|
|
852
|
+
if (cwd_conditional) i++
|
|
853
|
+
}
|
|
846
854
|
complex = 1
|
|
847
855
|
i++; continue
|
|
848
856
|
}
|
|
@@ -986,7 +994,48 @@ function token_ok(l, b) {
|
|
|
986
994
|
if (b ~ /\.(css|scss|less)$/) return 1
|
|
987
995
|
return l ~ /(^|\/)(design|design-tokens|themes?|styles?)\//
|
|
988
996
|
}
|
|
989
|
-
function
|
|
997
|
+
function absolute_path(w, dir, parts, count, k, path, depth, segments) {
|
|
998
|
+
if (dir == "") dir = effective_dir != "" ? effective_dir : ENVIRON["GS_CWD_FALLBACK"]
|
|
999
|
+
if (w !~ /^\//) w = dir "/" w
|
|
1000
|
+
count = split(w, parts, "/")
|
|
1001
|
+
for (k = 1; k <= count; k++) {
|
|
1002
|
+
if (parts[k] == "" || parts[k] == ".") continue
|
|
1003
|
+
if (parts[k] == "..") { if (depth > 0) depth--; continue }
|
|
1004
|
+
segments[++depth] = parts[k]
|
|
1005
|
+
}
|
|
1006
|
+
for (k = 1; k <= depth; k++) path = path "/" segments[k]
|
|
1007
|
+
while (sub(/^\/proc\/(self|thread-self|[0-9]+)\/root(\/|$)/, "/", path)) {}
|
|
1008
|
+
return path == "" ? "/" : path
|
|
1009
|
+
}
|
|
1010
|
+
# All recursive roots use this matcher, including defaults and directory changes. Expansion is symbolic:
|
|
1011
|
+
# shell text is never evaluated, and patterns are intersected only with the finite mount ancestor chain.
|
|
1012
|
+
function mount_ancestor(w, m, dir, path, mount, parent, k, paths, count, home, literal) {
|
|
1013
|
+
if (w ~ /[$`]/ || m ~ /[cC]/ || dir ~ /[$`]/) return 0
|
|
1014
|
+
if (dir == "\001") return 1
|
|
1015
|
+
if (w ~ /^~/) {
|
|
1016
|
+
if (w !~ /^~(\/|$)/ || ENVIRON["HOME"] == "") return 1
|
|
1017
|
+
home = ENVIRON["HOME"]; literal = home; gsub(/./, "l", literal)
|
|
1018
|
+
w = home substr(w, 2); m = literal substr(m, 2)
|
|
1019
|
+
}
|
|
1020
|
+
resolve(w, m)
|
|
1021
|
+
count = nalt
|
|
1022
|
+
for (k = 1; k <= count; k++) paths[k] = ALT[k]
|
|
1023
|
+
for (k = 1; k <= count; k++) {
|
|
1024
|
+
if (paths[k] ~ /[\001\003]/ && w != "\001") continue
|
|
1025
|
+
if (w == "\001") return 1
|
|
1026
|
+
path = absolute_path(paths[k], dir)
|
|
1027
|
+
for (mount in SECRET_MOUNT) {
|
|
1028
|
+
parent = mount
|
|
1029
|
+
while (parent != "") {
|
|
1030
|
+
if (pattern_match(path, parent)) return 1
|
|
1031
|
+
sub(/\/[^\/]*$/, "", parent)
|
|
1032
|
+
}
|
|
1033
|
+
if (pattern_match(path, "/")) return 1
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
return 0
|
|
1037
|
+
}
|
|
1038
|
+
function sensitive_path(w, l, b, mount, normalized, k) {
|
|
990
1039
|
l = tolower(w); b = l; sub(/.*\//, "", b)
|
|
991
1040
|
if (l ~ /(^|\/)\.kube\// || b == "kubeconfig" || b ~ /\.kubeconfig$/) return "a kubeconfig"
|
|
992
1041
|
# Every name starting with .env stays protected (.env2, .envprod, .envrc.local, .env-prod); only the
|
|
@@ -1006,7 +1055,10 @@ function sensitive_path(w, l, b) {
|
|
|
1006
1055
|
if (l ~ /\.docker\/config\.json$/) return "the Docker registry credentials"
|
|
1007
1056
|
if (l ~ /(^|\/)(\.ssh|\.aws)\/?$/) return "a credential directory"
|
|
1008
1057
|
if (l ~ /\/proc\/[^\/]*\/environ$/) return "a process environment"
|
|
1009
|
-
|
|
1058
|
+
for (k = 1; k <= ncd; k++) {
|
|
1059
|
+
normalized = tolower(absolute_path(w, cwd_at(k)))
|
|
1060
|
+
for (mount in SECRET_MOUNT) if (l == mount || index(l, mount "/") == 1 || normalized == mount || index(normalized, mount "/") == 1) return "mounted secrets"
|
|
1061
|
+
}
|
|
1010
1062
|
return ""
|
|
1011
1063
|
}
|
|
1012
1064
|
|
|
@@ -1319,6 +1371,7 @@ function reader_may_recurse(A, n, i, j, w, b, ended, pattern) {
|
|
|
1319
1371
|
}
|
|
1320
1372
|
function glob_directory( text, head, dir, prior) {
|
|
1321
1373
|
dir = ENVIRON["GS_CWD"]; text = CMD
|
|
1374
|
+
if (dir == "" && recursive_search(PROBE_WORDS, 1, PROBE_COUNT)) dir = ENVIRON["GS_CWD_FALLBACK"]
|
|
1322
1375
|
if (ENVIRON["GS_GLOB_SAFE"] != "1" || dir == "" || dir !~ /^\//) return ""
|
|
1323
1376
|
if (text ~ /^[ \t]*cd([ \t]|&&|$)/) {
|
|
1324
1377
|
if (!match(text, /^[ \t]*cd[ \t]+(\047[^\047\n]+\047|"[^"$`\\\n]+"|[A-Za-z0-9_.\/@+-]+)[ \t]*&&/)) return ""
|
|
@@ -1338,6 +1391,11 @@ function glob_secret_match(a, prefix, parent, dir, script, cmd, line, count,
|
|
|
1338
1391
|
if (substr(a, length(a), 1) != "\004" || prefix == "" || prefix ~ /[^A-Za-z0-9._\/@+=,:%-]/) return "a key or certificate file"
|
|
1339
1392
|
parent = prefix; sub(/[^\/]*$/, "", parent)
|
|
1340
1393
|
dir = glob_directory()
|
|
1394
|
+
if (glob_recursive) for (k = 2; k <= PROBE_COUNT; k++) {
|
|
1395
|
+
if (PROBE_WORDS[k] ~ /^--(follow|dereference-recursive)$/ ||
|
|
1396
|
+
(base(PROBE_WORDS[1]) == "rg" && PROBE_WORDS[k] ~ /^-[^-]*L/) ||
|
|
1397
|
+
(base(PROBE_WORDS[1]) ~ /^(grep|egrep|fgrep)$/ && PROBE_WORDS[k] ~ /^-[^-]*R/)) return "a key or certificate file"
|
|
1398
|
+
}
|
|
1341
1399
|
if (dir == "" || parent ~ /(^|\/)\.\.(\/|$)/) return "a key or certificate file"
|
|
1342
1400
|
# Compare the actual directories reached under both cd modes before probing.
|
|
1343
1401
|
script = "unset GLOBIGNORE CDPATH; shopt -u failglob; shopt -s nullglob dotglob nocaseglob; " \
|
|
@@ -1347,13 +1405,20 @@ function glob_secret_match(a, prefix, parent, dir, script, cmd, line, count,
|
|
|
1347
1405
|
"probe=$parent; while [ ! -e \"$probe\" ]; do [ ! -L \"$probe\" ] || exit 3; next=${probe%/*}; " \
|
|
1348
1406
|
"[ \"$next\" != \"$probe\" ] || next=.; probe=$next; done; " \
|
|
1349
1407
|
"checked_cd \"$probe\" || exit 3; [ \"$probe\" = \"$parent\" ] || { echo OK; exit 0; }; " \
|
|
1350
|
-
"
|
|
1351
|
-
"
|
|
1352
|
-
"
|
|
1408
|
+
"scan_file() { local f=\"$1\" depth=\"$2\" child; seen=$((seen+1)); " \
|
|
1409
|
+
"[ \"$seen\" -le 20000 ] && [ \"$depth\" -le 64 ] || return 3; " \
|
|
1410
|
+
"if [ -L \"$f\" ]; then [ \"$depth\" -gt 0 ] && return 0; return 3; fi; " \
|
|
1411
|
+
"case \"$PWD/$f\" in *[!a-zA-Z0-9._/@+=,:%-]*) return 3;; esac; " \
|
|
1412
|
+
"if [ -d \"$f\" ]; then [ -r \"$f\" ] && [ -x \"$f\" ] || return 3; " \
|
|
1413
|
+
"for child in \"$f\"/*; do scan_file \"$child\" $((depth+1)) || return 3; done; " \
|
|
1414
|
+
"else [ -f \"$f\" ] || return 3; printf \"F:%s\\n\" \"$PWD/$f\"; fi; }; " \
|
|
1415
|
+
"n=0; seen=0; for f in \"$stem\"*; do n=$((n+1)); [ \"$n\" -le 200 ] && [ ! -L \"$f\" ] || exit 3; " \
|
|
1416
|
+
"if [ -d \"$f\" ] && [ \"$3\" != 1 ]; then continue; fi; " \
|
|
1417
|
+
"scan_file \"$f\" 0 || exit 3; done; echo OK"
|
|
1353
1418
|
cmd = "bash -c " shell_quote(script) " guard-glob " shell_quote(dir) " " shell_quote(prefix) " " shell_quote(glob_recursive ? "1" : "0") " 2>/dev/null"
|
|
1354
1419
|
while ((cmd | getline line) > 0) {
|
|
1355
1420
|
if (line == "OK") { ok = 1; continue }
|
|
1356
|
-
if (ok || substr(line, 1, 2) != "F:" || ++count >
|
|
1421
|
+
if (ok || substr(line, 1, 2) != "F:" || ++count > 20000) { ok = 0; break }
|
|
1357
1422
|
name = substr(line, 3); kind = sensitive_path(name)
|
|
1358
1423
|
basename = name; sub(/.*\//, "", basename)
|
|
1359
1424
|
original = prefix; sub(/[^\/]*$/, "", original); original = original basename
|
|
@@ -1675,6 +1740,164 @@ function env_program(b, p, t) {
|
|
|
1675
1740
|
if (t !~ /[^A-Za-z0-9_](env|ENV|ENVIRON|strenv|envsubst|getenv|PROCINFO|SYMTAB)[^A-Za-z0-9_]/) return
|
|
1676
1741
|
report(b " program reads the process environment, which can hold credentials", "name one non-credential variable with printenv NAME, or test existence with [ -n \"${NAME:-}\" ] && echo set")
|
|
1677
1742
|
}
|
|
1743
|
+
function recursive_search(A, s, n, k, j, b, w, c, value) {
|
|
1744
|
+
b = base(A[s])
|
|
1745
|
+
if (b == "rg" || b == "ag") return 1
|
|
1746
|
+
if (b !~ /^(grep|egrep|fgrep)$/) return 0
|
|
1747
|
+
for (k = s + 1; k <= n && A[k] != "--"; k++) {
|
|
1748
|
+
w = A[k]
|
|
1749
|
+
if (w ~ /^--(recursive|dereference-recursive)$/ || w == "--directories=recurse") return 1
|
|
1750
|
+
if (w == "--directories") { if (A[++k] == "recurse") return 1; continue }
|
|
1751
|
+
if (w ~ /^--/) { if (regex_value(w)) k++; continue }
|
|
1752
|
+
if (w !~ /^-./) continue
|
|
1753
|
+
for (j = 2; j <= length(w); j++) {
|
|
1754
|
+
c = substr(w, j, 1)
|
|
1755
|
+
if (c ~ /^[rR]$/) return 1
|
|
1756
|
+
if (index("efmABCdD", c)) {
|
|
1757
|
+
value = j < length(w) ? substr(w, j + 1) : A[++k]
|
|
1758
|
+
if (c == "d" && value == "recurse") return 1
|
|
1759
|
+
break
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
return 0
|
|
1764
|
+
}
|
|
1765
|
+
function literal_directory(w, dir) {
|
|
1766
|
+
if (w ~ /^~(\/|$)/) w = ENVIRON["HOME"] substr(w, 2)
|
|
1767
|
+
if (w == "" || w ~ /[$`*?\[{}]/ || w ~ /^[-+~]/ || w ~ /[\001\003]/) return dir
|
|
1768
|
+
return absolute_path(w, dir)
|
|
1769
|
+
}
|
|
1770
|
+
function cwd_at(k, j, dir) {
|
|
1771
|
+
dir = CWD[k]
|
|
1772
|
+
for (j = 1; j <= nwrap; j++) dir = literal_directory(WRAP_DIR[j], dir)
|
|
1773
|
+
return dir
|
|
1774
|
+
}
|
|
1775
|
+
function push_cwd_scope( k) {
|
|
1776
|
+
cwd_depth++; SAVED_COUNT[cwd_depth] = ncd; SAVED_CONDITION[cwd_depth] = cwd_conditional
|
|
1777
|
+
PIPE_SCOPE[cwd_depth] = pipe_input || (cwd_depth > 1 && PIPE_SCOPE[cwd_depth - 1])
|
|
1778
|
+
for (k = 1; k <= ncd; k++) SAVED_CWD[cwd_depth, k] = CWD[k]
|
|
1779
|
+
}
|
|
1780
|
+
function pop_cwd_scope( k) {
|
|
1781
|
+
if (cwd_depth == 0) return
|
|
1782
|
+
delete CWD; ncd = SAVED_COUNT[cwd_depth]; cwd_conditional = SAVED_CONDITION[cwd_depth]
|
|
1783
|
+
for (k = 1; k <= ncd; k++) CWD[k] = SAVED_CWD[cwd_depth, k]
|
|
1784
|
+
effective_dir = CWD[1]; cwd_depth--
|
|
1785
|
+
}
|
|
1786
|
+
function change_directory(A, s, n, b, k, j, w, dir, count, nextdir, seen) {
|
|
1787
|
+
if (b == "popd") return
|
|
1788
|
+
k = s + 1
|
|
1789
|
+
while (k <= n && A[k] ~ /^(-[LP]|--)$/) k++
|
|
1790
|
+
w = k <= n ? A[k] : ENVIRON["HOME"]
|
|
1791
|
+
for (k = 1; k <= ncd; k++) {
|
|
1792
|
+
if (cwd_conditional && !(CWD[k] in seen)) { seen[CWD[k]] = 1; nextdir[++count] = CWD[k] }
|
|
1793
|
+
dir = literal_directory(w, CWD[k])
|
|
1794
|
+
if (!(dir in seen)) { seen[dir] = 1; nextdir[++count] = dir }
|
|
1795
|
+
}
|
|
1796
|
+
delete CWD; ncd = count
|
|
1797
|
+
for (j = 1; j <= ncd; j++) CWD[j] = nextdir[j]
|
|
1798
|
+
effective_dir = CWD[1]
|
|
1799
|
+
}
|
|
1800
|
+
function clear_pipeline() {
|
|
1801
|
+
if (cwd_depth > 0 && PIPE_SCOPE[cwd_depth]) return
|
|
1802
|
+
delete PF_ROOT; delete PF_MASK; delete PF_DIR; npf = 0
|
|
1803
|
+
}
|
|
1804
|
+
function report_mount_read(w, m, dir, b) {
|
|
1805
|
+
if (mount_ancestor(w, m, dir)) report(b " recursively reads an ancestor of mounted secrets", "name only non-credential source files or an unrelated directory")
|
|
1806
|
+
}
|
|
1807
|
+
function read_pending_find( k) {
|
|
1808
|
+
for (k = 1; k <= npf; k++) report_mount_read(PF_ROOT[k], PF_MASK[k], PF_DIR[k], "find")
|
|
1809
|
+
}
|
|
1810
|
+
function add_bulk_root(w, m, dir) {
|
|
1811
|
+
ROOT[++nr] = w; ROOT_MASK[nr] = m; ROOT_DIR[nr] = dir
|
|
1812
|
+
}
|
|
1813
|
+
# One root model for all recursive/bulk readers. ROOT carries sources only; ROOT_DIR captures the cwd at
|
|
1814
|
+
# that operand, including ordered tar -C switches. Search defaults and find defaults enter the same model.
|
|
1815
|
+
function bulk_roots(A, s, n, b, k, j, w, m, dir, ended, enabled, target, skip, value, c, values, key, eq, start, stdin_list) {
|
|
1816
|
+
delete ROOT; delete ROOT_MASK; delete ROOT_DIR; nr = 0; bulk_find = 0; bulk_reads = 1
|
|
1817
|
+
dir = effective_dir
|
|
1818
|
+
if (b == "git") {
|
|
1819
|
+
s++
|
|
1820
|
+
while (s <= n && A[s] ~ /^-/) {
|
|
1821
|
+
w = A[s]
|
|
1822
|
+
if (w == "-C" || w == "--work-tree") { dir = literal_directory(A[s + 1], dir); s += 2 }
|
|
1823
|
+
else if (w ~ /^-C./) { dir = literal_directory(substr(w, 3), dir); s++ }
|
|
1824
|
+
else if (w ~ /^--work-tree=/) { dir = literal_directory(substr(w, 13), dir); s++ }
|
|
1825
|
+
else if (w == "-c" || w == "--git-dir") s += 2
|
|
1826
|
+
else s++
|
|
1827
|
+
}
|
|
1828
|
+
if (A[s] != "grep") return 0
|
|
1829
|
+
for (k = s + 1; k <= n; k++) if (A[k] == "--no-index") enabled = 1
|
|
1830
|
+
if (!enabled) return 0
|
|
1831
|
+
b = "grep"
|
|
1832
|
+
} else if (b ~ /^(grep|egrep|fgrep|rg|ag)$/) enabled = recursive_search(A, s, n)
|
|
1833
|
+
if (b ~ /^(grep|egrep|fgrep|rg|ag)$/) {
|
|
1834
|
+
if (!enabled) return 0
|
|
1835
|
+
regex_slots(A, s, n)
|
|
1836
|
+
for (k = s + 1; k <= n; k++) if (k in ROPER) { add_bulk_root(A[k], mask_of(A, k), dir); skip = 1 }
|
|
1837
|
+
if (!skip && (b !~ /^(rg|ag)$/ || (!pipe_input && nrt == 0 && !regex_input))) add_bulk_root(".", "u", dir)
|
|
1838
|
+
return nr
|
|
1839
|
+
}
|
|
1840
|
+
if (b == "find") {
|
|
1841
|
+
bulk_find = 1; bulk_reads = 0; k = s + 1
|
|
1842
|
+
while (k <= n) {
|
|
1843
|
+
if (A[k] ~ /^-[HLP]$/ || A[k] ~ /^-O[0-9]+$/) k++
|
|
1844
|
+
else if (A[k] == "-D") k += 2
|
|
1845
|
+
else break
|
|
1846
|
+
}
|
|
1847
|
+
for (; k <= n && A[k] !~ /^[-(!]/; k++) add_bulk_root(A[k], mask_of(A, k), dir)
|
|
1848
|
+
if (nr == 0) add_bulk_root(".", "u", dir)
|
|
1849
|
+
for (; k <= n; k++) if (A[k] ~ /^-(exec|execdir|ok|okdir)$/) bulk_reads = 1
|
|
1850
|
+
return nr
|
|
1851
|
+
}
|
|
1852
|
+
if (b !~ /^(cp|rsync|scp|tar|zip|cpio|diff)$/) return 0
|
|
1853
|
+
values = b == "tar" ? "fCXTb" : b == "cp" ? "tS" : b == "scp" ? "PofilJS" : b == "rsync" ? "eBfT" : ""
|
|
1854
|
+
for (k = s + 1; k <= n; k++) {
|
|
1855
|
+
w = A[k]; m = mask_of(A, k); key = ""; value = ""
|
|
1856
|
+
if (w ~ /^[0-9]*[<>]/) { if (w ~ /^[0-9]*[<>]+&?-?$/) k++; continue }
|
|
1857
|
+
if (!ended && w == "--") { ended = 1; continue }
|
|
1858
|
+
if (!ended && w ~ /^--/) {
|
|
1859
|
+
eq = index(w, "="); key = eq ? substr(w, 1, eq - 1) : w
|
|
1860
|
+
if (key ~ /^--(recursive|archive|create)$/ || (b == "tar" && key ~ /^--(append|update)$/)) enabled = 1
|
|
1861
|
+
if (key ~ /^--(directory|target-directory|file|files-from|exclude|include|exclude-from|include-from|filter|rsh|suffix|block-size)$/) value = eq ? substr(w, eq + 1) : A[++k]
|
|
1862
|
+
} else if (!ended && (w ~ /^-./ || (b == "tar" && k == s + 1 && w ~ /^[A-Za-z]+$/))) {
|
|
1863
|
+
start = w ~ /^-/ ? 2 : 1
|
|
1864
|
+
for (j = start; j <= length(w); j++) {
|
|
1865
|
+
c = substr(w, j, 1)
|
|
1866
|
+
if ((b == "tar" && c ~ /^[cru]$/) || (b == "cpio" && c == "o") || (b !~ /^(tar|cpio)$/ && c ~ /^[rR]$/) || (b ~ /^(cp|rsync)$/ && c == "a")) enabled = 1
|
|
1867
|
+
if (index(values, c)) {
|
|
1868
|
+
key = c == "C" ? "--directory" : c == "t" ? "--target-directory" : c == "T" && b == "tar" ? "--files-from" : "--value"
|
|
1869
|
+
value = j < length(w) ? substr(w, j + 1) : A[++k]
|
|
1870
|
+
break
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
} else { add_bulk_root(w, m, dir); continue }
|
|
1874
|
+
if (key == "--target-directory") target = 1
|
|
1875
|
+
if (key == "--directory") {
|
|
1876
|
+
dir = literal_directory(value, dir)
|
|
1877
|
+
}
|
|
1878
|
+
if (key == "--files-from") {
|
|
1879
|
+
if (b != "tar") add_bulk_root("\001", "", dir)
|
|
1880
|
+
else if (value == "-") stdin_list = 1
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
if (!enabled) { nr = 0; return 0 }
|
|
1884
|
+
if (b ~ /^(cp|rsync|scp)$/ && !target && nr > 0) nr--
|
|
1885
|
+
if (b == "zip" && nr > 0) { for (k = 1; k < nr; k++) { ROOT[k] = ROOT[k + 1]; ROOT_MASK[k] = ROOT_MASK[k + 1]; ROOT_DIR[k] = ROOT_DIR[k + 1] } nr-- }
|
|
1886
|
+
if (pipe_input && (b == "cpio" || stdin_list)) read_pending_find()
|
|
1887
|
+
return nr
|
|
1888
|
+
}
|
|
1889
|
+
function check_bulk_roots(A, s, n, b, k, d) {
|
|
1890
|
+
for (d = 1; d <= ncd; d++) {
|
|
1891
|
+
effective_dir = cwd_at(d)
|
|
1892
|
+
bulk_roots(A, s, n, b)
|
|
1893
|
+
for (k = 1; k <= nr; k++) {
|
|
1894
|
+
if (ROOT[k] == "-") continue
|
|
1895
|
+
if (bulk_find) { PF_ROOT[++npf] = ROOT[k]; PF_MASK[npf] = ROOT_MASK[k]; PF_DIR[npf] = ROOT_DIR[k] }
|
|
1896
|
+
if (bulk_reads) report_mount_read(ROOT[k], ROOT_MASK[k], ROOT_DIR[k], b)
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
effective_dir = CWD[1]
|
|
1900
|
+
}
|
|
1678
1901
|
function reader(A, s, n, b, k, w, mode, havepat, need, afterdd, kind, valued, valued2, shortvals, filenames) {
|
|
1679
1902
|
b = base(A[s]); mode = ""; valued = " "; valued2 = " "; shortvals = ""
|
|
1680
1903
|
if (b == "sed") {
|
|
@@ -1762,7 +1985,7 @@ function git_content(A, s, n, subcommand, k, w, kind, ended, pathspec) {
|
|
|
1762
1985
|
}
|
|
1763
1986
|
}
|
|
1764
1987
|
function analyze(A, s, n, w, b, k, names, p, config, get, show, first) {
|
|
1765
|
-
nrt = 0; delete REDIRECT_TOKENS; delete ROFF; first = s
|
|
1988
|
+
nrt = 0; nwrap = 0; delete REDIRECT_TOKENS; delete ROFF; first = s
|
|
1766
1989
|
while (s <= n) {
|
|
1767
1990
|
w = A[s]; b = base(w)
|
|
1768
1991
|
if (is_assign(w)) { if (protected_config(w)) config_report(); s++; continue }
|
|
@@ -1770,7 +1993,7 @@ function analyze(A, s, n, w, b, k, names, p, config, get, show, first) {
|
|
|
1770
1993
|
if (b in KW) { s++; continue }
|
|
1771
1994
|
if (b == "command" || b == "builtin") { s++; if (s <= n && (A[s] == "-v" || A[s] == "-V")) return; if (s <= n && A[s] == "-p") s++; if (A[s] == "--") s++; continue }
|
|
1772
1995
|
if (b == "sudo" || b == "doas") { s = skipopts(A, s + 1, n, "ugChprtUD"); continue }
|
|
1773
|
-
if (b == "xargs") { s = skipopts(A, s + 1, n, "IniPLdsEa"); continue }
|
|
1996
|
+
if (b == "xargs") { read_pending_find(); s = skipopts(A, s + 1, n, "IniPLdsEa"); continue }
|
|
1774
1997
|
if (b == "timeout") { s = skipopts(A, s + 1, n, "ks") + 1; continue }
|
|
1775
1998
|
if (b == "nice" || b == "watch") { s = skipopts(A, s + 1, n, "n"); continue }
|
|
1776
1999
|
if (b == "nohup" || b == "time" || b == "exec" || b == "setsid") { s = skipopts(A, s + 1, n, ""); continue }
|
|
@@ -1781,7 +2004,10 @@ function analyze(A, s, n, w, b, k, names, p, config, get, show, first) {
|
|
|
1781
2004
|
w = A[s]
|
|
1782
2005
|
if (is_assign(w)) { if (protected_config(w)) config_report(); s++ }
|
|
1783
2006
|
else if (w ~ /^[0-9]*[<>]/) s += (w ~ /^[0-9]*[<>]+&?-?$/) ? 2 : 1
|
|
1784
|
-
else if (w == "-
|
|
2007
|
+
else if (w == "-C" || w == "--chdir") { WRAP_DIR[++nwrap] = A[s + 1]; s += 2 }
|
|
2008
|
+
else if (w ~ /^--chdir=/) { WRAP_DIR[++nwrap] = substr(w, 9); s++ }
|
|
2009
|
+
else if (w ~ /^-C./) { WRAP_DIR[++nwrap] = substr(w, 3); s++ }
|
|
2010
|
+
else if (w == "-u" || w == "-S" || w == "--unset" || w == "--split-string") s += 2
|
|
1785
2011
|
else if (substr(w, 1, 1) == "-") s++
|
|
1786
2012
|
else break
|
|
1787
2013
|
}
|
|
@@ -1797,17 +2023,20 @@ function analyze(A, s, n, w, b, k, names, p, config, get, show, first) {
|
|
|
1797
2023
|
if (expands(A[s], mask_of(A, s))) return dyn_command(A, s, n)
|
|
1798
2024
|
b = base(A[s])
|
|
1799
2025
|
if (nheredoc > 0 && b ~ /^(node|nodejs|deno|bun|python[0-9.]*|ruby|perl|php|lua|osascript|pwsh|powershell|dotnet|java|jshell|rscript|tclsh|julia|groovy|tsx|ts-node)$/) hd_interp = 1
|
|
2026
|
+
if (b == "cd" || b == "pushd" || b == "popd") { change_directory(A, s, n, b); return }
|
|
2027
|
+
check_bulk_roots(A, s, n, b)
|
|
1800
2028
|
if (A[s] == "git") git_content(A, s, n)
|
|
1801
2029
|
shell_config(A, s, n, b)
|
|
1802
2030
|
collect_bindings(A, s, n, b)
|
|
1803
2031
|
if (b == "for" || b == "select" || b == "unset") return
|
|
2032
|
+
if (b == "find") return
|
|
1804
2033
|
if (b == "dd") {
|
|
1805
2034
|
for (k = s + 1; k <= n; k++) if (A[k] ~ /^if=/ && (config = operand_kind(A, k, 3)) != "") report("dd reads " config, "name only a non-credential input file")
|
|
1806
2035
|
return
|
|
1807
2036
|
}
|
|
1808
2037
|
if (b ~ /^(cp|mv|ln|rsync|scp|tar|zip)$/) { transfer_files(A, s, n, b); return }
|
|
1809
2038
|
if (b ~ /^(export|declare|typeset|local|readonly)$/) for (k = s + 1; k <= n; k++) if (is_assign(A[k])) set_var(A[k], mask_of(A, k))
|
|
1810
|
-
if (b == "bash" || b == "sh" || b == "zsh" || b == "dash" || b == "ksh") { shell_invocation(A, s, n); return }
|
|
2039
|
+
if (b == "bash" || b == "sh" || b == "zsh" || b == "dash" || b == "ksh") { if (pipe_input || (cwd_depth > 0 && PIPE_SCOPE[cwd_depth])) read_pending_find(); shell_invocation(A, s, n); return }
|
|
1811
2040
|
if (b == "eval") { p = ""; for (k = s + 1; k <= n; k++) p = p " " A[k]; enqueue(p); return }
|
|
1812
2041
|
if (b == "kubectl" || b == "oc") return kube(A, s, n)
|
|
1813
2042
|
if (b == "docker" || b == "podman") return dock(A, s, n)
|
|
@@ -1882,6 +2111,9 @@ BEGIN {
|
|
|
1882
2111
|
ESC["\\"] = 92; ESC["\047"] = 39; ESC["\""] = 34; ESC["?"] = 63
|
|
1883
2112
|
nprobe = split(".env .env.local .env.production .envrc id_rsa id_ed25519 id_ecdsa id_dsa credentials token token.json tokens.json github_token .netrc .npmrc .pypirc .pgpass .git-credentials kubeconfig", PROBE, " ")
|
|
1884
2113
|
nprobe2 = split(".kube/config .aws/credentials .docker/config.json /proc/1/environ /run/secrets/token /var/run/secrets/token", PROBE2, " ")
|
|
2114
|
+
for (i = 1; i <= nprobe2; i++) if (PROBE2[i] ~ /^\/(var\/)?run\/secrets\//) {
|
|
2115
|
+
mount = PROBE2[i]; sub(/\/[^\/]*$/, "", mount); SECRET_MOUNT[mount] = 1
|
|
2116
|
+
}
|
|
1885
2117
|
nextension = split("pem key p12 pfx jks keystore kdbx kubeconfig env", EXT, " ")
|
|
1886
2118
|
ndispatch = split("cat tac nl less more head tail bat batcat strings xxd od hexdump cut sort uniq base64 wc dd cp mv ln rsync scp tar zip shopt set setopt unsetopt emulate grep egrep fgrep rg ag sed awk gawk mawk nawk busybox jq yq gojq jaq kubectl oc docker podman docker-compose gh vault aws az gcloud pulumi cratis printenv export declare typeset env bash sh zsh dash ksh eval", DN, " ")
|
|
1887
2119
|
ninterp = split(".env|env .env.local|name .env.production|name .envrc|name id_rsa|name id_ed25519|name id_ecdsa|name id_dsa|name .netrc|name .npmrc|name .pgpass|name .pypirc|name .git-credentials|name kubeconfig|name .kube/|name .aws/|name .docker/config.json|name credentials.json|name secrets.yaml|name secrets.yml|name .pem|ext .key|ext .p12|ext .pfx|ext .jks|ext .keystore|ext .kdbx|ext", INTERP_SPEC, " ")
|
|
@@ -1889,7 +2121,8 @@ BEGIN {
|
|
|
1889
2121
|
nstem = split(".env .pem .key .p12 .pfx .jks .keystore .kdbx id_rsa id_ed25519 id_ecdsa id_dsa .netrc .npmrc .pgpass .pypirc .git-credentials .kube/ kubeconfig credentials credential secrets.yaml secrets.yml .docker/ /environ run/secrets", STEM, " ")
|
|
1890
2122
|
CMD = ENVIRON["GS_COMMAND"]
|
|
1891
2123
|
for (pass = 1; pass <= 2; pass++) {
|
|
1892
|
-
delete queue; queued = 0; qi = 0; delete seen; reports = ""
|
|
2124
|
+
delete queue; delete QUEUE_DIR; delete QUEUE_COUNT; queued = 0; qi = 0; delete seen; reports = ""
|
|
2125
|
+
delete CWD; ncd = 1; nwrap = 0; CWD[1] = ENVIRON["GS_CWD_FALLBACK"]; effective_dir = CWD[1]
|
|
1893
2126
|
nheredoc = 0; hd_shell = 0; hd_interp = 0; commands = 0; complex = 0; simple_ok = 1; TAINT = ""
|
|
1894
2127
|
enqueue(CMD)
|
|
1895
2128
|
while (qi < queued) { qi++; tokenize(queue[qi]) }
|
|
@@ -1906,10 +2139,9 @@ BEGIN {
|
|
|
1906
2139
|
AWK
|
|
1907
2140
|
|
|
1908
2141
|
# Never infer a missing hook cwd for filesystem-dependent glob decisions.
|
|
1909
|
-
command_cwd="$(jq -r '.cwd // empty' <<<"$input")" || parser_failed
|
|
1910
2142
|
glob_shell_safe=1
|
|
1911
2143
|
if [[ -n "${BASH_ENV+x}" || -n "${ENV+x}" || -n "${GLOBIGNORE+x}" ]] || shopt -q dotglob || shopt -q nocaseglob; then glob_shell_safe=0; fi
|
|
1912
|
-
findings="$(GS_COMMAND="$command_text" GS_CWD="$command_cwd" GS_CWD_FALLBACK="${command_cwd:-$PWD}" GS_GLOB_SAFE="$glob_shell_safe" LC_ALL=C awk "$awk_program" </dev/null)" || parser_failed
|
|
2144
|
+
findings="$(GS_LINK_PROGRAM="$link_program" GS_COMMAND="$command_text" GS_CWD="$command_cwd" GS_CWD_FALLBACK="${command_cwd:-$PWD}" GS_GLOB_SAFE="$glob_shell_safe" LC_ALL=C awk "$awk_program" </dev/null)" || parser_failed
|
|
1913
2145
|
[ -n "$findings" ] || exit 0
|
|
1914
2146
|
|
|
1915
2147
|
{
|