@miller-tech/uap 1.187.3 → 1.187.4
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/package.json +1 -1
- package/src/policies/enforcers/__pycache__/_common.cpython-312.pyc +0 -0
- package/src/policies/enforcers/rtk_wrap.py +65 -28
- package/templates/hooks/__pycache__/deliver_autoroute.cpython-312.pyc +0 -0
- package/tools/agents/scripts/__pycache__/toolcall_path_normalizer.cpython-312.pyc +0 -0
package/package.json
CHANGED
|
Binary file
|
|
@@ -27,40 +27,77 @@ PM_BUILTINS = {
|
|
|
27
27
|
PMS = ("npm", "pnpm", "yarn")
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
# A command is a sequence of STATEMENTS; each one invokes its own binary.
|
|
31
|
+
_STATEMENT_SPLIT_RE = re.compile(r"&&|\|\||[;|&\n]")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _leading_binary(statement: str) -> tuple[str, list[str]] | None:
|
|
35
|
+
"""The binary a statement invokes, plus its tokens — or None.
|
|
36
|
+
|
|
37
|
+
Skips env assignments (`FOO=bar cmd`) and shell grouping, then reads the
|
|
38
|
+
FIRST real word. That word is what the shell executes; a wrapped CLI
|
|
39
|
+
appearing later is an argument, not an invocation.
|
|
40
|
+
"""
|
|
41
|
+
tokens = statement.replace("(", " ").replace("{", " ").split()
|
|
42
|
+
idx = 0
|
|
43
|
+
while idx < len(tokens) and "=" in tokens[idx].split("/")[0]:
|
|
44
|
+
idx += 1 # env assignment prefix
|
|
45
|
+
if idx >= len(tokens):
|
|
46
|
+
return None
|
|
47
|
+
return tokens[idx].split("/")[-1], tokens[idx:]
|
|
48
|
+
|
|
49
|
+
|
|
30
50
|
def main() -> None:
|
|
31
51
|
op, args = parse_cli()
|
|
32
52
|
cmd = (args.get("command") or args.get("cmd") or "").strip()
|
|
33
53
|
if not cmd or op.lower() != "bash":
|
|
34
54
|
emit(True, "not a Bash command")
|
|
35
55
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
# Evaluate each statement on its own.
|
|
57
|
+
#
|
|
58
|
+
# Whole-command matching got this wrong in BOTH directions. It only accepted
|
|
59
|
+
# `rtk` at the very start, so `cd /srv/app && rtk git log` — already wrapped —
|
|
60
|
+
# was refused, with a suggestion that prefixed rtk to the entire line and
|
|
61
|
+
# produced nonsense like `rtk cd /srv/app; git log`. And it scanned only the
|
|
62
|
+
# first three tokens, so `cd /srv/app && git log` slipped through entirely:
|
|
63
|
+
# `git` sat at index 3. That is a bypass, not just noise — any bare invocation
|
|
64
|
+
# could be hidden behind a `cd`. Reading the leading binary of each statement
|
|
65
|
+
# fixes both, because that is what the shell actually runs.
|
|
66
|
+
for raw in _STATEMENT_SPLIT_RE.split(cmd):
|
|
67
|
+
statement = raw.strip()
|
|
68
|
+
if not statement:
|
|
69
|
+
continue
|
|
70
|
+
found = _leading_binary(statement)
|
|
71
|
+
if not found:
|
|
72
|
+
continue
|
|
73
|
+
bin_name, tokens = found
|
|
74
|
+
|
|
75
|
+
# A statement led by `rtk` (or anything else outside WRAPPED) is fine:
|
|
76
|
+
# in `rtk git log` the leading binary is rtk and `git` is its argument.
|
|
77
|
+
# No separate rtk check is needed - rtk is simply not a wrapped CLI.
|
|
78
|
+
# Mutation testing flagged the earlier explicit check as equivalent,
|
|
79
|
+
# i.e. dead.
|
|
80
|
+
if bin_name not in WRAPPED:
|
|
81
|
+
continue
|
|
82
|
+
|
|
83
|
+
wrapper = "rtk"
|
|
84
|
+
if bin_name in PMS:
|
|
85
|
+
sub = ""
|
|
86
|
+
for nxt in tokens[1:]:
|
|
87
|
+
if not nxt.startswith("-"):
|
|
88
|
+
sub = nxt.split("/")[-1]
|
|
89
|
+
break
|
|
90
|
+
if sub in PM_BUILTINS:
|
|
91
|
+
wrapper = "rtk proxy"
|
|
92
|
+
# Suggest fixing THIS statement, not the whole line.
|
|
93
|
+
emit(
|
|
94
|
+
False,
|
|
95
|
+
f"rtk-wrap: '{bin_name}' must be invoked via rtk. "
|
|
96
|
+
f"Use: {wrapper} {statement}",
|
|
97
|
+
bin=bin_name,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
emit(True, "no unwrapped CLI in any statement")
|
|
64
101
|
|
|
65
102
|
|
|
66
103
|
if __name__ == "__main__":
|
|
Binary file
|