Repository navigation
fix(std): refuse non-regular files, full JPEG SOF range, list truncation marker - #96
Conversation
Tiny Sweeper reviewReviewed head: Verdict: Ready for maintainer review · Priority: none Diagnostics and supporting detailsFull summaryPull request purpose (title): fix(std): refuse non-regular files, full JPEG SOF range, list truncation marker. Tiny Sweeper completed its review; deterministic results follow. Review snapshot
Completeness: Complete What changedfile_read and edit_file check metadata after canonicalization and return `<path> is not a regular file` for any non-regular file before reading. image_info's dimension scan covers 0xC0..=0xCF excluding 0xC4, 0xC8 and 0xCC, and its metadata/read failures return Ok(ToolResult::error(..)). list_files sets a truncated flag when an entry exists past MAX_ENTRIES and appends `... listing stopped at 1000 entries [truncated]`. Tests were added or updated for each behavior, including a revised truncation test that creates MAX_ENTRIES+1 files then removes one. Features
TestsNo supported feature-to-test mapping was produced. Test execution is not inferred. FindingsNo active actionable findings. Before mergeNone. How this fits togetherflowchart LR
n0["...fuses_a_replacement_that_outgrows_the_cap<br/>changed"]:::changed
n1["a_paged_read_is_recorded_as_partial<br/>changed"]:::changed
n2["...ute_on_a_directory_reports_a_read_failure<br/>changed"]:::changed
n3["listing_stops_at_the_entry_cap<br/>changed"]:::changed
n4["write"]:::impacted
n5["with_file_state_agent_id"]:::impacted
n6["...he_file_state_guard_and_records_its_write"]:::impacted
n7["init_global"]:::impacted
n0 -->|calls| n4
n0 -->|tests| n4
n1 -->|calls| n4
n1 -->|tests| n4
n1 -->|calls| n5
n1 -->|tests| n5
n1 -->|calls| n7
n1 -->|tests| n7
n3 -->|calls| n4
n3 -->|tests| n4
n6 -->|calls| n4
n6 -->|tests| n4
n6 -->|calls| n5
n6 -->|tests| n5
n6 -->|calls| n7
n6 -->|tests| n7
classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Agent review detailscritique
security
tests
commits
description
Evidence and run details
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Comment |
Summary
This PR fixes four small robustness gaps in the tinytools-std filesystem tools.
file_readandedit_fileblocked on a FIFO. Both tools check metadata (size) and then callread_to_string. A FIFO has length 0, so it passes the size check, and then the read blocks forever while waiting for a writer. A character device can stream without end in the same way. Both tools now refuse anything that is not a regular file (<path> is not a regular file) before reading.image_infomissed most JPEG SOF markers. It read dimensions only from SOF0 to SOF3 (0xC0..=0xC3). Every SOF marker from0xC0to0xCFcarries the frame size, exceptC4(DHT),C8(JPG) andCC(DAC). Arithmetic-coded and lossless JPEGs (SOF5 to SOF15) therefore came back without dimensions. The scan now covers the whole range and skips those three markers as ordinary segments.image_inforeturned I/O failures asErr. A metadata or read failure became ananyhowerror, unlike every other filesystem tool. Both now return aToolResulterror with the same message, so the model sees the reason.list_filestruncated without saying so. It stops atMAX_ENTRIES(1000), and the output looked like a complete listing. When at least one more entry exists, it now ends with... listing stopped at 1000 entries [truncated].Related issue
None.
API or behavior changes
file_read/edit_fileon a FIFO, socket, device or directory now return<path> is not a regular file. Before, a FIFO blocked, and a directory produced the OS read error.image_infonow reports dimensions for SOF5 to SOF15 JPEGs. A metadata or read failure is nowOk(ToolResult::error(..))and no longerErr. A missingpathargument is unchanged.list_filesadds a truncation line when it hits the entry cap. When it does not, the output is unchanged.Validation
Commands actually run, with their outcome:
cargo fmt --all -- --check:rustfmt --edition 2024on the touched files only.N/A:
cargo clippy --all-targets --all-features -- -D warningswas left to CI.N/A:
cargo build --all-targets --all-featureswas left to CI.N/A:
cargo test --all-featureswas left to CI. Only the tests below ran locally. Before the fix, all 5 failed:a_fifo_is_refused_not_read:file_read blocked on a FIFO: Elapsed(())(5 s timeout);edit_refuses_a_fifo:edit blocked on a FIFO: Elapsed(());jpeg_dimensions_come_from_every_sof_marker_and_skip_c4_c8_cc:SOF 0xC5gaveNone;execute_on_a_directory_reports_a_read_failure(updated): the call returnedErr;a_capped_listing_says_it_was_truncated: no marker.After the fix, these and the rest of the
image_infotests pluslisting_stops_at_the_entry_cappassed (30 tests).Tests
file_read/extra_tests.rs::a_fifo_is_refused_not_readandedit_file/mod_tests.rs::edit_refuses_a_fifo(unix only) create a FIFO withmkfifoand expect a refusal within 5 s. Afterwards they open the FIFO for writing on a detached thread, so a failing run still shuts down.image_info/mod_tests.rs::jpeg_dimensions_come_from_every_sof_marker_and_skip_c4_c8_ccreads dimensions from all 13 SOF markers and skips C4, C8 and CC.image_info/mod_tests.rs::execute_on_a_directory_reports_a_read_failureused to assert the oldErrand now expects aToolResulterror.list_files/extra_tests.rs::a_capped_listing_says_it_was_truncated: 1001 entries produce the marker, and 1000 entries do not.Not in this PR: giving
image_infoanexecute_with_contextand a rate limit. Both are host-policy questions, not robustness fixes.Documentation
Not needed.
Checklist
#[allow(...)],#[ignore], or relaxed lints.envcontents in the diff or the description