Skip to content
Open
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
8 changes: 6 additions & 2 deletions sdk/src/validation_results.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ use crate::{
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "json_schema", derive(JsonSchema))]
pub enum ValidationState {
/// Validation is disabled in the SDK and the [ValidationState] is unable to be determined.
Unknown,
/// The manifest store fails to meet [ValidationState::WellFormed] requirements, meaning it cannot
/// even be parsed or its basic structure is non-compliant.
///
/// This case may also occur if validation is disabled in the SDK.
Invalid,
/// The manifest store is well-formed and the cryptographic integrity checks succeed.
///
Expand Down Expand Up @@ -238,6 +238,10 @@ impl ValidationResults {
} else if is_valid {
return ValidationState::Valid;
}
} else {
// REVIEW-NOTE: is this the best way to detect that it wasn't validated? should we also check if success/failure is empty if there
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? I'm not sure if there will always be no active manifest in validation_results if we did not validate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// Validation status codes for the ingredient's active manifest. Present if ingredient is a C2PA
/// asset. Not present if the ingredient is not a C2PA asset.
#[serde(rename = "activeManifest", skip_serializing_if = "Option::is_none")]
active_manifest: Option<StatusCodes>,

I think it's a safe assumption that if there's no active_manifest then it hasn't been validated, or at the very least it couldn't be determined. The only problem is that we populate the validation results on a Reader::post_validate, so it's possible that normal validation is disabled but since it was post validated the state shows as invalid (or possibly even valid?).

// is an active manifest?
return ValidationState::Unknown;
}

ValidationState::Invalid
Expand Down