Skip to content

Commit

Permalink
Merge pull request #292 from flavio/allow-fulcio-and-rekor-data-to-be…
Browse files Browse the repository at this point in the history
…-none

Allow fulcio and rekor data to be None
  • Loading branch information
flavio authored Jul 18, 2022
2 parents 5671a08 + 99c2f0e commit f1c651a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 25 deletions.
31 changes: 16 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "policy-server"
version = "1.1.0"
version = "1.1.1"
authors = [
"Flavio Castelli <[email protected]>",
"Rafael Fernández López <[email protected]>",
Expand All @@ -11,7 +11,7 @@ edition = "2018"
[dependencies]
anyhow = "1.0"
itertools = "0.10.3"
policy-evaluator = { git = "https://github.com/kubewarden/policy-evaluator", tag = "v0.4.4" }
policy-evaluator = { git = "https://github.com/kubewarden/policy-evaluator", tag = "v0.4.5" }
lazy_static = "1.4.0"
clap = { version = "3.2.10", features = [ "cargo", "env" ] }
k8s-openapi = { version = "0.15.0", default-features = false, features = ["v1_24"] }
Expand Down
1 change: 1 addition & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pub(crate) fn setup_tracing(matches: &clap::ArgMatches) -> Result<()> {
// let's filter them
.add_directive("cranelift_codegen=off".parse().unwrap())
.add_directive("cranelift_wasm=off".parse().unwrap())
.add_directive("wasmtime_cranelift=off".parse().unwrap())
.add_directive("regalloc=off".parse().unwrap())
.add_directive("hyper=off".parse().unwrap())
.add_directive("h2=off".parse().unwrap())
Expand Down
19 changes: 16 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,26 @@ fn main() -> Result<()> {
let (callback_handler_shutdown_channel_tx, callback_handler_shutdown_channel_rx) =
oneshot::channel();

let repo = sigstore::tuf::SigstoreRepository::fetch(None)?;
let fulcio_and_rekor_data = FulcioAndRekorData::FromTufRepository { repo };
let fulcio_and_rekor_data = match sigstore::tuf::SigstoreRepository::fetch(None) {
Ok(repo) => Some(FulcioAndRekorData::FromTufRepository { repo }),
Err(e) => {
// We cannot rely on `tracing` yet, because the tracing system has not
// been initialized, this has to be done inside of an async block, which
// we cannot use yet
eprintln!("Cannot fetch TUF repository: {:?}", e);
eprintln!("Sigstore Verifier created without Fulcio data: keyless signatures are going to be discarded because they cannot be verified");
eprintln!(
"Sigstore Verifier created without Rekor data: transparency log data won't be used"
);
eprintln!("Sigstore capabilities are going to be limited");
None
}
};

let mut callback_handler = CallbackHandlerBuilder::default()
.registry_config(sources.clone(), docker_config.clone())
.shutdown_channel(callback_handler_shutdown_channel_rx)
.fulcio_and_rekor_data(&fulcio_and_rekor_data)
.fulcio_and_rekor_data(fulcio_and_rekor_data.as_ref())
.build()?;
let callback_sender_channel = callback_handler.sender_channel();

Expand Down
23 changes: 18 additions & 5 deletions src/policy_downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,24 @@ async fn create_verifier(
None => sigstore::tuf::SigstoreRepository::fetch(None),
})
.await
.map_err(|e| anyhow!("Cannot spawn blocking task: {}", e))?
.map_err(|e| anyhow!("Cannot create TUF repository: {}", e))?;

let fulcio_and_rekor_data = FulcioAndRekorData::FromTufRepository { repo };
Verifier::new(sources, &fulcio_and_rekor_data)
.map_err(|e| anyhow!("Cannot spawn blocking task: {}", e))?;

let fulcio_and_rekor_data = match repo {
Ok(repo) => Some(FulcioAndRekorData::FromTufRepository { repo }),
Err(e) => {
// We cannot rely on `tracing` yet, because the tracing system has not
// been initialized, this has to be done inside of an async block, which
// we cannot use yet
eprintln!("Cannot fetch TUF repository: {:?}", e);
eprintln!("Sigstore Verifier created without Fulcio data: keyless signatures are going to be discarded because they cannot be verified");
eprintln!(
"Sigstore Verifier created without Rekor data: transparency log data won't be used"
);
eprintln!("Sigstore capabilities are going to be limited");
None
}
};
Verifier::new(sources, fulcio_and_rekor_data.as_ref())
}

#[cfg(test)]
Expand Down

0 comments on commit f1c651a

Please sign in to comment.