fix: audit fixes — blur offset, lock-before-IO, FP signal lifecycle, TOCTOU (v0.6.6)
Update PKGBUILD version / update-pkgver (push) Successful in 2s
Update PKGBUILD version / update-pkgver (push) Successful in 2s
Third triple audit (quality, performance, security). Key fixes: - Blur padding offset: texture at (-pad,-pad) prevents edge darkening on all sides - Wallpaper loads after lock.lock() — disk I/O no longer delays lock acquisition - begin_verification disconnects old signal handler before registering new one - resume_async resets failed_attempts to prevent premature exhaustion - Unknown VerifyStatus with done=true triggers restart instead of hanging - symlink_metadata() replaces separate is_file()+is_symlink() (TOCTOU) - faillock_warning dead code removed, blur sigma clamped to [0,100] - Redundant Zeroizing<Vec<u8>> removed, on_verify_status restricted to pub(crate) - Warn logging for non-UTF-8 GECOS and avatar path errors - Default impl for FingerprintListener, 3 new tests (47 total)
This commit is contained in:
+20
-3
@@ -100,9 +100,10 @@ pub fn load_strings(locale: Option<&str>) -> &'static Strings {
|
||||
match locale { "de" => &STRINGS_DE, _ => &STRINGS_EN }
|
||||
}
|
||||
|
||||
/// Returns a warning when the user is one attempt away from lockout.
|
||||
/// Caller is responsible for handling the locked state (count >= max_attempts).
|
||||
pub fn faillock_warning(attempt_count: u32, max_attempts: u32, strings: &Strings) -> Option<String> {
|
||||
if attempt_count >= max_attempts { return Some(strings.faillock_locked.to_string()); }
|
||||
let remaining = max_attempts - attempt_count;
|
||||
let remaining = max_attempts.saturating_sub(attempt_count);
|
||||
if remaining == 1 { return Some(strings.faillock_attempts_remaining.replace("{n}", &remaining.to_string())); }
|
||||
None
|
||||
}
|
||||
@@ -139,5 +140,21 @@ mod tests {
|
||||
#[test] fn faillock_zero() { assert!(faillock_warning(0, 3, load_strings(Some("en"))).is_none()); }
|
||||
#[test] fn faillock_one() { assert!(faillock_warning(1, 3, load_strings(Some("en"))).is_none()); }
|
||||
#[test] fn faillock_two() { assert!(faillock_warning(2, 3, load_strings(Some("en"))).is_some()); }
|
||||
#[test] fn faillock_three() { assert_eq!(faillock_warning(3, 3, load_strings(Some("en"))).unwrap(), "Account may be locked"); }
|
||||
#[test] fn faillock_three() { assert!(faillock_warning(3, 3, load_strings(Some("en"))).is_none()); }
|
||||
|
||||
#[test]
|
||||
fn faillock_caller_contract() {
|
||||
// Mirrors the lockscreen.rs usage: caller handles count >= max separately,
|
||||
// faillock_warning is only called when count < max.
|
||||
let max = 3u32;
|
||||
let strings = load_strings(Some("en"));
|
||||
for count in 0..max {
|
||||
let result = faillock_warning(count, max, strings);
|
||||
if max - count == 1 {
|
||||
assert!(result.is_some(), "should warn at count={count}");
|
||||
} else {
|
||||
assert!(result.is_none(), "should not warn at count={count}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user