Skip to content

Commit 9fb057e

Browse files
committed
test: cover security dependency pins
1 parent 6242eb3 commit 9fb057e

4 files changed

Lines changed: 126 additions & 16 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,19 @@
138138
},
139139
"pnpm": {
140140
"overrides": {
141-
"@lhci/cli>tmp": "^0.2.4",
141+
"@lhci/cli>tmp": "^0.2.6",
142142
"basic-ftp": "^5.3.0",
143143
"commitizen>lodash": "^4.17.23",
144144
"eslint>ajv": "^6.14.0",
145-
"external-editor>tmp": "^0.2.4",
145+
"external-editor>tmp": "^0.2.6",
146146
"flatted": "^3.4.2",
147147
"minimatch": "^10.2.3",
148148
"rollup": "^4.59.0",
149-
"tmp": "^0.2.4",
149+
"tmp": "^0.2.6",
150150
"yauzl": "^3.2.1"
151151
},
152152
"onlyBuiltDependencies": [
153153
"esbuild"
154154
]
155155
}
156-
}
156+
}

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/security/run-cargo-audit.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ cd "$repo_root/src-tauri"
1010
# Owner: Platform Engineering
1111
# Review date: 2026-03-09
1212
# Last remediation update: hickory-resolver upgraded to 0.26.1 to clear
13-
# RUSTSEC-2026-0119, and lz4_flex upgraded to 0.12.1 to clear
14-
# RUSTSEC-2026-0041.
13+
# RUSTSEC-2026-0119, and locked lz4_flex versions kept outside the
14+
# RUSTSEC-2026-0041 vulnerable ranges.
1515
# Umbrella tracking issue: https://github.com/saagar210/AssistSupport/issues/11
1616
#
1717
# GTK3/Tauri Linux runtime chain (issue #12):
@@ -65,4 +65,4 @@ cargo audit --deny unsound --deny unmaintained \
6565
--ignore RUSTSEC-2025-0100 \
6666
--ignore RUSTSEC-2026-0002 \
6767
--ignore RUSTSEC-2026-0097 \
68-
--ignore RUSTSEC-2026-0105
68+
--ignore RUSTSEC-2026-0105
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//! Dependency pinning checks for security-alert remediations.
2+
3+
use std::fs;
4+
5+
fn cargo_lock() -> String {
6+
fs::read_to_string(format!("{}/Cargo.lock", env!("CARGO_MANIFEST_DIR")))
7+
.expect("Cargo.lock should be readable")
8+
}
9+
10+
fn package_versions<'a>(lockfile: &'a str, package_name: &str) -> Vec<&'a str> {
11+
let versions: Vec<_> = lockfile
12+
.split("[[package]]")
13+
.filter_map(|package| {
14+
let mut name = None;
15+
let mut version = None;
16+
17+
for line in package.lines() {
18+
if let Some(value) = line.strip_prefix("name = \"") {
19+
name = value.strip_suffix('"');
20+
}
21+
22+
if let Some(value) = line.strip_prefix("version = \"") {
23+
version = value.strip_suffix('"');
24+
}
25+
}
26+
27+
(name == Some(package_name)).then_some(version).flatten()
28+
})
29+
.collect();
30+
31+
assert!(
32+
!versions.is_empty(),
33+
"{package_name} should be present in Cargo.lock"
34+
);
35+
36+
versions
37+
}
38+
39+
fn package_version<'a>(lockfile: &'a str, package_name: &str) -> &'a str {
40+
let versions = package_versions(lockfile, package_name);
41+
42+
assert_eq!(
43+
versions.len(),
44+
1,
45+
"{package_name} should have one locked version; found {versions:?}"
46+
);
47+
48+
versions[0]
49+
}
50+
51+
fn version_tuple(version: &str) -> (u64, u64, u64) {
52+
let mut parts = version.split('.').map(|part| {
53+
part.parse::<u64>()
54+
.unwrap_or_else(|_| panic!("{version} should contain numeric version parts"))
55+
});
56+
57+
let major = parts
58+
.next()
59+
.unwrap_or_else(|| panic!("{version} should include a major version"));
60+
let minor = parts
61+
.next()
62+
.unwrap_or_else(|| panic!("{version} should include a minor version"));
63+
let patch = parts
64+
.next()
65+
.unwrap_or_else(|| panic!("{version} should include a patch version"));
66+
67+
assert!(
68+
parts.next().is_none(),
69+
"{version} should only include major.minor.patch"
70+
);
71+
72+
(major, minor, patch)
73+
}
74+
75+
fn assert_package_at_least(lockfile: &str, package_name: &str, minimum: &str) {
76+
let actual = package_version(lockfile, package_name);
77+
78+
assert!(
79+
version_tuple(actual) >= version_tuple(minimum),
80+
"{package_name} should stay on at least {minimum}; found {actual}"
81+
);
82+
}
83+
84+
#[test]
85+
fn cargo_lock_uses_patched_openssl() {
86+
let lockfile = cargo_lock();
87+
88+
assert_package_at_least(&lockfile, "openssl", "0.10.79");
89+
}
90+
91+
#[test]
92+
fn cargo_lock_uses_patched_hickory_proto() {
93+
let lockfile = cargo_lock();
94+
95+
assert_package_at_least(&lockfile, "hickory-proto", "0.26.1");
96+
}
97+
98+
#[test]
99+
fn cargo_lock_uses_patched_lz4_flex() {
100+
let lockfile = cargo_lock();
101+
let versions = package_versions(&lockfile, "lz4_flex");
102+
103+
assert!(
104+
versions.iter().all(|version| {
105+
let parsed = version_tuple(version);
106+
parsed > version_tuple("0.11.5") && parsed != version_tuple("0.12.0")
107+
}),
108+
"lz4_flex should stay outside vulnerable ranges <=0.11.5 and 0.12.0; found {versions:?}"
109+
);
110+
}

0 commit comments

Comments
 (0)