Security - Remove the unsafe Vec::set_len over recycled sector buffers — UB reachable from safe code (GHSA-j8ww-f5fg-9pmh, low). Uses Vec::resize; pooling unchanged. CI / tooling - clippy on stable with the MSRV single-sourced from Cargo.toml; cargo-deny dependency-audit gate with first-party git sources allowed (#15); audience-based comment-guard (#17). Docs - README (keydb ownership, BD-J parser count), drive-access transport/reset notes, mux timeline module-doc links.
2.0 KiB
SCSI error-decoding test contract
Background for tests/scsi_error_decoding.rs.
v0.13.20 rewrote scsi/linux.rs to a synchronous blocking SG_IO and
consolidated sense parsing into the parse_sense helper that every
platform backend now shares. v0.13.23 replaced the Error::ScsiError
flat-fields shape with { opcode, status, sense: Option<ScsiSense> }
so callers can route on structured sense data (key + ASC + ASCQ) via
Error::scsi_sense / Error::is_marginal_read / ScsiSense::is_*.
The actual ioctl(SG_IO, ...) call is impossible to mock without a
kernel, so libc shims are deliberately avoided here. These tests
therefore pin the contract every backend must satisfy via a mock
ScsiTransport:
- Healthy result ->
Ok(ScsiResult { bytes_transferred = data.len() - resid }). - Transport-level failure (no SCSI status delivered: kernel
timeout, USB bridge wedge, IOKit service error) ->
Error::ScsiError { status: SCSI_STATUS_TRANSPORT_FAILURE, sense: None }.Error::is_scsi_transport_failure()returnstrue. Used bydrive_has_discto detect the wedge signature. - SCSI-level failure (drive replied CHECK CONDITION with sense) ->
Error::ScsiError { status: 0x02, sense: Some(ScsiSense {...}) }with the parsed key/ASC/ASCQ. Error::is_marginal_read()istruefor MEDIUM ERROR / ABORTED COMMAND / RECOVERED ERROR / NO SENSE;falsefor HARDWARE / DATA PROTECT / UNIT ATTENTION / NOT READY / ILLEGAL REQUEST and for transport failures.
Inline parse_sense_tests in src/scsi/mod.rs cover the pure parse
logic (descriptor 0x72/0x73 vs fixed 0x70/0x71, short-buffer, VALID
bit masking, unknown response codes, ASC/ASCQ offsets); this file
covers the consumer side -- a real transport feeding a real Error
variant to a real call site (scsi::inquiry).
MockTransport outcomes
Outcomes mirror what each backend's execute() should produce after
the v0.13.23 sense plumbing: Option<ScsiSense> carrying the full
SPC-4 triple for drive-reported failures, None for transport-level
failures.