Skip to content

Permission Wildcard * Overwriting Lower Permissions #24335

@matthew-j-hooper

Description

@matthew-j-hooper

Description

According to the docs https://opencode.ai/docs/permissions/:

Rules are evaluated by pattern match, with the last matching rule winning. A common pattern is to put the catch-all "*" rule first, and more specific rules after it.

Therefore the below opencode.json should result in a behavior allowing writing to the specified directory but no others, regardless of the root project directory location.

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
	"external_directory": {
	  "~/Documents/Programming/AI/**": "allow"
	},
    "edit": {
	  "*": "deny",
	  "~/Documents/Programming/AI/**": "allow"
	},
    "bash": {
	  "*": "deny",
	  "cd ~/Documents/Programming/AI/*": "allow",
	  "ls ~/Documents/Programming/AI/*": "allow",
	  "touch ~/Documents/Programming/AI/*": "allow",
	  "pwd": "allow"
	}
  }
}

However this results in no write access in any directory.

Similarly, based on my interpretation of the docs, this altercation to the opencode.json should also allow for the same expected behavior:

{
  "$schema": "https://opencode.ai/config.json",
  "permission": {
	"external_directory": {
	  "~/Documents/Programming/AI/**": "allow"
	},
	"edit": "deny",
    "edit": {
	  "~/Documents/Programming/AI/**": "allow"
	},
    "bash": {
	  "*": "deny",
	  "cd ~/Documents/Programming/AI/*": "allow",
	  "ls ~/Documents/Programming/AI/*": "allow",
	  "touch ~/Documents/Programming/AI/*": "allow",
	  "pwd": "allow"
	}
  }
}

This results in having write access to all directories. The documentation is worded to imply that this might only work when restricting access?

Add explicit rules when a tool should be restricted in these paths, such as blocking edits while keeping reads:

Plugins

None

OpenCode version

1.14.25

Steps to reproduce

  1. Use the provided opencode.json configurations.
  2. Ask OpenCode to write to a file within your specified directory

Screenshot and/or share link

No response

Operating System

Fedora 43

Terminal

Foot

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions