feat(report): executive report at /relatorio with a Relatório button
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and clippy (push) Successful in 13s
CI / Tests (Linux) (push) Successful in 34s
CI / Dependency audit (push) Successful in 10s
Release / ci (push) Successful in 57s
Release / Build image (arm64) (push) Failing after 28s
Release / Build image (amd64) (push) Successful in 7m14s
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
Release / Plan (reuse the published image?) (push) Successful in 4s
CI / Docker image (build and smoke test) (push) Skipped
CI / Format and clippy (push) Successful in 13s
CI / Tests (Linux) (push) Successful in 34s
CI / Dependency audit (push) Successful in 10s
Release / ci (push) Successful in 57s
Release / Build image (arm64) (push) Failing after 28s
Release / Build image (amd64) (push) Successful in 7m14s
Release / Publish tags (push) Skipped
Release / Gitea release (push) Skipped
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6a14c29b97
commit
a218111996
13 files changed
+1034
-1
No files matched your search
@@ -4,13 +4,14 @@ use acaua_core::update::UpdateStatus;
|
||||
use acaua_core::zeek::{self, AnalysisReport};
|
||||
use acaua_core::{update, Result};
|
||||
use axum::body::Body;
|
||||
use axum::extract::State;
|
||||
use axum::extract::{Query, State};
|
||||
use axum::http::{header, StatusCode, Uri};
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use axum::routing::{get, post};
|
||||
use axum::{Json, Router};
|
||||
use rust_embed::RustEmbed;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use tokio::net::TcpListener;
|
||||
@@ -101,6 +102,28 @@ async fn analyze(
|
||||
})
|
||||
}
|
||||
|
||||
/// Executive report of the latest analysis (`?tlp=` picks the TLP label).
|
||||
async fn report_page(
|
||||
State(state): State<AppState>,
|
||||
Query(query): Query<HashMap<String, String>>,
|
||||
) -> Response {
|
||||
let lock = state.last_report.lock().unwrap();
|
||||
let Some(report) = lock.as_ref() else {
|
||||
return (
|
||||
StatusCode::NOT_FOUND,
|
||||
[(header::CONTENT_TYPE, "text/html; charset=utf-8")],
|
||||
"<!doctype html><meta charset=\"utf-8\"><title>Acauã</title><p>Nenhuma análise executada. Rode uma análise no painel e abra o relatório de novo.</p>",
|
||||
)
|
||||
.into_response();
|
||||
};
|
||||
let options = acaua_core::report::ReportOptions {
|
||||
tlp: query.get("tlp").cloned().unwrap_or_else(|| "AMBER".into()),
|
||||
issued_at: None,
|
||||
};
|
||||
let html = acaua_core::report::render_html_with(report, &options);
|
||||
([(header::CONTENT_TYPE, "text/html; charset=utf-8")], html).into_response()
|
||||
}
|
||||
|
||||
async fn update_check() -> std::result::Result<Json<UpdateStatus>, (StatusCode, Json<ErrorBody>)> {
|
||||
update::check(env!("CARGO_PKG_VERSION"))
|
||||
.map(Json)
|
||||
@@ -167,6 +190,7 @@ pub async fn serve(bind: &str, data_dir: PathBuf) -> Result<()> {
|
||||
.route("/api/alerts", get(alerts))
|
||||
.route("/api/analyze", post(analyze))
|
||||
.route("/api/update", get(update_check))
|
||||
.route("/relatorio", get(report_page))
|
||||
.route("/logo.png", get(logo))
|
||||
.fallback(asset)
|
||||
.with_state(state)
|
||||
|
||||
Reference in new issue
Block a user