Skip to content

Commit 801be8f

Browse files
committed
Rust: Add more tests for std::fs::DirBuilder and similar.
1 parent bc226e2 commit 801be8f

File tree

1 file changed

+6
-1
lines changed
  • rust/ql/test/query-tests/security/CWE-022/src

1 file changed

+6
-1
lines changed

rust/ql/test/query-tests/security/CWE-022/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,22 +117,27 @@ fn sinks(path1: &Path, path2: &Path) {
117117
let _ = std::fs::soft_link(path1, path2); // $ path-injection-sink
118118
let _ = std::fs::symlink_metadata(path1); // $ path-injection-sink
119119
let _ = std::fs::write(path1, "contents"); // $ path-injection-sink
120-
let _ = std::fs::DirBuilder::new().create(path1); // $ path-injection-sink
121120
let _ = std::fs::File::create(path1); // $ path-injection-sink
122121
let _ = std::fs::File::create_buffered(path1); // $ path-injection-sink
123122
let _ = std::fs::File::create_new(path1); // $ path-injection-sink
124123
let _ = std::fs::File::open(path1); // $ path-injection-sink
125124
let _ = std::fs::File::open_buffered(path1); // $ path-injection-sink
125+
let _ = std::fs::DirBuilder::new().create(path1); // $ path-injection-sink
126+
let _ = std::fs::DirBuilder::new().recursive(true).create(path1); // $ path-injection-sink
126127
let _ = std::fs::OpenOptions::new().open(path1); // $ MISSING: path-injection-sink
127128

128129
let _ = tokio::fs::read(path1); // $ MISSING: path-injection-sink
129130
let _ = tokio::fs::read_to_string(path1); // $ MISSING: path-injection-sink
130131
let _ = tokio::fs::remove_file(path1); // $ MISSING: path-injection-sink
132+
let _ = tokio::fs::DirBuilder::new().create(path1); // $ MISSING: path-injection-sink
133+
let _ = tokio::fs::DirBuilder::new().recursive(true).create(path1); // $ MISSING: path-injection-sink
131134
let _ = tokio::fs::OpenOptions::new().open(path1); // $ MISSING: path-injection-sink
132135

133136
let _ = async_std::fs::read(path1); // $ MISSING: path-injection-sink
134137
let _ = async_std::fs::read_to_string(path1); // $ MISSING: path-injection-sink
135138
let _ = async_std::fs::remove_file(path1); // $ MISSING: path-injection-sink
139+
let _ = async_std::fs::DirBuilder::new().create(path1); // $ MISSING: path-injection-sink
140+
let _ = async_std::fs::DirBuilder::new().recursive(true).create(path1); // $ MISSING: path-injection-sink
136141
let _ = async_std::fs::OpenOptions::new().open(path1); // $ MISSING: path-injection-sink
137142
}
138143

0 commit comments

Comments
 (0)