diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index af2cc90..b19fb38 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,7 +23,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: nextest - args: run --all-features --all-targets --retries 2 + args: run --all-features --all-targets --retries 10 fmt: name: Rust fmt diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 605e19a..44c2718 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -22,7 +22,7 @@ jobs: with: command: llvm-cov args: clean --workspace - - run: cargo llvm-cov --all-features --no-fail-fast --lcov --output-path lcov.info + - run: cargo llcargo llvm-cov nextest --all-features --no-fail-fast --lcov --output-path lcov.info -- --retries 10 - name: Upload coverage to Codecov uses: codecov/codecov-action@v1 with: diff --git a/tests/test_heuristics.rs b/tests/test_heuristics.rs index 46ede78..db33759 100644 --- a/tests/test_heuristics.rs +++ b/tests/test_heuristics.rs @@ -269,53 +269,53 @@ fn heuristics_static_wildcard_request_with_dont_filter() -> Result<(), Box in response as well as -// /// in the output file -// fn heuristics_wildcard_test_with_redirect_as_response_code( -// ) -> Result<(), Box> { -// let srv = MockServer::start(); +#[test] +/// test finds a static wildcard that returns 3xx, expect redirects to => in response as well as +/// in the output file +fn heuristics_wildcard_test_with_redirect_as_response_code( +) -> Result<(), Box> { + let srv = MockServer::start(); -// let (tmp_dir, file) = setup_tmp_directory(&["LICENSE".to_string()], "wordlist")?; -// let outfile = tmp_dir.path().join("outfile"); + let (tmp_dir, file) = setup_tmp_directory(&["LICENSE".to_string()], "wordlist")?; + let outfile = tmp_dir.path().join("outfile"); -// let mock = srv.mock(|when, then| { -// when.method(GET) -// .path_matches(Regex::new("/[a-zA-Z0-9]{32}/").unwrap()); -// then.status(301) -// .body("this is a testAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); -// }); + let mock = srv.mock(|when, then| { + when.method(GET) + .path_matches(Regex::new("/[a-zA-Z0-9]{32}/").unwrap()); + then.status(301) + .body("this is a testAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + }); -// let mock2 = srv.mock(|when, then| { -// when.method(GET) -// .path_matches(Regex::new("/[a-zA-Z0-9]{96}/").unwrap()); -// then.status(301) -// .header("Location", &srv.url("/some-redirect")) -// .body("this is a testAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); -// }); + let mock2 = srv.mock(|when, then| { + when.method(GET) + .path_matches(Regex::new("/[a-zA-Z0-9]{96}/").unwrap()); + then.status(301) + .header("Location", &srv.url("/some-redirect")) + .body("this is a testAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); + }); -// let cmd = Command::cargo_bin("feroxbuster") -// .unwrap() -// .arg("--url") -// .arg(srv.url("/")) -// .arg("--wordlist") -// .arg(file.as_os_str()) -// .arg("--add-slash") -// .arg("--output") -// .arg(outfile.as_os_str()) -// .arg("--threads") -// .arg("1") -// .unwrap(); + let cmd = Command::cargo_bin("feroxbuster") + .unwrap() + .arg("--url") + .arg(srv.url("/")) + .arg("--wordlist") + .arg(file.as_os_str()) + .arg("--add-slash") + .arg("--output") + .arg(outfile.as_os_str()) + .arg("--threads") + .arg("1") + .unwrap(); -// let contents = std::fs::read_to_string(outfile).unwrap(); + let contents = std::fs::read_to_string(outfile).unwrap(); -// teardown_tmp_directory(tmp_dir); + teardown_tmp_directory(tmp_dir); -// assert!(contents.contains("WLD")); -// assert!(contents.contains("301")); -// assert!(contents.contains("/some-redirect")); -// assert!(contents.contains(" => ")); -// assert!(contents.contains(&srv.url("/"))); -// assert!(contents.contains("(url length: 32)")); + assert!(contents.contains("WLD")); + assert!(contents.contains("301")); + assert!(contents.contains("/some-redirect")); + assert!(contents.contains(" => ")); + assert!(contents.contains(&srv.url("/"))); + assert!(contents.contains("(url length: 32)")); -// cmd.assert().success().stdout( -// predicate::str::contains(" => ") -// .and(predicate::str::contains("/some-redirect")) -// .and(predicate::str::contains("301")) -// .and(predicate::str::contains(srv.url("/"))) -// .and(predicate::str::contains("(url length: 32)")) -// .and(predicate::str::contains("WLD")), -// ); + cmd.assert().success().stdout( + predicate::str::contains(" => ") + .and(predicate::str::contains("/some-redirect")) + .and(predicate::str::contains("301")) + .and(predicate::str::contains(srv.url("/"))) + .and(predicate::str::contains("(url length: 32)")) + .and(predicate::str::contains("WLD")), + ); -// assert_eq!(mock.hits(), 1); -// assert_eq!(mock2.hits(), 1); -// Ok(()) -// } + assert_eq!(mock.hits(), 1); + assert_eq!(mock2.hits(), 1); + Ok(()) +} // todo figure out why ci hates these tests