Skip to content

Commit 9d7064d

Browse files
committed
Add a newline to json output.
We don't pretty print the json because it's mostly arrays and that gets us a newline after each element and that's arguably worse. This at least gets us valid text files in the eyes of POSIX.
1 parent 46069cf commit 9d7064d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

verifier-cli/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,8 @@ fn verify<P: AsRef<Path>>(
556556
// write nonce to temp dir
557557
let nonce_path = work_dir.as_ref().join("nonce.json");
558558
info!("writing nonce to: {}", nonce_path.display());
559-
let nonce_str = serde_json::to_string(&nonce)?;
559+
let mut nonce_str = serde_json::to_string(&nonce)?;
560+
nonce_str.push('\n');
560561
fs::write(&nonce_path, nonce_str)?;
561562

562563
// get attestation
@@ -567,7 +568,8 @@ fn verify<P: AsRef<Path>>(
567568
let (attestation, _): (Attestation, _) = hubpack::deserialize(&attestation)
568569
.map_err(|e| anyhow!("Failed to deserialize Attestation: {}", e))?;
569570
// serialize attestation to json & write to file
570-
let attestation = serde_json::to_string(&attestation)?;
571+
let mut attestation = serde_json::to_string(&attestation)?;
572+
attestation.push('\n');
571573
let attestation_path = work_dir.as_ref().join("attest.json");
572574
info!("writing attestation to: {}", attestation_path.display());
573575
fs::write(&attestation_path, &attestation)?;
@@ -578,7 +580,8 @@ fn verify<P: AsRef<Path>>(
578580
attest.log(&mut log)?;
579581
let (log, _): (Log, _) = hubpack::deserialize(&log)
580582
.map_err(|e| anyhow!("Failed to deserialize Log: {}", e))?;
581-
let log = serde_json::to_string(&log)?;
583+
let mut log = serde_json::to_string(&log)?;
584+
log.push('\n');
582585
let log_path = work_dir.as_ref().join("log.json");
583586
info!("writing measurement log to: {}", log_path.display());
584587
fs::write(&log_path, &log)?;

0 commit comments

Comments
 (0)