Implement Payload Hash parsing

This commit is contained in:
Till Wegmueller 2020-08-04 22:32:44 +02:00
parent 4057826c7a
commit c2867684d1
3 changed files with 250 additions and 147 deletions

View file

@ -327,25 +327,20 @@ fn parse_file_action(line: String, line_nr: usize) -> Result<File, Error> {
Ok(b) => b, Ok(b) => b,
Err(e) => return Err(ManifestError::InvalidAction {action: line, line: line_nr, message: e})? Err(e) => return Err(ManifestError::InvalidAction {action: line, line: line_nr, message: e})?
}, },
"chash" | "pkg.content-hash" => act.payload.additional_identifiers.push(match Digest::from_str(clean_string_value(&cap[val_cap_idx]).as_str()) {
Ok(d) => d,
Err(e) => return Err(e)?
}),
_ => { _ => {
let key_val_string = clean_string_value(&cap[full_cap_idx]); let key_val_string = String::from(&cap[full_cap_idx]);
if key_val_string.contains("facet.") { if key_val_string.contains("facet.") {
match add_facet_to_action(&mut act, key_val_string, line.clone(), line_nr) { match add_facet_to_action(&mut act, key_val_string, line.clone(), line_nr) {
Ok(_) => continue, Ok(_) => continue,
Err(e) => return Err(e)?, Err(e) => return Err(e)?,
} }
} else {
act.properties.push(Property{key: clean_string_value(&cap[key_cap_idx]), value: clean_string_value(&cap[val_cap_idx])});
} }
let mut key = key_val_string.clone();
let value = match key.find("=") {
Some(idx) => {
key.split_off(idx+1)
},
None => return Err(ManifestError::InvalidAction{action: line, line: line_nr, message: String::from("no value present for facet")})?
};
key = key.replace("=", "");
act.properties.push(Property{key, value});
} }
} }
} }

View file

@ -5,7 +5,7 @@
use std::str::FromStr; use std::str::FromStr;
#[derive(Debug)] #[derive(Debug, PartialEq)]
pub enum DigestAlgorithm { pub enum DigestAlgorithm {
SHA1, //Default, sadly SHA1, //Default, sadly
SHA256, //sha256t SHA256, //sha256t
@ -20,7 +20,7 @@ impl Default for DigestAlgorithm {
fn default() -> Self { DigestAlgorithm::SHA1 } fn default() -> Self { DigestAlgorithm::SHA1 }
} }
#[derive(Debug)] #[derive(Debug, PartialEq)]
pub enum DigestSource { pub enum DigestSource {
GzipCompressed, GzipCompressed,
GNUElf, GNUElf,

View file

@ -16,7 +16,7 @@ mod tests {
use crate::actions::{parse_manifest_string, Attr}; use crate::actions::{parse_manifest_string, Attr};
use std::collections::HashSet; use std::collections::HashSet;
use crate::payload::Payload; use crate::payload::Payload;
use crate::digest::Digest; use crate::digest::{Digest, DigestAlgorithm, DigestSource};
use std::str::FromStr; use std::str::FromStr;
#[test] #[test]
@ -240,6 +240,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("4b76e83bb4bb7c87176b72ef805fe78ecae60d2c"), hash: String::from("4b76e83bb4bb7c87176b72ef805fe78ecae60d2c"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "7288afc78233791bb8e13b3e13aa4f0b4b1d6ee8".to_string(),
..Digest::default()
},
Digest{
hash: "42007aaee6bd54977eb33f91db28f931ab11c39787ba9f7851b6baf0d142185b".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "ec144533fa077af1d5b152d8c7549f113902021d71808adb12ea3f92bda9fd66".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -248,15 +264,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
path: "lib/svc/method/http-nginx".to_string(), path: "lib/svc/method/http-nginx".to_string(),
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "7288afc78233791bb8e13b3e13aa4f0b4b1d6ee8".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:42007aaee6bd54977eb33f91db28f931ab11c39787ba9f7851b6baf0d142185b".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:ec144533fa077af1d5b152d8c7549f113902021d71808adb12ea3f92bda9fd66".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "975".to_string(), value: "975".to_string(),
},Property{ },Property{
@ -271,6 +278,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("72e0496a02e72e7380b0b62cdc8410108302876f"), hash: String::from("72e0496a02e72e7380b0b62cdc8410108302876f"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "2f82b51db9cbba0705cb680e5aa0f11ff237009b".to_string(),
..Digest::default()
},
Digest{
hash: "c0c3640d6e61b53a3dc4228adff7532ec6b5d09bf1847991a3aaa5eb3e04d19a".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "e1999bae58ef887d81dc686b794429a9dea0e7674b631c2a08f07fb9b34440e2".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "sys".to_string(), group: "sys".to_string(),
@ -279,15 +302,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
path: "lib/svc/manifest/network/http-nginx.xml".to_string(), path: "lib/svc/manifest/network/http-nginx.xml".to_string(),
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "2f82b51db9cbba0705cb680e5aa0f11ff237009b".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:c0c3640d6e61b53a3dc4228adff7532ec6b5d09bf1847991a3aaa5eb3e04d19a".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:e1999bae58ef887d81dc686b794429a9dea0e7674b631c2a08f07fb9b34440e2".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "1067".to_string(), value: "1067".to_string(),
},Property{ },Property{
@ -305,6 +319,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("95de71d58b37f9f74bede0e91bc381d6059fc2d7"), hash: String::from("95de71d58b37f9f74bede0e91bc381d6059fc2d7"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "c2e2e4cf82ec527800a2170d9e2565b75d557012".to_string(),
..Digest::default()
},
Digest{
hash: "b592728ea1dcd6dd0924e1e6767e217ad70ec6973086911d8bc07d44695b9f0e".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "8407d82b497c4a865841ab8874207cc5a4d581ba574d66074ef5f92f05ee13cf".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -313,15 +343,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
path: "usr/share/nginx/html/50x.html".to_string(), path: "usr/share/nginx/html/50x.html".to_string(),
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "c2e2e4cf82ec527800a2170d9e2565b75d557012".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:b592728ea1dcd6dd0924e1e6767e217ad70ec6973086911d8bc07d44695b9f0e".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:8407d82b497c4a865841ab8874207cc5a4d581ba574d66074ef5f92f05ee13cf".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "327".to_string(), value: "327".to_string(),
},Property{ },Property{
@ -336,6 +357,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("7dd71afcfb14e105e80b0c0d7fce370a28a41f0a"), hash: String::from("7dd71afcfb14e105e80b0c0d7fce370a28a41f0a"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "50b7bcf6c555b8e9bde1eacd2c3d5c34a757c312".to_string(),
..Digest::default()
},
Digest{
hash: "204038cd5fbbcdd2c3d24acb7f41b1e861c51d689f53202ec69b43bdba01cb60".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "34bad6066578cf03289b0c957cb4f01a9353f91b3b95079d69bf9e12dd569279".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -344,15 +381,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
path: "usr/share/nginx/html/index.html".to_string(), path: "usr/share/nginx/html/index.html".to_string(),
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "50b7bcf6c555b8e9bde1eacd2c3d5c34a757c312".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:204038cd5fbbcdd2c3d24acb7f41b1e861c51d689f53202ec69b43bdba01cb60".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:34bad6066578cf03289b0c957cb4f01a9353f91b3b95079d69bf9e12dd569279".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "381".to_string(), value: "381".to_string(),
},Property{ },Property{
@ -367,6 +395,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("cbf596ddb3433a8e0d325f3c188bec9c1bb746b3"), hash: String::from("cbf596ddb3433a8e0d325f3c188bec9c1bb746b3"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "2df27ca83841b9c8e38c5aa30760372773166928".to_string(),
..Digest::default()
},
Digest{
hash: "d260c064680ec58135d9a290ed3cfd64274db769701ab3df2bfdeb653a864518".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "4924c0f4bdc37b832afd281ad07b0bf339c8c3a0e2d95e076998d46fab76a084".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -376,15 +420,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "2df27ca83841b9c8e38c5aa30760372773166928".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:d260c064680ec58135d9a290ed3cfd64274db769701ab3df2bfdeb653a864518".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:4924c0f4bdc37b832afd281ad07b0bf339c8c3a0e2d95e076998d46fab76a084".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "448".to_string(), value: "448".to_string(),
},Property{ },Property{
@ -399,6 +434,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("da38e2a0dded838afbe0eade6cb837ac30fd8046"), hash: String::from("da38e2a0dded838afbe0eade6cb837ac30fd8046"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "530616dc345f6acf0aea26db06e56aa41b2f510d".to_string(),
..Digest::default()
},
Digest{
hash: "baeeb2df301f8764568a86884c127e90faf39bee4ff0e53fb4a890955e605cee".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "5c6f541692556eacbde4ea1536de3c1af2cd8e9980fc4edca36851a97ed671ba".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -408,15 +459,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "530616dc345f6acf0aea26db06e56aa41b2f510d".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:baeeb2df301f8764568a86884c127e90faf39bee4ff0e53fb4a890955e605cee".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:5c6f541692556eacbde4ea1536de3c1af2cd8e9980fc4edca36851a97ed671ba".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "430".to_string(), value: "430".to_string(),
},Property{ },Property{
@ -431,6 +473,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("407cb51b397ba4ad90a2246640a81af18e2e917a"), hash: String::from("407cb51b397ba4ad90a2246640a81af18e2e917a"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "00d285c15dd65f24c4c89d5790094c38432a1ac6".to_string(),
..Digest::default()
},
Digest{
hash: "06381b2c4a28fe88c0d908f1cd81453c9482358c8195163e294b8def8924b366".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "d66022b08971eaf9ddf3230a991b0d8352fcefe0f797305a94b5ca0574d70ff5".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -440,15 +498,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "00d285c15dd65f24c4c89d5790094c38432a1ac6".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:06381b2c4a28fe88c0d908f1cd81453c9482358c8195163e294b8def8924b366".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:d66022b08971eaf9ddf3230a991b0d8352fcefe0f797305a94b5ca0574d70ff5".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "938".to_string(), value: "938".to_string(),
},Property{ },Property{
@ -463,6 +512,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("19ec7fb71e7f00d7e8a1cfc1013490f0cfee572b"), hash: String::from("19ec7fb71e7f00d7e8a1cfc1013490f0cfee572b"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "0f2588ac25780698ea7ebeac3ea0e9041502d501".to_string(),
..Digest::default()
},
Digest{
hash: "92d4df1df754d3e2cd8c52aba7415680c86097803b437bf0edcd8d022ab6aa8c".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "2ad3bb0540d800f2115691c96e8ed35b9b91eb5c248bea199da22ffd102cc847".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -472,15 +537,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "0f2588ac25780698ea7ebeac3ea0e9041502d501".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:92d4df1df754d3e2cd8c52aba7415680c86097803b437bf0edcd8d022ab6aa8c".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:2ad3bb0540d800f2115691c96e8ed35b9b91eb5c248bea199da22ffd102cc847".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "749".to_string(), value: "749".to_string(),
},Property{ },Property{
@ -495,6 +551,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("e39dbc36680b717ec902fadc805a302f1cf62245"), hash: String::from("e39dbc36680b717ec902fadc805a302f1cf62245"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "325af5a4b735284a3cdfd3b04bd249ff22334965".to_string(),
..Digest::default()
},
Digest{
hash: "8217c6955d644400707c4ecf1539ece4ee2fd1be4838654860f2ef2ecacdebd4".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "46566d205da4d67a6e12a1d3d2f78e3602770ce42ef2c117ee95b821aec90100".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -504,15 +576,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "325af5a4b735284a3cdfd3b04bd249ff22334965".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:8217c6955d644400707c4ecf1539ece4ee2fd1be4838654860f2ef2ecacdebd4".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:46566d205da4d67a6e12a1d3d2f78e3602770ce42ef2c117ee95b821aec90100".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "990".to_string(), value: "990".to_string(),
},Property{ },Property{
@ -527,6 +590,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("d143ca7a6aac765d28724af54d969a4bd2202383"), hash: String::from("d143ca7a6aac765d28724af54d969a4bd2202383"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "adacb374c514459417f07cacd4f8bf60644c9651".to_string(),
..Digest::default()
},
Digest{
hash: "cc9263a836b4db441340d2e041adf10136c9a8aa31259b868000f88c84032ba1".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "cf0cd12b5f3f1d9d15378e1a1bacaaff7589bf2c129312b277b66ea3418acc54".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -536,15 +615,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "adacb374c514459417f07cacd4f8bf60644c9651".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:cc9263a836b4db441340d2e041adf10136c9a8aa31259b868000f88c84032ba1".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:cf0cd12b5f3f1d9d15378e1a1bacaaff7589bf2c129312b277b66ea3418acc54".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "997".to_string(), value: "997".to_string(),
},Property{ },Property{
@ -559,6 +629,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("379c1e2a2a5ffb8c91a07328d4c9be2bc58799fd"), hash: String::from("379c1e2a2a5ffb8c91a07328d4c9be2bc58799fd"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "2c75c59e0de9208a9b96460d0566e5686708310c".to_string(),
..Digest::default()
},
Digest{
hash: "e6dd7076b6319abc3fcd04554fede95c8cc40f1e21a83772c36577f939e81cb6".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "48efb28df3607f1a8b67eab95d4ca19526e8351d10529d97cb4af05250f8ee95".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -568,15 +654,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "2c75c59e0de9208a9b96460d0566e5686708310c".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:e6dd7076b6319abc3fcd04554fede95c8cc40f1e21a83772c36577f939e81cb6".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:48efb28df3607f1a8b67eab95d4ca19526e8351d10529d97cb4af05250f8ee95".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "275".to_string(), value: "275".to_string(),
},Property{ },Property{
@ -591,6 +668,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("cc2fcdb4605dcac23d59f667889ccbdfdc6e3668"), hash: String::from("cc2fcdb4605dcac23d59f667889ccbdfdc6e3668"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "62320c6c207a26bf9c68c39d0372f4d4b97b905f".to_string(),
..Digest::default()
},
Digest{
hash: "eb133ae0a357df02b4b02615bc47dc2e5328105dac2dbcbd647667e9bbc3b2fd".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "e5a2625a67f5502c5911d7e7a850030b6af89929e182b2da74ecf6e79df0e9d2".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -600,15 +693,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "62320c6c207a26bf9c68c39d0372f4d4b97b905f".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:eb133ae0a357df02b4b02615bc47dc2e5328105dac2dbcbd647667e9bbc3b2fd".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:e5a2625a67f5502c5911d7e7a850030b6af89929e182b2da74ecf6e79df0e9d2".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "284".to_string(), value: "284".to_string(),
},Property{ },Property{
@ -623,6 +707,22 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("e10f2d42c9e581901d810928d01a3bf8f3372838"), hash: String::from("e10f2d42c9e581901d810928d01a3bf8f3372838"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "fd231cdd1a726fcb2abeba90b31cbf4c7df6df4d".to_string(),
..Digest::default()
},
Digest{
hash: "7620f21db4c06f3eb863c0cb0a8b3f62c435abd2f8f47794c42f08ad434d90dd".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "ca16a95ddd6ef2043969db20915935829b8ccb6134588e1710b24baf45afd7bb".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -632,15 +732,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
preserve: true, preserve: true,
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "fd231cdd1a726fcb2abeba90b31cbf4c7df6df4d".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:7620f21db4c06f3eb863c0cb0a8b3f62c435abd2f8f47794c42f08ad434d90dd".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:ca16a95ddd6ef2043969db20915935829b8ccb6134588e1710b24baf45afd7bb".to_string(),
},Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "1197".to_string(), value: "1197".to_string(),
},Property{ },Property{
@ -655,6 +746,32 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
hash: String::from("6d5f820bb1d67594c7b757c79ef6f9242df49e98"), hash: String::from("6d5f820bb1d67594c7b757c79ef6f9242df49e98"),
..Digest::default() ..Digest::default()
}, },
additional_identifiers: vec![
Digest{
hash: "3ab17dde089f1eac7abd37d8efd700b5139d70b2".to_string(),
..Digest::default()
},
Digest{
hash: "add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GNUElf
},
Digest{
hash: "add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GNUElfUnsigned
},
Digest{
hash: "3d87b058a8e69b3a8dfab142f5e856549dcd531a371e3ca4d2be391655b0d076".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::UncompressedFile
},
Digest{
hash: "7f93c48194b3e164ea35a9d2ddff310215769dbd27b45e9ab72beef1cce0d4f6".to_string(),
algorithm: DigestAlgorithm::SHA512Half,
source: DigestSource::GzipCompressed
}
],
..Payload::default() ..Payload::default()
}, },
group: "bin".to_string(), group: "bin".to_string(),
@ -663,9 +780,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
path: "usr/sbin/nginx".to_string(), path: "usr/sbin/nginx".to_string(),
properties: vec![ properties: vec![
Property{ Property{
key: "chash".to_string(),
value: "3ab17dde089f1eac7abd37d8efd700b5139d70b2".to_string(),
},Property{
key: "elfarch".to_string(), key: "elfarch".to_string(),
value: "i386".to_string(), value: "i386".to_string(),
},Property{ },Property{
@ -674,18 +788,6 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
},Property{ },Property{
key: "elfhash".to_string(), key: "elfhash".to_string(),
value: "25b0cdd7736cddad78ce91b61385a8fdde91f7b2".to_string(), value: "25b0cdd7736cddad78ce91b61385a8fdde91f7b2".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gelf:sha512t_256:add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gelf.unsigned:sha512t_256:add9bfb171c2a173b8f12d375884711527f40e592d100a337a9fae078c8beabd".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "file:sha512t_256:3d87b058a8e69b3a8dfab142f5e856549dcd531a371e3ca4d2be391655b0d076".to_string(),
},Property{
key: "pkg.content-hash".to_string(),
value: "gzip:sha512t_256:7f93c48194b3e164ea35a9d2ddff310215769dbd27b45e9ab72beef1cce0d4f6".to_string(),
},Property{ },Property{
key: "pkg.csize".to_string(), key: "pkg.csize".to_string(),
value: "657230".to_string(), value: "657230".to_string(),
@ -718,6 +820,12 @@ file 6d5f820bb1d67594c7b757c79ef6f9242df49e98 chash=3ab17dde089f1eac7abd37d8efd7
assert_eq!(val.key, test_results[pos].properties[vpos].key); assert_eq!(val.key, test_results[pos].properties[vpos].key);
assert_eq!(val.value, test_results[pos].properties[vpos].value); assert_eq!(val.value, test_results[pos].properties[vpos].value);
} }
for (vpos, val) in file.payload.additional_identifiers.iter().enumerate() {
assert_eq!(val.hash, test_results[pos].payload.additional_identifiers[vpos].hash);
assert_eq!(val.source, test_results[pos].payload.additional_identifiers[vpos].source);
assert_eq!(val.algorithm, test_results[pos].payload.additional_identifiers[vpos].algorithm);
}
} }
} }
} }