Skip to content

Commit 8f36bf4

Browse files
KixironJoshua Nelson
authored and
Joshua Nelson
committed
Added some small tests
1 parent 2993499 commit 8f36bf4

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fn main() {
2323
println!("cargo:rerun-if-changed=templates/menu.js");
2424
println!("cargo:rerun-if-changed=templates/index.js");
2525
println!("cargo:rerun-if-changed=vendor/");
26+
println!("cargo:rerun-if-changed=vendor/fontawesome/scss/_variables.scss");
2627
// TODO: are these right?
2728
println!("cargo:rerun-if-changed=.git/HEAD");
2829
println!("cargo:rerun-if-changed=.git/index");

src/web/statics.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,26 @@ mod tests {
249249
Ok(())
250250
});
251251
}
252+
253+
#[test]
254+
fn directory_traversal() {
255+
wrapper(|env| {
256+
let web = env.frontend();
257+
258+
let urls = &[
259+
"../LICENSE.txt",
260+
"%2e%2e%2fLICENSE.txt",
261+
"%2e%2e/LICENSE.txt",
262+
"..%2fLICENSE.txt",
263+
"%2e%2e%5cLICENSE.txt",
264+
];
265+
266+
for url in urls {
267+
let req = web.get(&format!("/-/static/{}", url)).send()?;
268+
assert_eq!(req.status().as_u16(), 404);
269+
}
270+
271+
Ok(())
272+
});
273+
}
252274
}

0 commit comments

Comments
 (0)