Skip to content

Commit

Permalink
Clippy and SW compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Cashmaney committed Aug 13, 2023
1 parent 45f6832 commit 6085987
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cosmwasm/enclaves/execute/src/registration/attestation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ pub const DEV_HOSTNAME: &str = "api.trustedservices.intel.com";
#[cfg(feature = "production")]
pub const SIGRL_SUFFIX: &str = "/sgx/attestation/v5/sigrl/";
#[cfg(feature = "production")]
pub const REPORT_SUFFIX: &str = "/sgx/attestation/v5/report&update=early";
pub const REPORT_SUFFIX: &str = "/sgx/attestation/v5/report?update=early";

#[cfg(feature = "production")]
pub const LEGACY_REPORT_SUFFIX: &str = "/sgx/attestation/v5/report";
Expand All @@ -85,7 +85,7 @@ pub const LEGACY_REPORT_SUFFIX: &str = "/sgx/dev/attestation/v5/report";
#[cfg(all(feature = "SGX_MODE_HW", not(feature = "production")))]
pub const SIGRL_SUFFIX: &str = "/sgx/dev/attestation/v5/sigrl/";
#[cfg(all(feature = "SGX_MODE_HW", not(feature = "production")))]
pub const REPORT_SUFFIX: &str = "/sgx/dev/attestation/v5/report&update=early";
pub const REPORT_SUFFIX: &str = "/sgx/dev/attestation/v5/report?update=early";

/// extra_data size that will store the public key of the attesting node
#[cfg(feature = "SGX_MODE_HW")]
Expand Down
13 changes: 6 additions & 7 deletions cosmwasm/enclaves/execute/src/registration/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,12 @@ impl AttestationReport {
// Verify and extract information from attestation report
let attn_report: Value = serde_json::from_slice(&report.report)?;
trace!("attn_report: {}", attn_report);

// Verify API version is supported
let version = attn_report["version"]
.as_u64()
.ok_or(Error::ReportParseError)?;

if version != 4 {
if version != 5 {
warn!("API version incompatible");
return Err(Error::ReportParseError);
};
Expand Down Expand Up @@ -712,8 +711,8 @@ impl AttestationReport {
};

let advisories: Vec<String> = if let Some(raw) = attn_report.get("advisoryIDs") {
serde_json::from_value(raw.clone()).map_err(|_| {
warn!("Failed to decode advisories");
serde_json::from_value(raw.clone()).map_err(|e| {
warn!("Failed to decode advisories: {}", e);
Error::ReportParseError
})?
} else {
Expand All @@ -731,9 +730,9 @@ impl AttestationReport {
// We don't actually validate the public key, since we use ephemeral certificates,
// and all we really care about that the report is valid and the key that is saved in the
// report_data field

let time = chrono::DateTime::parse_from_rfc3339(timestamp_str).map_err(|_| {
warn!("Failed to decode advisories");
let timestamp_rfc = format!("{}Z", timestamp_str);
let time = chrono::DateTime::parse_from_rfc3339(&timestamp_rfc).map_err(|e| {
warn!("Failed to decode timestamp: {}", e);
Error::ReportParseError
})?;
let timestamp_since_epoch = time.timestamp();
Expand Down

0 comments on commit 6085987

Please sign in to comment.