pub struct UnsafeChecksum {}Expand description
§What it does
Ensures that each alpm-package-source-checksum in SRCINFO data uses a safe hash function.
§Why is this bad?
Upstream artifacts are validated against hash digests (see alpm-package-source-checksum) set in PKGBUILD and SRCINFO files.
Some hash functions (e.g. MD-5 and SHA-1) used for creating these hash digests are unsafe to use from a cryptographic perspective. These algorithms should be avoided to prevent hash collisions and potential abuse.
Using unsafe hash algorithms allows attackers to craft malicious artifacts that pass the checksum check. Further, attackers could swap existing artifacts with these malicious artifacts and compromise a package on (re)build.
§Example
pkgbase = test
pkgver = 1.0.0
pkgrel = 1
arch = x86_64
source = https://domain.tld/testing/x86_64_test.tar.gz
md5sums = 10245815f893d79f3d779690774f0b43Use instead:
pkgbase = test
pkgver = 1.0.0
pkgrel = 1
arch = x86_64
source = https://domain.tld/testing/x86_64_test.tar.gz
sha512sums = 1816c57b4abf31eb7c57a66bfb0f0ee5cef9398b5e4cc303468e08dae2702da55978402da94673e444f8c02754e94dedef4d12450319383c3a481d1c5cd90c82Implementations§
Source§impl UnsafeChecksum
impl UnsafeChecksum
Sourcepub fn new_boxed(_: &LintRuleConfiguration) -> Box<dyn LintRule>
pub fn new_boxed(_: &LintRuleConfiguration) -> Box<dyn LintRule>
Create a new, boxed instance of UnsafeChecksum.
Sourcefn create_checksum_issue(
&self,
field_name: &str,
value: &str,
architecture: Option<SystemArchitecture>,
) -> LintIssue
fn create_checksum_issue( &self, field_name: &str, value: &str, architecture: Option<SystemArchitecture>, ) -> LintIssue
Helper function to create a lint issue for unsafe checksum field.
Trait Implementations§
Source§impl Clone for UnsafeChecksum
impl Clone for UnsafeChecksum
Source§fn clone(&self) -> UnsafeChecksum
fn clone(&self) -> UnsafeChecksum
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnsafeChecksum
impl Debug for UnsafeChecksum
Source§impl Documented for UnsafeChecksum
impl Documented for UnsafeChecksum
Source§const DOCS: &'static str = "# What it does\n\nEnsures that each [alpm-package-source-checksum] in [SRCINFO] data uses a safe hash function.\n\n# Why is this bad?\n\nUpstream artifacts are validated against hash digests (see [alpm-package-source-checksum]) set\nin [PKGBUILD] and [SRCINFO] files.\n\nSome [hash functions] (e.g. [MD-5] and [SHA-1]) used for creating these hash digests are unsafe\nto use from a cryptographic perspective. These algorithms should be avoided to prevent hash\ncollisions and potential abuse.\n\nUsing unsafe hash algorithms allows attackers to craft malicious artifacts that pass the\nchecksum check. Further, attackers could swap existing artifacts with these malicious artifacts\nand compromise a package on (re)build.\n\n# Example\n\n```ini,ignore\npkgbase = test\npkgver = 1.0.0\npkgrel = 1\narch = x86_64\nsource = https://domain.tld/testing/x86_64_test.tar.gz\nmd5sums = 10245815f893d79f3d779690774f0b43\n```\n\nUse instead:\n\n```ini,ignore\npkgbase = test\npkgver = 1.0.0\npkgrel = 1\narch = x86_64\nsource = https://domain.tld/testing/x86_64_test.tar.gz\nsha512sums = 1816c57b4abf31eb7c57a66bfb0f0ee5cef9398b5e4cc303468e08dae2702da55978402da94673e444f8c02754e94dedef4d12450319383c3a481d1c5cd90c82\n```\n\n[MD-5]: https://en.wikipedia.org/wiki/MD-5\n[PKGBUILD]: https://man.archlinux.org/man/PKGBUILD.5\n[RFC 0046]: https://rfc.archlinux.page/0046-upstream-package-sources/\n[SHA-1]: https://en.wikipedia.org/wiki/SHA-1\n[SRCINFO]: https://alpm.archlinux.page/specifications/SRCINFO.5.html\n[alpm-package-source-checksum]: https://alpm.archlinux.page/specifications/alpm-package-source-checksum.7.html\n[hash functions]: https://en.wikipedia.org/wiki/Hash_function"
const DOCS: &'static str = "# What it does\n\nEnsures that each [alpm-package-source-checksum] in [SRCINFO] data uses a safe hash function.\n\n# Why is this bad?\n\nUpstream artifacts are validated against hash digests (see [alpm-package-source-checksum]) set\nin [PKGBUILD] and [SRCINFO] files.\n\nSome [hash functions] (e.g. [MD-5] and [SHA-1]) used for creating these hash digests are unsafe\nto use from a cryptographic perspective. These algorithms should be avoided to prevent hash\ncollisions and potential abuse.\n\nUsing unsafe hash algorithms allows attackers to craft malicious artifacts that pass the\nchecksum check. Further, attackers could swap existing artifacts with these malicious artifacts\nand compromise a package on (re)build.\n\n# Example\n\n```ini,ignore\npkgbase = test\npkgver = 1.0.0\npkgrel = 1\narch = x86_64\nsource = https://domain.tld/testing/x86_64_test.tar.gz\nmd5sums = 10245815f893d79f3d779690774f0b43\n```\n\nUse instead:\n\n```ini,ignore\npkgbase = test\npkgver = 1.0.0\npkgrel = 1\narch = x86_64\nsource = https://domain.tld/testing/x86_64_test.tar.gz\nsha512sums = 1816c57b4abf31eb7c57a66bfb0f0ee5cef9398b5e4cc303468e08dae2702da55978402da94673e444f8c02754e94dedef4d12450319383c3a481d1c5cd90c82\n```\n\n[MD-5]: https://en.wikipedia.org/wiki/MD-5\n[PKGBUILD]: https://man.archlinux.org/man/PKGBUILD.5\n[RFC 0046]: https://rfc.archlinux.page/0046-upstream-package-sources/\n[SHA-1]: https://en.wikipedia.org/wiki/SHA-1\n[SRCINFO]: https://alpm.archlinux.page/specifications/SRCINFO.5.html\n[alpm-package-source-checksum]: https://alpm.archlinux.page/specifications/alpm-package-source-checksum.7.html\n[hash functions]: https://en.wikipedia.org/wiki/Hash_function"
Source§impl LintRule for UnsafeChecksum
impl LintRule for UnsafeChecksum
Source§fn documentation(&self) -> String
fn documentation(&self) -> String
Source§fn run(
&self,
resources: &Resources,
issues: &mut Vec<LintIssue>,
) -> Result<(), Error>
fn run( &self, resources: &Resources, issues: &mut Vec<LintIssue>, ) -> Result<(), Error>
Source§fn scoped_name(&self) -> String
fn scoped_name(&self) -> String
LintRule::scope and LintRule::name
as {scope}::{name}. Read more