Release / Build image (amd64) (push) Successful in 10m49s
Release / Plan (reuse the published image?) (push) Successful in 5s
Release / ci (push) Successful in 20m40s
CI / Format and clippy (push) Successful in 5m43s
CI / Tests (Linux) (push) Successful in 16m5s
CI / Dependency audit (push) Successful in 11s
CI / Docker image (build and smoke test) (push) Skipped
Release / Build image (arm64) (push) Successful in 7m34s
Release / Publish tags (push) Successful in 15s
Release / Gitea release (push) Skipped
Release / CLI (linux-aarch64) (push) Skipped
Release / CLI (linux-x86_64) (push) Skipped
Renames the whole project, after the harpy eagle: crates (xexeu-core/xexeu-cli -> harpia-core/harpia-cli), binary (xexeu -> harpia), admin token env var (XEXEU_ADMIN_TOKEN -> HARPIA_ADMIN_TOKEN), compose env vars (XEXEU_* -> HARPIA_*), container image (ciberfauna/xexeu -> ciberfauna/harpia) and the Gitea repository (ciberfauna/xexeu -> ciberfauna/harpia). Logo updated to the new brand artwork. All docs (EN/PT-BR), CI workflows, scripts, GUI strings and the openspec change history updated to match. BREAKING CHANGE: binary, crate, env var and image names all changed; existing .env files, scripts and deployments referencing the old xexeu/XEXEU names must be updated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VAyr8cd6jzwpJM9cS1oGjy
122 lines
4.0 KiB
Rust
122 lines
4.0 KiB
Rust
use std::io::{BufRead, BufReader, Read, Write};
|
|
use std::net::TcpStream;
|
|
use std::path::Path;
|
|
use std::process::{Command, Stdio};
|
|
use std::time::{Duration, Instant};
|
|
|
|
struct ChildGuard(std::process::Child);
|
|
|
|
impl Drop for ChildGuard {
|
|
fn drop(&mut self) {
|
|
let _ = self.0.kill();
|
|
let _ = self.0.wait();
|
|
}
|
|
}
|
|
|
|
fn http_get(addr: &str, path: &str) -> (u16, String) {
|
|
let mut stream = TcpStream::connect(addr).expect("connect to server");
|
|
stream
|
|
.set_read_timeout(Some(Duration::from_secs(3)))
|
|
.expect("set read timeout");
|
|
let request = format!("GET {path} HTTP/1.1\r\nHost: {addr}\r\nConnection: close\r\n\r\n");
|
|
stream.write_all(request.as_bytes()).expect("write request");
|
|
let mut bytes = Vec::new();
|
|
stream.read_to_end(&mut bytes).expect("read response");
|
|
let response = String::from_utf8_lossy(&bytes).to_string();
|
|
let status_line = response.lines().next().unwrap_or("");
|
|
let code: u16 = status_line
|
|
.split_whitespace()
|
|
.nth(1)
|
|
.unwrap_or("0")
|
|
.parse()
|
|
.unwrap_or(0);
|
|
let body = response.split("\r\n\r\n").nth(1).unwrap_or("").to_string();
|
|
(code, body)
|
|
}
|
|
|
|
#[test]
|
|
fn serve_validates_against_real_dvwa_scan_data() {
|
|
let validate_dir = Path::new("/tmp/harpia-validate");
|
|
if !validate_dir.exists() {
|
|
eprintln!("skip: /tmp/harpia-validate does not exist");
|
|
return;
|
|
}
|
|
|
|
let config_path = validate_dir.join("harpia.toml");
|
|
let sweeps_dir = validate_dir.join("sweeps");
|
|
let data_dir = validate_dir.join("data");
|
|
|
|
let mut child = Command::new(env!("CARGO_BIN_EXE_harpia"))
|
|
.args([
|
|
"serve",
|
|
"--bind",
|
|
"127.0.0.1:0",
|
|
"--config",
|
|
config_path.to_str().expect("config"),
|
|
"--sweeps",
|
|
sweeps_dir.to_str().expect("sweeps"),
|
|
"--data-dir",
|
|
data_dir.to_str().expect("data"),
|
|
])
|
|
.stdout(Stdio::piped())
|
|
.stderr(Stdio::inherit())
|
|
.spawn()
|
|
.expect("spawn harpia serve");
|
|
|
|
let stdout = child.stdout.take().expect("take stdout");
|
|
let mut reader = BufReader::new(stdout);
|
|
let mut server_addr = None;
|
|
let deadline = Instant::now() + Duration::from_secs(5);
|
|
|
|
while Instant::now() < deadline {
|
|
let mut line = String::new();
|
|
if reader.read_line(&mut line).unwrap_or(0) > 0 {
|
|
if let Some(pos) = line.find("http://") {
|
|
let rest = &line[pos + "http://".len()..];
|
|
let addr = rest.split_whitespace().next().unwrap_or("").trim();
|
|
server_addr = Some(addr.to_string());
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
let _guard = ChildGuard(child);
|
|
let server_addr = server_addr.expect("server listening addr");
|
|
|
|
// Poll /api/hosts
|
|
let poll_deadline = Instant::now() + Duration::from_secs(6);
|
|
let mut dvwa_found = false;
|
|
while Instant::now() < poll_deadline {
|
|
let (status, body) = http_get(&server_addr, "/api/hosts");
|
|
if status == 200 && body.contains("172.30.0.10") && body.contains("CVE-2017-3167") {
|
|
dvwa_found = true;
|
|
assert!(body.contains("Apache HTTP Server"));
|
|
assert!(body.contains("2.4.25"));
|
|
assert!(body.contains(r#""cvss":9.8"#));
|
|
break;
|
|
}
|
|
std::thread::sleep(Duration::from_millis(300));
|
|
}
|
|
|
|
assert!(
|
|
dvwa_found,
|
|
"expected DVWA host 172.30.0.10 with CVE-2017-3167 in /api/hosts"
|
|
);
|
|
|
|
// Check dashboard and static assets
|
|
let (status, body) = http_get(&server_addr, "/");
|
|
assert_eq!(status, 200);
|
|
assert!(body.contains("Harpia"));
|
|
|
|
let (status, body) = http_get(&server_addr, "/app.css");
|
|
assert_eq!(status, 200);
|
|
assert!(body.contains("--sev-critical"));
|
|
|
|
let (status, body) = http_get(&server_addr, "/app.js");
|
|
assert_eq!(status, 200);
|
|
assert!(body.contains("renderSeverityChart"));
|
|
|
|
let (status, _) = http_get(&server_addr, "/logo.png");
|
|
assert_eq!(status, 200);
|
|
}
|