sigstore_verification/sources/
mod.rs1pub mod file;
2pub mod github;
3pub mod oci;
4
5use crate::Result;
6use async_trait::async_trait;
7use std::path::Path;
8
9#[derive(Debug, Clone)]
11pub struct ArtifactRef {
12 pub digest: String,
14 pub path: Option<String>,
16 pub metadata: Option<serde_json::Value>,
18}
19
20impl ArtifactRef {
21 pub fn from_path(path: &Path) -> Result<Self> {
22 let digest = crate::calculate_file_digest(path)?;
23 Ok(Self {
24 digest: format!("sha256:{}", digest),
25 path: Some(path.to_string_lossy().to_string()),
26 metadata: None,
27 })
28 }
29
30 pub fn from_digest(digest: &str) -> Self {
31 Self {
32 digest: digest.to_string(),
33 path: None,
34 metadata: None,
35 }
36 }
37}
38
39#[async_trait]
41pub trait AttestationSource: Send + Sync {
42 async fn fetch_attestations(
44 &self,
45 artifact: &ArtifactRef,
46 ) -> Result<Vec<crate::api::Attestation>>;
47
48 fn source_type(&self) -> &'static str;
50}