Skip to content

Commit 328282a

Browse files
authored
Merge pull request #505 from flavio/feat-allow-building-sigstore-trust-root-from-json
feat: allow creation of SigstoreTrustRoot from JSON data
2 parents 39b2f6f + 92f48a0 commit 328282a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/trust/sigstore/mod.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,19 @@ impl SigstoreTrustRoot {
7777
Self::from_tough(&repository, cache_dir).await
7878
}
7979

80+
/// Constructs a new trust root from a JSON object containing a
81+
/// [`TrustedRoot`](https://github.com/sigstore/protobuf-specs).
82+
///
83+
/// # Warning
84+
///
85+
/// This constructor does not perform any validation of the provided data.
86+
/// The caller must ensure that the data is trustworthy.
87+
/// Using untrusted data may lead to security vulnerabilities.
88+
pub fn from_trusted_root_json_unchecked(data: &[u8]) -> Result<Self> {
89+
let trusted_root: TrustedRoot = serde_json::from_slice(data)?;
90+
Ok(Self { trusted_root })
91+
}
92+
8093
async fn fetch_target<N>(
8194
repository: &tough::Repository,
8295
checkout_dir: Option<&Path>,

0 commit comments

Comments
 (0)