Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add permission name when accessing a special file errors #25085

Merged
merged 13 commits into from
Aug 19, 2024

Conversation

sigmaSd
Copy link
Contributor

@sigmaSd sigmaSd commented Aug 18, 2024

fix #25055

@sigmaSd sigmaSd marked this pull request as ready for review August 18, 2024 21:00
Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test to ensure it's actually fixed and doesn't regress in the future?

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Aug 18, 2024

I found something weird with tests

import { assertThrows } from "jsr:@std/assert";
Deno.test({ permissions: { read: true } }, function execPathPerm() {
  console.log(Deno.permissions.querySync({ "name": "read" }));
  if (Deno.build.os === "linux") {
    assertThrows(
      () => {
        const a = Deno.readTextFileSync("/proc/net/dev");
        console.log(a);
      },
      Deno.errors.PermissionDenied,
      "Requires read access to <exec_path>, run again with the --allow-read flag",
    );
  }
});

if I run this on the main branch with deno test -A, it doesn't error as expected, seems somehow like even though I specified only read = true, the tests are passing allow-all permission in implicit way, so it doesn't throw

@sigmaSd sigmaSd marked this pull request as draft August 18, 2024 21:47
@sigmaSd sigmaSd marked this pull request as ready for review August 18, 2024 21:55
`PermissionDenied: Requires all access to "/proc/net/dev", run again with the --allow-all flag`,
);
},
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it out and cargo test js_unit_tests::os_test runs fine with this, so I reverted to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... it was passing locally and now it's failing. I probably wasn't running it correctly. I'm looking into this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to revert my changes and follow up in a separate pr

Copy link
Member

@dsherret dsherret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@dsherret dsherret enabled auto-merge (squash) August 19, 2024 16:20
@dsherret dsherret merged commit ee2b689 into denoland:main Aug 19, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message when accessing /proc
2 participants