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
[FEATURE]: more general external_directory permissions #4991
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I looked at the implementation of of external_directory and it seems to be extremely narrow, as in for a couple of tools. Would it not make sense to check if any path like thing is in the CLI arguments regardless of the command, and if it looks like it matches something on the filesystem invoke the external_directory permissions?
Matching the path-like to actual filepaths should avoid invoking it on false positives.
These issues all touch on making the permission system more flexible and generalizable beyond specific hardcoded tools. Feel free to ignore if your specific case isn't addressed by these.
and if it looks like it matches something on the filesystem invoke the external_directory permissions?
What does this mean?
So imagine a command that has an argument that looks like a path but isn't, or is a path, but not relevant on the machine (for the first, maybe some script that does API calls, but the base URL is embedded so you have something like http GET /api/lookup for the latter something like ssh remotemachine ls /var/lib/). In both cases it would look like path outside of the CWD, but the first one is not a path, the latter is not a path on the machine. So my suggestion would be to parse CLI arguments for path like things, but verify if those things are actually paths that exist on the current machine. Such a check (that probably should be glob aware) would tell opencode that /api/lookup is not a path on this machine, so no need to apply external_directory permissions.
Does that make sense? I feel this would remove the need to hardcode specific commands (although some common commands could still get their own special rules if needed).
Activity
github-actions commentedon Dec 2, 2025
This issue might be a duplicate of existing issues. Please check:
external_directorymore extensible with environment variables and wildcardsThese issues all touch on making the permission system more flexible and generalizable beyond specific hardcoded tools. Feel free to ignore if your specific case isn't addressed by these.
rekram1-node commentedon Dec 2, 2025
Yeah it could definitely be better
What does this mean?
benceferdinandy-signifyd commentedon Dec 2, 2025
So imagine a command that has an argument that looks like a path but isn't, or is a path, but not relevant on the machine (for the first, maybe some script that does API calls, but the base URL is embedded so you have something like
http GET /api/lookupfor the latter something likessh remotemachine ls /var/lib/). In both cases it would look like path outside of the CWD, but the first one is not a path, the latter is not a path on the machine. So my suggestion would be to parse CLI arguments for path like things, but verify if those things are actually paths that exist on the current machine. Such a check (that probably should be glob aware) would tell opencode that/api/lookupis not a path on this machine, so no need to applyexternal_directorypermissions.Does that make sense? I feel this would remove the need to hardcode specific commands (although some common commands could still get their own special rules if needed).
rekram1-node commentedon Dec 2, 2025
Yeah I see what you mean