Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/config/built_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ pub(crate) fn get_built_ins() -> BTreeMap<ApiName, ApiConfig> {
perm(
&[
"std::fs",
// Darwin is not yet supported
//"std::os::darwin::fs",
"std::os::linux::fs",
"std::os::unix::fs",
"std::os::unix::io",
"std::os::wasi::fs",
"std::os::wasi::io",
"std::os::windows::fs",
"std::os::windows::io",
"std::path",
// WASI is not yet supported
//"std::os::wasi::fs",
//"std::os::wasi::io",
// Windows is not yet supported
//"std::os::windows::fs",
//"std::os::windows::io",
],
&[],
),
Expand All @@ -26,7 +29,12 @@ pub(crate) fn get_built_ins() -> BTreeMap<ApiName, ApiConfig> {
result.insert(
ApiName::from("net"),
perm(
&["std::net", "std::os::wasi::net", "std::os::windows::net"],
&[
"std::net",
"std::os::linux::net",
// Windows is not yet supported
//"std::os::windows::net",
],
&[],
),
);
Expand All @@ -39,8 +47,10 @@ pub(crate) fn get_built_ins() -> BTreeMap<ApiName, ApiConfig> {
perm(
&[
"std::process",
"std::os::linux::process",
"std::unix::process",
"std::windows::process",
// Windows is not yet supported
//"std::windows::process",
],
&["std::process::abort", "std::process::exit"],
),
Expand Down
1 change: 0 additions & 1 deletion test_crates/cackle.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ test.allow_apis = [
allow_unsafe = true
build.allow_apis = [
"env",
"fs",
"process",
]
allow_build_instructions = [
Expand Down
10 changes: 5 additions & 5 deletions test_crates/crab-4/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! results from this crate in parallel to crab_1, since neither depends on the other.

use std::ffi::OsString;
use std::path::Path;
use std::fs;

pub fn access_file() {
f1();
Expand All @@ -15,19 +15,19 @@ pub fn access_file() {
}

fn f1() {
let _ = Path::new("a.txt").exists();
let _ = fs::exists("a.txt");
}

fn f2() {
let _ = Path::new("a.txt").exists();
let _ = fs::exists("a.txt");
}

fn f3() {
let _ = Path::new("a.txt").exists();
let _ = fs::exists("a.txt");
}

fn f4() {
let _ = Path::new("a.txt").exists();
let _ = fs::exists("a.txt");
}

/// Make sure that we can't circumvent checks by accessing a function via a function pointer instead
Expand Down
4 changes: 2 additions & 2 deletions test_crates/crab-5/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
//! problems encountered while checking this crate might show up twice, since the two build.rs files
//! can be checked in parallel.

use std::path::Path;
use std::fs;
use std::sync::atomic::AtomicU8;

pub fn do_something() -> bool {
helper()
}

fn helper() -> bool {
let c = || Path::new("/").exists();
let c = || fs::exists("/").is_ok();
c()
}

Expand Down
4 changes: 2 additions & 2 deletions test_crates/crab-7/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::path::Path;
use std::fs;

pub fn do_something() {}

Expand All @@ -8,7 +8,7 @@ extern "C" fn before_main() {
// pre-main activities and with recent versions doing so causes an assertion failure. We can
// apparently still get away with the environment variable check.
if std::env::var("FOO").is_ok() {
println!("Does / exist?: {:?}", Path::new("/").exists());
println!("Does / exist?: {:?}", fs::exists("/").is_ok_and(|exists| exists));
}
}

Expand Down
2 changes: 1 addition & 1 deletion test_crates/crab-8/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub fn print_defaults() {
// Instantiate cra6::print_default with a PathBuf. This shouldn't count as crab_6 using the fs
// API, but it should count as this crate using it.
crab_6::print_default::<std::path::PathBuf>();
crab_6::print_default::<std::sync::LazyLock<std::fs::FileTimes>>();
}