use crate::graph::GraphNode;
use anyhow::Result;
use serde_json::json;
pub fn generate_intoto_statement(nodes: &[GraphNode]) -> Result<serde_json::Value> {
let subject: Vec<serde_json::Value> = nodes
.iter()
.map(|node| {
json!({
"name": format!("{}:{}", node.ecosystem, node.package_name),
"digest": {
"sha256": node.content_hash.trim_start_matches("sha256:")
}
})
})
.collect();
let statement = json!({
"_type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://in-toto.io/attestation/link/v0.1",
"subject": subject,
"predicate": {
"byproducts": {},
"command": ["rivox", "build"],
"environment": {
"builder": "rivox-v0.1.0"
},
"materials": []
}
});
Ok(statement)
}