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
84 lines
2.2 KiB
Rust
84 lines
2.2 KiB
Rust
use std::fs;
|
|
use std::net::TcpListener;
|
|
use std::process::Command;
|
|
|
|
use harpia_core::batch::{SweepBatch, SweepStatus};
|
|
use tempfile::TempDir;
|
|
|
|
#[test]
|
|
fn scan_once_writes_a_complete_batch_with_the_open_port() {
|
|
let listener = TcpListener::bind("127.0.0.1:0").expect("bind loopback listener");
|
|
let port = listener.local_addr().expect("listener address").port();
|
|
std::thread::spawn(move || {
|
|
for stream in listener.incoming() {
|
|
if stream.is_err() {
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
|
|
let workspace = TempDir::new().expect("temporary directory");
|
|
let config = workspace.path().join("harpia.toml");
|
|
fs::write(
|
|
&config,
|
|
format!(
|
|
r#"
|
|
[escopo]
|
|
autorizado = ["127.0.0.1/32"]
|
|
responsavel = "teste"
|
|
|
|
[padrao]
|
|
cron = "@daily"
|
|
hosts_simultaneos = 2
|
|
|
|
[perfis.padrao]
|
|
tcp = "{port}"
|
|
|
|
[[grupo]]
|
|
nome = "local"
|
|
alvos = ["127.0.0.1/32"]
|
|
"#
|
|
),
|
|
)
|
|
.expect("write configuration");
|
|
|
|
let sweeps = workspace.path().join("sweeps");
|
|
let output = Command::new(env!("CARGO_BIN_EXE_harpia"))
|
|
.args([
|
|
"scan",
|
|
"--group",
|
|
"local",
|
|
"--once",
|
|
"--config",
|
|
config.to_str().expect("config path"),
|
|
"--out",
|
|
sweeps.to_str().expect("sweeps path"),
|
|
])
|
|
.output()
|
|
.expect("run harpia scan");
|
|
|
|
assert!(
|
|
output.status.success(),
|
|
"scan failed: {}",
|
|
String::from_utf8_lossy(&output.stderr)
|
|
);
|
|
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
assert!(stdout.contains("vivos: 1"), "unexpected stdout: {stdout}");
|
|
|
|
let group_dir = sweeps.join("local");
|
|
let sweep_dir = fs::read_dir(&group_dir)
|
|
.expect("group directory")
|
|
.next()
|
|
.expect("one sweep")
|
|
.expect("sweep entry")
|
|
.path();
|
|
|
|
let batch = SweepBatch::read(&sweep_dir).expect("read batch");
|
|
assert_eq!(batch.manifest.status, SweepStatus::Complete);
|
|
assert_eq!(batch.manifest.group, "local");
|
|
assert_eq!(batch.alive_hosts().count(), 1);
|
|
|
|
let open: Vec<u16> = batch.open_ports("127.0.0.1".parse().expect("ip")).collect();
|
|
assert_eq!(open, vec![port]);
|
|
}
|