[FEATURE]: more general external_directory permissions #3259

Open
opened 2026-02-16 17:39:22 -05:00 by yindo · 4 comments
Owner

Originally created by @benceferdinandy-signifyd on GitHub (Dec 2, 2025).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • 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.

Originally created by @benceferdinandy-signifyd on GitHub (Dec 2, 2025). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] 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.
yindo added the discussion label 2026-02-16 17:39:22 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 2, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #4743: Allow /tmp or $TMPDIR folder access option - discusses making external_directory more extensible with environment variables and wildcards
  • #4287: edit/write permission with deny,allow,ask using glob - proposes using glob patterns for more granular permission control
  • #4800: permissions for compound commands - relates to permission resolution for complex CLI arguments
  • #4881: Setting global permissions for custom tool - discusses broader permission configuration for tools

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.

@github-actions[bot] commented on GitHub (Dec 2, 2025): This issue might be a duplicate of existing issues. Please check: - #4743: Allow /tmp or $TMPDIR folder access option - discusses making `external_directory` more extensible with environment variables and wildcards - #4287: edit/write permission with deny,allow,ask using glob - proposes using glob patterns for more granular permission control - #4800: permissions for compound commands - relates to permission resolution for complex CLI arguments - #4881: Setting global permissions for custom tool - discusses broader permission configuration for tools 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.
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

Yeah it could definitely be better

and if it looks like it matches something on the filesystem invoke the external_directory permissions?

What does this mean?

@rekram1-node commented on GitHub (Dec 2, 2025): Yeah it could definitely be better > and if it looks like it matches something on the filesystem invoke the external_directory permissions? What does this mean?
Author
Owner

@benceferdinandy-signifyd commented on GitHub (Dec 2, 2025):

Yeah it could definitely be better

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).

@benceferdinandy-signifyd commented on GitHub (Dec 2, 2025): > Yeah it could definitely be better > > > 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).
Author
Owner

@rekram1-node commented on GitHub (Dec 2, 2025):

Yeah I see what you mean

@rekram1-node commented on GitHub (Dec 2, 2025): Yeah I see what you mean
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3259