Enforce Android lifecycle and presentation security (#100)
This commit is contained in:
1 parent
c0ba6d43d8
commit
a06f39af23
37 files changed
+1129
-110
No files matched your search
@@ -85,6 +85,28 @@ fn mobile_context_uses_injected_os_backend_clock_and_lifecycle_without_global_co
|
||||
authentication.lifecycle(MobileLifecycleEvent::Background)?;
|
||||
assert!(!authentication.state()?.unlocked());
|
||||
assert!(authentication.entry_editor(editor.id()).is_err());
|
||||
for event in [
|
||||
MobileLifecycleEvent::DeviceLocked,
|
||||
MobileLifecycleEvent::MemoryPressure,
|
||||
MobileLifecycleEvent::ProcessRecreated,
|
||||
] {
|
||||
authentication.unlock_entry(
|
||||
"email/personal",
|
||||
Some(SecretBytes::new(
|
||||
fixture.key("alice")?.passphrase.as_bytes().to_vec(),
|
||||
)),
|
||||
)?;
|
||||
let editor = authentication.begin_entry_editor("email/personal")?;
|
||||
clock.advance(Duration::from_secs(5));
|
||||
assert_eq!(
|
||||
authentication
|
||||
.lifecycle(MobileLifecycleEvent::Foreground)?
|
||||
.remaining_seconds(),
|
||||
25
|
||||
);
|
||||
assert!(!authentication.lifecycle(event)?.unlocked());
|
||||
assert!(authentication.entry_editor(editor.id()).is_err());
|
||||
}
|
||||
let baseline_locks = backend.locks();
|
||||
drop(authentication);
|
||||
assert!(
|
||||
|
||||
@@ -165,6 +165,28 @@ fn clearing_clipboard_never_reads_or_restores_previous_secrets() -> TestResult {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn immediate_copy_revocation_clears_only_matching_content() -> TestResult {
|
||||
let backend = MemoryClipboard::with_text(b"copied secret");
|
||||
let mut manager = ClipboardManager::new(backend.clone(), ClipboardTimeout::default());
|
||||
let secret = SecretBytes::new(b"copied secret".to_vec());
|
||||
assert_eq!(
|
||||
manager.clear_current_copy(&secret)?,
|
||||
ClipboardDisposition::Cleared
|
||||
);
|
||||
assert_eq!(backend.text(), None);
|
||||
backend.set_text(b"new user value");
|
||||
assert_eq!(
|
||||
manager.clear_current_copy(&secret)?,
|
||||
ClipboardDisposition::PreservedNewer
|
||||
);
|
||||
assert_eq!(
|
||||
backend.text().as_deref(),
|
||||
Some(b"new user value".as_slice())
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clipboard_validation_and_cleanup_failures_are_typed_and_redacted() -> TestResult {
|
||||
assert_eq!(
|
||||
|
||||
Reference in new issue
Block a user