Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print a more meaningful message when decoding an object fails. #924

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,9 +818,12 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
manifest_bytes.clone(), self.run.validation.strict
) {
Ok(manifest) => manifest,
Err(err) => {
Err(_) => {
self.metrics.invalid_manifests += 1;
warn!("{}: {}.", self.cert.rpki_manifest(), err);
warn!(
"{}: failed to decode manifest.",
self.cert.rpki_manifest()
);
return Ok(None)
}
};
Expand Down Expand Up @@ -945,9 +948,9 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
// Decode and validate the CRL.
let mut crl = match Crl::decode(crl_bytes.clone()) {
Ok(crl) => crl,
Err(err) => {
Err(_) => {
self.metrics.invalid_crls += 1;
warn!("{}: {}.", crl_uri, err);
warn!("{}: failed to decode CRL.", crl_uri);
return Ok(None)
}
};
Expand Down Expand Up @@ -1077,9 +1080,12 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
stored_manifest.manifest().clone(), self.run.validation.strict
) {
Ok(manifest) => manifest,
Err(err) => {
warn!("{}: {}.", self.cert.rpki_manifest(), err);
Err(_) => {
self.metrics.invalid_manifests += 1;
warn!(
"{}: failed to decode manifest.",
self.cert.rpki_manifest(),
);
return Err(Failed);
}
};
Expand Down Expand Up @@ -1125,10 +1131,10 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
// Decode and validate the CRL.
let mut crl = match Crl::decode(stored_manifest.crl().clone()) {
Ok(crl) => crl,
Err(err) => {
warn!("{}: {}.", crl_uri, err);
Err(_) => {
self.metrics.invalid_manifests += 1;
self.metrics.invalid_crls += 1;
warn!("{}: failed to decode CRL.", crl_uri);
return Err(Failed)
}
};
Expand Down Expand Up @@ -1271,9 +1277,9 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
) -> Result<(), Failed> {
let cert = match Cert::decode(content) {
Ok(cert) => cert,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
manifest.metrics.invalid_certs += 1;
warn!("{}: failed to decode certificate.", uri);
return Ok(())
}
};
Expand Down Expand Up @@ -1386,9 +1392,9 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
content, self.run.validation.strict
) {
Ok(roa) => roa,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
manifest.metrics.invalid_roas += 1;
warn!("{}: failed to decode ROA.", uri);
return Ok(())
}
};
Expand Down Expand Up @@ -1421,8 +1427,8 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
) {
Ok(aspa) => aspa,
Err(err) => {
warn!("{}: {}.", uri, err);
manifest.metrics.invalid_aspas += 1;
warn!("{}: failed to decode ASPA.", uri);
return Ok(())
}
};
Expand Down Expand Up @@ -1453,9 +1459,9 @@ impl<'a, P: ProcessRun> PubPoint<'a, P> {
content, self.run.validation.strict
) {
Ok(obj) => obj,
Err(err) => {
warn!("{}: {}.", uri, err);
Err(_) => {
manifest.metrics.invalid_gbrs += 1;
warn!("{}: failed to decode GBR.", uri);
return Ok(())
}
};
Expand Down
Loading