Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/heimdall

guests/static-scan/src/wasm.rs

// SPDX-License-Identifier: AGPL-3.0-only
//! The wasm export, bound to heimdall-wasm's WIT world `job`
//! (`crates/heimdall-wasm/wit/heimdall.wit`). Heimdall is a defensive sandbox.
//! `input` is the scan-input envelope; `params` are the job's string pairs.
//! An accepted run emits exactly one file, the findings document.

#![allow(unsafe_code)] // the generated canonical-ABI glue only

wit_bindgen::generate!({ path: "../../crates/heimdall-wasm/wit/heimdall.wit", world: "job" });

struct StaticScan;

impl Guest for StaticScan {
    fn run(input: Vec<u8>, params: Vec<Param>) -> Result<Output, Refusal> {
        match crate::scan_pairs(
            &input,
            params.iter().map(|p| (p.key.as_str(), p.value.as_str())),
        ) {
            crate::Outcome::Report { report, json } => {
                emit_file(heimdall_scan::REPORT_NAME, &json);
                Ok(Output {
                    note: crate::Outcome::note(&report),
                })
            }
            crate::Outcome::Refused { reason } => Err(Refusal { reason }),
        }
    }
}

export!(StaticScan);