{"id":15401095,"url":"https://github.com/sunfishcode/open-ambient","last_synced_at":"2025-04-16T02:27:41.987Z","repository":{"id":57649196,"uuid":"385760137","full_name":"sunfishcode/open-ambient","owner":"sunfishcode","description":"Open files and directories with constant paths","archived":false,"fork":false,"pushed_at":"2024-01-11T05:46:46.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T00:11:15.589Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sunfishcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-13T23:32:22.000Z","updated_at":"2023-01-09T08:28:53.000Z","dependencies_parsed_at":"2024-10-19T06:46:03.860Z","dependency_job_id":null,"html_url":"https://github.com/sunfishcode/open-ambient","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"be1416cd6212e39324d2bb37435ea1b2438f1bf8"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fopen-ambient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fopen-ambient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fopen-ambient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sunfishcode%2Fopen-ambient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sunfishcode","download_url":"https://codeload.github.com/sunfishcode/open-ambient/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249184292,"owners_count":21226340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T15:56:28.286Z","updated_at":"2025-04-16T02:27:41.968Z","avatar_url":"https://github.com/sunfishcode.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e\u003ccode\u003eopen-ambient\u003c/code\u003e\u003c/h1\u003e\n\n  \u003cp\u003e\n    \u003cstrong\u003eOpen files and directories with constant paths\u003c/strong\u003e\n  \u003c/p\u003e\n\n  \u003cp\u003e\n    \u003ca href=\"https://github.com/sunfishcode/open-ambient/actions?query=workflow%3ACI\"\u003e\u003cimg src=\"https://github.com/sunfishcode/open-ambient/workflows/CI/badge.svg\" alt=\"Github Actions CI Status\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://crates.io/crates/open-ambient\"\u003e\u003cimg src=\"https://img.shields.io/crates/v/open-ambient.svg\" alt=\"crates.io page\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://docs.rs/open-ambient\"\u003e\u003cimg src=\"https://docs.rs/open-ambient/badge.svg\" alt=\"docs.rs docs\" /\u003e\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\nOne of the uses for [ambient-authority] is to mark places in the code which\nmay be opening files or other resources in ways that may be influenced by\nuntrusted inputs. Paths or other identifiers which are constant and known\nat compile time are safe. This crate provides macros for use with [cap-std]\nwhich open files and directories in a way that requires the paths to be\nconstant and in a way that allows them to be ignored in a clippy scan for\nuse of dynamic ambient authority.\n\nTo use, it add `#![deny(clippy::disallowed_method)]` to your code and copy\n[the clippy.toml file], as described [here], for example:\n\n```rust\n#![deny(clippy::disallowed_method)]\n\nuse open_ambient::open_ambient_file;\n\nfn main() {\n    let fine = open_ambient_file!(\"Cargo.toml\").unwrap();\n    // ... do stuff with `fine`\n    drop(fine);\n\n    let risky = std::fs::File::open(\"Cargo.toml\").unwrap();\n    // ... do stuff with `risky`\n    drop(risky);\n}\n```\n\nAnd run clippy configured with [these instructions]. The above code\ngets just one error:\n\n```\nerror: use of a disallowed method `std::fs::File::open`\n  --\u003e test.rs:10:19\n   |\n10 |     let risky = std::fs::File::open(\"Cargo.toml\").unwrap();\n   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n```\n\nThe `open_ambient_file!` line does not get an error, while the\n`std::fs::File::open` line does.\n\n[ambient-authority]: https://crates.io/crates/ambient-authority\n[cap-std]: https://crates.io/crates/cap-std\n[here]: https://github.com/sunfishcode/ambient-authority/blob/main/clippy.toml#L5\n[these instructions]: https://github.com/sunfishcode/ambient-authority/blob/main/clippy.toml#L18\n[the clippy.toml file]: https://github.com/sunfishcode/ambient-authority/blob/main/clippy.toml\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunfishcode%2Fopen-ambient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsunfishcode%2Fopen-ambient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsunfishcode%2Fopen-ambient/lists"}