Repository navigation
Conversation
A directory audit guarded its nested non-JS loop (qybaihe#330) but still read every JS/TS file with a bare readFileSync, so one unreadable script (EACCES, a file removed between the walk and the read) threw out of auditTarget and removed the whole audit and the defend pre-flight stage. Collect the path into unreadableFiles and mark the simulation partial, matching the sibling loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A directory audit walks the tree, keeps every JS/TS file it finds, and reads each one to build the exposure model. That read had no guard, so a file that
stataccepted butreadFileSynccould not open, such as a script owned by another account, one removed between the walk and the read, or one held open by a scanner, threw out ofauditTarget. The caller lost the entire report: no attack surface, nounreadableFilesentry, no partial marker.defendTargetlost stage 2 with it, because it calls the audit directly.What changed
src/engine/auditor.ts: the JS/TS loop now reads inside atry/catch, pushes the project-relative path intounreadableFiles, and continues with the next file. That is the same treatment the nested artifact loop already gives an unreadable.asaror.wasm, so both halves of a directory audit now fail the same way.parseStatusfrom that list, so a run with one unreadable script reportspartialinstead of throwing or claimingcomplete.tests/audit-unreadable-nested.test.ts: a new case injects a singleEACCESfor one file name and asserts that the audit returns, listslocked.js, marks the simulationpartial, and still counts the readable sibling. A permission error cannot be produced portably, sincechmod 000is ignored on Windows and by root, so the test passes every other read through to the real filesystem.Why it matters
The audit is the pre-flight stage of
defendTargetand the whole ofbla_audit. A single unreadable script in a large build tree used to turn a report into a stack trace. For an operator that is worse than a partial result in two ways: the rest of the surface disappears with the failing file, and nothing says the run stopped early. The report contract in this repo is that BLA names what it could not examine, and this path broke that contract instead of degrading into it.Validation
The new test fails on the old code with
EACCES: permission deniedthrown from the read insideauditTarget. After the change, 21 tests pass in that set with one symlink test skipped on Windows, and the type check is clean.Compatibility
A tree where every script is readable reports exactly what it did before.
unreadableFilesonly appears when something could not be read, and a directory audit that previously threw now returns a report. Callers notice the difference only in the case that used to crash.