tauri-apps / plugins-workspace

All of the official Tauri plugins in one place!
https://tauri.app
Apache License 2.0
813 stars 224 forks source link

`fs:scope-resource-recursive` won't allow access to the resource directory #1307

Closed suguruwataru closed 1 week ago

suguruwataru commented 3 months ago

Taking the example from https://beta.tauri.app/references/acl/#capabilities

{
  "permissions": [
    {
      "identifier": "fs:scope",
      "allow": [{ "path": "$APPDATA" }, { "path": "$APPDATA/**" }]
    }
  ]
}

This example doesn't really work as one would expect, making all content of the appdata directory accessible. In order to scope all content of a directory, the scope <directory>/** is not enough. <directory>/ is needed as well. Since $APPDATA itself is not a member of $APPDATA, this makes sense, I guess.

As a result, with the current definition of scope-resource-recursive (and similar scopes), after adding a permission such as allow-resource-read-recursive, one still won't be able to access the directory, since its path only includes the directory's content, but not the directory itself:

path = "$RESOURCE/**"

Permissions such as allow-resource-meta are required to be used together to get access to the directory. They include the path that points to the diretory itself.

When it comes to allow-resource-read-recursive (and similar scopes), I don't think it makes sense to be not able to access the directory itself when this scope is used. The documentation of allow-resource-read-recursive says

This allows full recursive read access to the complete $RESOURCE folder, files and subdirectories.

It didn't come to me intuitively that I don't have the permission to access the directory itself when I have "full" recursive read access to the "complete" directory.

imyanice commented 2 months ago

i had the same bug and allowing the parent directory did it for me, thanks a lot!


"permissions": [
    {
      "identifier": "fs:read-all",
      "allow": [{
        "path": "$HOME/.vxfetch/"
      },
        {
          "path": "$HOME/.vxfetch/**"
        }
      ]
    }
  ]
winjeysong commented 1 month ago

Same problem...

According to fs scope permissions, fs:scope-appcache-recursive means

This scope recursive access to the complete $APPCACHE folder, including sub directories and files.

But I can't access $APPCACHE/sub/file even if I have set fs:scope-appcache-recursive.