cargo-xss-testing 0.4.6

XSS vulnerability test for docs.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::{fs, path::Path};

fn main() {
    // let content = fs::read_to_string("inject.html").unwrap();
    // let one_line = content.replace('\n', "").replace('\r', ""); // Removes newlines

    // let dest_path = Path::new(&"./src").join("inject.txt");
    // fs::write(dest_path, one_line).unwrap();

    // inject into OUT_DIR target/doc/static.files/inject.js
    let content = fs::read_to_string("doc/test.js").unwrap();

    fs::create_dir_all("target/doc/static.files").unwrap();
    fs::write("target/doc/static.files/inject.js", content).unwrap();
}