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

tag_safe custom_attribute for ocap discipline #130

Closed
dckc opened this issue Dec 23, 2020 · 5 comments
Closed

tag_safe custom_attribute for ocap discipline #130

dckc opened this issue Dec 23, 2020 · 5 comments

Comments

@dckc
Copy link

dckc commented Dec 23, 2020

Feel free to close this as out of scope, but the idea is:

  1. tag functions that are designed to follow ocap discipline:
#[tagged_safe(ocap="tagsafe_std_ocap.txt")]
extern crate std as _std;

#[tag_safe(ocap)]
fn cap_main<W>(out: &mut W) -> io::Result<()>
  1. tag functions that use ambient authority as unsafe w.r.t. ocap discipline. The tagsafe_std_ocap.txt file db would express the equivalent of:
#[tag_unsafe(ocap)]
use std::fs::File::open;
  1. Use the tag_safe linter to go BZZZT if an ocap safe function calls, directly or indirectly, an ocap unsafe function.

refs from around Nov 2016:
thepowersgang/tag_safe#1
https://github.com/dckc/larust-tame
dckc/rust#2 (comment)

@sunfishcode
Copy link
Member

I'm not familiar with tag_safe or the rustc plugin system, but this sounds like something interesting to pursue. Would you be interested in putting together a small version of this, that just marks a small number of functions, to show how it work work?

@dckc
Copy link
Author

dckc commented Dec 29, 2020

I'm interested, yes; whether I'm available is another question. :-/

Here's hoping.

@sunfishcode
Copy link
Member

It seems the #![plugin] mechanism that tag_safe is built on is deprecated.

cargo-geiger is a project that similarly builds a custom static analysis, but uses syn rather than being a rustc plugin, which may be something to look into.

And on a related note, I posted here about a possible change to Rust's std which would help distinguish the parts of the API that use ambient filesystem authorities from the parts that don't.

@sunfishcode
Copy link
Member

With the switch to the ambient-authority crate to model ambient authority, another option is to use clippy. A clippy config file for scanning for ambient_authority() or any of the known functions in std, tempfile, rand, directories_next, or fs_set_times, is here:

https://github.com/sunfishcode/ambient-authority/blob/main/clippy.toml

@dckc
Copy link
Author

dckc commented Jun 14, 2021

fantastic!

@dckc dckc closed this as completed Jun 14, 2021
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

No branches or pull requests

2 participants