@@ -8,9 +8,6 @@ use crate::{
88
99/// Reads a manifest and verifys it from the EXISTING key. This is best for GENERAL reading.
1010///
11- /// # Warning
12- /// Do NOT run on downloaded manifests before `read_manifest_signed`, or else potentially malicious inputs will be parsed.
13- ///
1411/// # Errors
1512///
1613/// - Filesystem errors (Permissions or doesn't exist)
@@ -37,26 +34,6 @@ fn read_manifest_unsigned(repo_path: &Path) -> Result<RepoManifest> {
3734 Ok ( manifest)
3835}
3936
40- /// Reads a manifest and verifys it. This is best for WHEN it has been downloaded.
41- ///
42- /// # Errors
43- ///
44- /// - Filesystem errors (Permissions or doesn't exist)
45- /// - Invalid signature
46- pub fn read_manifest_signed ( repo_path : & Path , public_key_serialized : & str ) -> Result < RepoManifest > {
47- let manifest_serialized = fs:: read_to_string ( repo_path. join ( "manifest.yml" ) ) ?;
48- let manifest_signature_serialized = fs:: read ( repo_path. join ( "manifest.yml.sig" ) ) ?;
49-
50- verify_signature (
51- & manifest_serialized,
52- & manifest_signature_serialized,
53- deserialize_verifying_key ( public_key_serialized) ?,
54- ) ?;
55-
56- let manifest = serde_yaml:: from_str ( & manifest_serialized) ?;
57- Ok ( manifest)
58- }
59-
6037/// Replaces the existing manifest with another one, and verifies that it is correct
6138///
6239/// # Errors
@@ -104,7 +81,8 @@ pub fn atomic_replace(base_path: &Path, filename: &str, contents: &[u8]) -> Resu
10481#[ cfg( test) ]
10582mod tests {
10683 use super :: * ;
107- use crate :: { crypto:: signing:: sign, repo:: create} ;
84+ use crate :: crypto:: signing:: sign;
85+ use crate :: repo:: create_repo;
10886 use temp_dir:: TempDir ;
10987
11088 #[ test]
@@ -126,7 +104,7 @@ mod tests {
126104 fn test_update_manifest_valid_and_invalid ( ) -> Result < ( ) > {
127105 let repo = TempDir :: new ( ) ?;
128106 let repo_path = repo. path ( ) ;
129- create ( repo_path, Some ( repo_path) ) ?;
107+ create_repo ( repo_path, Some ( repo_path) ) ?;
130108
131109 let old_manifest = read_manifest ( repo_path) ?;
132110
@@ -156,10 +134,10 @@ mod tests {
156134 fn test_read_signed_manifest ( ) -> Result < ( ) > {
157135 let repo = TempDir :: new ( ) ?;
158136 let repo_path = repo. path ( ) ;
159- create ( repo_path, Some ( repo_path) ) ?;
137+ create_repo ( repo_path, Some ( repo_path) ) ?;
160138
161139 let manifest = read_manifest ( repo_path) ?;
162- let manifest_signed = read_manifest_signed ( repo_path, & manifest . public_key ) ?;
140+ let manifest_signed = read_manifest ( repo_path) ?;
163141
164142 assert_eq ! ( manifest. edition, manifest_signed. edition) ;
165143
0 commit comments