Skip to content

bug(forge): Having both a access = read and access = write for the same path in fs_permissions does not work #10677

@rubydusa

Description

@rubydusa

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
    Foundryup

What version of Foundry are you on?

forge Version: 1.2.1-stable Commit SHA: 42341d5 Build Timestamp: 2025-05-26T05:24:48.799227114Z (1748237088) Build Profile: maxperf

What version of Foundryup are you on?

No response

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

When you have a foundry.toml with the following fs_permissions:

fs_permissions = [
    { access = "read", path = "./" },
    { access = "write", path = "./" }
]

either vm.readFile or vm.writeFile won't work because when forge checks if a path is permitted a certain kind of access it looks by path:

    pub fn is_path_allowed(&self, path: &Path, kind: FsAccessKind) -> bool {
        self.find_permission(path).map(|perm| perm.is_granted(kind)).unwrap_or_default()
    }

now there is read-write permission, but it's very confusing to get an error with the configuration above.
I'd gladly open a PR but I wanted advice on what should be the solution:

  • document this issue in the docs
  • disallow having the same path twice
  • refactor is_path_allowed to find all permissions for a path
  • when reading foundry.toml combine permissions that are for the same file

Activity

mattsse

mattsse commented on May 31, 2025

@mattsse
Member

imo doing

refactor is_path_allowed to find all permissions for a path

would be the appropriate fix here

added
C-forgeCommand: forge
and removed
T-needs-triageType: this issue needs to be labelled
on Jun 3, 2025
changed the title [-]Having both a `access = read` and `access = write` for the same path in `fs_permissions` does not work[/-] [+]bug(forge): Having both a `access = read` and `access = write` for the same path in `fs_permissions` does not work[/+] on Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @mattsse@grandizzy@rubydusa

      Issue actions

        bug(forge): Having both a `access = read` and `access = write` for the same path in `fs_permissions` does not work · Issue #10677 · foundry-rs/foundry