-
Notifications
You must be signed in to change notification settings - Fork 7.2k
feat: add allow_tmpdir permission for scoped tmpdir access
#6123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
@elithrar do you think is is preferable to something like: @thdxr has been working on a revamp of our permissions and part of it was making every permission (that makes sense) "glob-able" like this Other examples for other permissions: |
|
TBH I actually like both + tried to leave room for custom permission objects. thoughts:
As a user: I want opencode to be able to work within the cwd and use tmpdir as a sandbox. I do not want it to accidentally (through config) end up having wider access to the rest of my machine. Especially in an enterprise env, but also as a regular privacy conscious user. |
|
hmm okay good point about the tmpdir differences across different os, I will send this to Dax since he has been thinking about these things lately |
|
let me merge my permissions branch (it's close) and i'll look at this |
|
fa7c089 to
aad5408
Compare
When I was reading the top of this issue page I immediately thought tmpdir should be configurable. I am aware that the agent will know where the actual tmp dir is on a modern OS but maybe it can be coerced with a prompt. I for one like my tmp dir to be ./tmp . Perhaps it can be configured as a scratch dir or something similar. Even if this was to be done I am not saying it should be combined with the heart of this current issue. The two things are not entirely the same thing. |
|
If you want to do that, you can today: https://opencode.ai/docs/permissions/#granular-rules-object-syntax I will argue that that is the exception and not the rule though. Why wouldn't you use the OS-specific tmpdir and instead manage your own? |
Thank you . I will check that out. The reason is I don't want the agent to touch anything outside of the project directory. |
This PR adds an
allow_tmpdirpermission that allows file operations in the system's temporary directory without requiringexternal_directoryapproval prompts.The
permission.allow_tmpdir: boolean(defaults tofalse) and is in both global/merged config and per-agent config/schemas.specifically:
external_directorydefaults to"ask", prompting for permission on any file operation outside the current working directoryexternal_directory: "allow") permits access to ALL external directories, which is overly broadsecurity:
/tmp→/private/tmp)falsemaintains current security model (opt-in)external_directorysettingstests:
Filesystem.tmpdir(),isInTmpdir(),containsResolved()utilities tested for symlink resolution and non-existent pathsallow_tmpdir: truepermits tmpdir workdir whileexternal_directory: denyis setallow_tmpdir: truedoes not bypassexternal_directoryfor non-tmpdir pathsusage example:
{ "$schema": "https://opencode.ai/config.json", "permission": { "allow_tmpdir": true, "external_directory": "ask" } }Or per-agent:
{ "agent": { "build": { "permission": { "allow_tmpdir": true } } } }related: