Refuse a browser engine pin with another protocol
The pin names the protocol of its engine. An engine of another protocol would fail at its first start, so the host now refuses its pin before the download. This also uses the protocol field, which the build reported as unread.
This commit is contained in:
@@ -109,6 +109,10 @@ fn parse(text: &str) -> Result<Manifest> {
|
|||||||
if !valid_version(&manifest.version) {
|
if !valid_version(&manifest.version) {
|
||||||
return Err("The browser engine manifest has an invalid version.".into());
|
return Err("The browser engine manifest has an invalid version.".into());
|
||||||
}
|
}
|
||||||
|
// An engine of another protocol would fail at its first start. Refuse its pin before the download.
|
||||||
|
if manifest.protocol != PROTOCOL {
|
||||||
|
return Err("The browser engine manifest names another engine protocol.".into());
|
||||||
|
}
|
||||||
for package in manifest.platforms.values() {
|
for package in manifest.platforms.values() {
|
||||||
let hex = package.sha256.len() == 64 && package.sha256.bytes().all(|c| c.is_ascii_digit() || (b'a'..=b'f').contains(&c));
|
let hex = package.sha256.len() == 64 && package.sha256.bytes().all(|c| c.is_ascii_digit() || (b'a'..=b'f').contains(&c));
|
||||||
if !hex || package.bytes == 0 || Url::parse(&package.url).is_err() {
|
if !hex || package.bytes == 0 || Url::parse(&package.url).is_err() {
|
||||||
@@ -531,6 +535,7 @@ mod tests {
|
|||||||
r#"{"version":"../1","protocol":1}"#,
|
r#"{"version":"../1","protocol":1}"#,
|
||||||
r#"{"version":"0.1.8","protocol":1,"platforms":{"windows-x86_64":{"url":"x","bytes":1,"sha256":"00"}}}"#,
|
r#"{"version":"0.1.8","protocol":1,"platforms":{"windows-x86_64":{"url":"x","bytes":1,"sha256":"00"}}}"#,
|
||||||
r#"{"version":"0.1.8","protocol":1,"extra":true}"#,
|
r#"{"version":"0.1.8","protocol":1,"extra":true}"#,
|
||||||
|
r#"{"version":"0.1.8","protocol":2}"#,
|
||||||
] {
|
] {
|
||||||
assert!(parse(text).is_err(), "{text}");
|
assert!(parse(text).is_err(), "{text}");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user