Repository navigation
Forbid unsafe code - #16
Merged
Merged
Conversation
…ows access lists with icacls
There was a problem hiding this comment.
🟡 Changes recommended
The Windows permission restriction leaves explicit grants to other principals intact, so an existing configuration directory can remain accessible to others despite reporting success.
1 open issue
What changed in this PR
This PR forbids unsafe code throughout the crate, including tests, and replaces the two direct platform API implementations with safe alternatives.
Changes:
- Use
sigpipe::reset()to preserve quiet exits on closed Unix pipes. - Use
icaclsandwhoamifor Windows sign-in file and folder permissions. - Enable
unsafe_code = "forbid"and update dependencies.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
src/main.rs |
Replace the unsafe SIGPIPE reset with sigpipe::reset(). |
src/fsutil/owner_only.rs |
Replace Win32 calls with command-based permission handling and cached SID lookup. |
Cargo.toml |
Forbid unsafe code, add sigpipe, and remove direct libc and windows-sys dependencies. |
Cargo.lock |
Record sigpipe and update the crate’s dependency list. |
Review effort: Balanced
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.

Sets
unsafe_code = "forbid"for the whole crate, tests included, and removes the two places that used it:sigpipecrate instead of callinglibc::signal, sowritebook … | headstill exits quietly.libcis dropped.icacls <path> /inheritance:r /grant:r *<SID>:(OI)(CI)F(no(OI)(CI)for files), taking the SID fromwhoami /user.windows-sysis dropped.The Windows job's
keeps_sign_ins_in_a_folder_only_you_can_readchecks the resulting access list is protected and names only the current user with full control.