You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit eb9df27
Browse filesBrowse the repository at this point in the historyBrowse files
fix(server): check commands named through a variable the line sets (#5973)
OpenCode v2 asks about each command of a shell line on its own and drops
bare assignments, so `x=printf; $x ...` reached the agent permissions
plugin as `$x ...` and was only asked about, even where `printf *` is
blocked. The plugin now keeps each shell call's whole line by call id,
and the parser checks a variable-named program with every literal value
the line gives it (`x=rm`, `export x=rm`, `x=rm $x`, `for x in rm`,
`${x:-rm}`). Programs named through variables the line doesn't set,
substitutions or patterns are still asked about.
Signed-off-by: Jalil <reachjalil@gmail.com>
evidence.recordAssertionEvidence("the agent's variable-named printf call",`${call?.status??"none"}, no approval asked: ${variableCommand}`,call?.status==="error");
98
+
expect(call?.status).toBe("error");
99
+
awaituser.screenshot();
100
+
});
101
+
102
+
awaitstep("after: the variable-named printf never ran, and the agent was told the Contractors rule instead of Riley being asked to approve it",async()=>{
Copy file name to clipboardExpand all lines: packages/docs/cloud/share-with-your-team/agent-permissions.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ In the built-in browser, a blocked website doesn't load and the browser shows th
63
63
64
64
## Known limits
65
65
66
-
-**Commands named through a variable.** Command rules match the command as it is written. A command whose program name comes from a shell variable, substitution or pattern, such as `x=rm; $x -rf build`, can't be matched to a rule. Where commands are blocked it is blocked; where a command rule only blocks some commands, such as `rm *`, it is asked about, and the member can approve it.
66
+
-**Commands named through a variable.** Command rules match the command as it is written. When a command line sets the variable that names a program, as in `x=rm; $x -rf build`,`export x=rm`, `for x in rm` or `${x:-rm}`, the program is checked with each value the line gives it, so `rm *` blocks it. A program named through a variable the line doesn't set, such as `$EDITOR`, a substitution such as `$(which rm)` or a pattern such as `/bin/r?` can't be matched to a rule. Where commands are blocked it is blocked; where a command rule only blocks some commands, such as `rm *`, it is asked about, and the member can approve it.
67
67
-**Command lines OpenWork can't fully read.** A line nested or long enough that OpenWork stops reading it is handled the same way. A script that only exists when the command runs, such as `curl … | sh`, is checked as written.
68
68
-**Text that looks like a command.** Each line of a command is checked, including the text in a heredoc (`cat <<EOF` … `EOF`). A line there that matches a blocked pattern blocks the whole command, even though it is only written to a file.
69
69
-**Ask first for file edits.** It applies to the agent's file editing. When commands are allowed, a command that writes a file, such as `echo … > notes.txt`, isn't asked about; set **Run commands** to **Ask first** as well to cover those.
0 commit comments