20260727 修复缓存回放丢失reject reason(#132):缓存artifact增加reject_reason字段,fresh验证记录真实原因,VCIR/PP cache回放还原,旧缓存给后备文案
This commit is contained in:
@@ -3840,6 +3840,28 @@ fn audit_result_from_vcir_status(status: VcirArtifactValidationStatus) -> AuditO
|
||||
}
|
||||
}
|
||||
|
||||
/// Fallback detail for cached artifacts rejected by an earlier run whose cache
|
||||
/// entry predates reject-reason recording (field added 2026-07-27).
|
||||
const CACHED_REJECT_REASON_NOT_RECORDED: &str =
|
||||
"rejected in an earlier validation run (reject reason not recorded in cache)";
|
||||
|
||||
/// Detail for an audit entry rebuilt from a cached artifact: the real reject
|
||||
/// reason when the cache recorded one, an explicit fallback for legacy cache
|
||||
/// entries, and `None` for non-rejected artifacts.
|
||||
fn audit_detail_from_vcir_status(
|
||||
status: VcirArtifactValidationStatus,
|
||||
reject_reason: Option<&str>,
|
||||
) -> Option<String> {
|
||||
match status {
|
||||
VcirArtifactValidationStatus::Rejected => Some(
|
||||
reject_reason
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| CACHED_REJECT_REASON_NOT_RECORDED.to_string()),
|
||||
),
|
||||
VcirArtifactValidationStatus::Accepted | VcirArtifactValidationStatus::WarningOnly => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_publication_point_audit_from_snapshot(
|
||||
ca: &CaInstanceHandle,
|
||||
source: PublicationPointSource,
|
||||
@@ -4059,7 +4081,10 @@ fn build_publication_point_audit_from_vcir(
|
||||
sha256_hex: artifact.sha256.clone(),
|
||||
kind: kind_from_vcir_artifact_kind(artifact.artifact_kind),
|
||||
result: audit_result_from_vcir_status(artifact.validation_status),
|
||||
detail: None,
|
||||
detail: audit_detail_from_vcir_status(
|
||||
artifact.validation_status,
|
||||
artifact.reject_reason.as_deref(),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -4170,7 +4195,10 @@ fn build_publication_point_audit_from_publication_point_cache_projection(
|
||||
sha256_hex: artifact.sha256.clone(),
|
||||
kind: kind_from_vcir_artifact_kind(artifact.artifact_kind),
|
||||
result: audit_result_from_vcir_status(artifact.validation_status),
|
||||
detail: None,
|
||||
detail: audit_detail_from_vcir_status(
|
||||
artifact.validation_status,
|
||||
artifact.reject_reason.as_deref(),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -6003,9 +6031,9 @@ fn build_vcir_related_artifacts(
|
||||
objects: &crate::validation::objects::ObjectsOutput,
|
||||
child_audits: &[ObjectAuditEntry],
|
||||
) -> Vec<VcirRelatedArtifact> {
|
||||
let mut audit_by_uri: HashMap<&str, AuditObjectResult> = HashMap::new();
|
||||
let mut audit_by_uri: HashMap<&str, &ObjectAuditEntry> = HashMap::new();
|
||||
for entry in child_audits.iter().chain(objects.audit.iter()) {
|
||||
audit_by_uri.insert(entry.rsync_uri.as_str(), entry.result.clone());
|
||||
audit_by_uri.insert(entry.rsync_uri.as_str(), entry);
|
||||
}
|
||||
|
||||
let mut artifacts = Vec::with_capacity(pack.files.len() + 2);
|
||||
@@ -6016,6 +6044,7 @@ fn build_vcir_related_artifacts(
|
||||
sha256: sha256_hex(&pack.manifest_bytes),
|
||||
object_type: Some("mft".to_string()),
|
||||
validation_status: VcirArtifactValidationStatus::Accepted,
|
||||
reject_reason: None,
|
||||
});
|
||||
artifacts.push(VcirRelatedArtifact {
|
||||
artifact_role: if ca.parent_manifest_rsync_uri.is_none() {
|
||||
@@ -6035,13 +6064,20 @@ fn build_vcir_related_artifacts(
|
||||
}),
|
||||
object_type: Some("cer".to_string()),
|
||||
validation_status: VcirArtifactValidationStatus::Accepted,
|
||||
reject_reason: None,
|
||||
});
|
||||
|
||||
for file in &pack.files {
|
||||
let result = audit_by_uri
|
||||
.get(file.rsync_uri.as_str())
|
||||
.cloned()
|
||||
let audit_entry = audit_by_uri.get(file.rsync_uri.as_str()).copied();
|
||||
let result = audit_entry
|
||||
.map(|entry| entry.result.clone())
|
||||
.unwrap_or(AuditObjectResult::Ok);
|
||||
let validation_status = audit_result_to_vcir_status(&result);
|
||||
let reject_reason = if validation_status == VcirArtifactValidationStatus::Rejected {
|
||||
audit_entry.and_then(|entry| entry.detail.clone())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (artifact_role, artifact_kind) = artifact_role_and_kind(file, current_crl_rsync_uri);
|
||||
artifacts.push(VcirRelatedArtifact {
|
||||
artifact_role,
|
||||
@@ -6049,7 +6085,8 @@ fn build_vcir_related_artifacts(
|
||||
uri: Some(file.rsync_uri.clone()),
|
||||
sha256: sha256_hex_from_32(&file.sha256),
|
||||
object_type: object_type_from_uri(file.rsync_uri.as_str()),
|
||||
validation_status: audit_result_to_vcir_status(&result),
|
||||
validation_status,
|
||||
reject_reason,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user