-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New lint: Unix permissions set to a non-octal value #6934
Comments
@rustbot claim |
@giraffate Can I get a little help on this one? I need to be able to check if the method |
@ebobrow Thanks for working on this! I think these codes may help you to detect a receiver type of rust-clippy/clippy_lints/src/open_options.rs Lines 32 to 43 in 0743e84
|
Thank you so much! |
Add non_octal_unix_permissions lint fixes #6934 changelog: add new lint that checks for non-octal values used to set unix file permissions
Add non_octal_unix_permissions lint fixes #6934 changelog: add new lint that checks for non-octal values used to set unix file permissions
Add non_octal_unix_permissions lint fixes #6934 changelog: add new lint that checks for non-octal values used to set unix file permissions
Add non_octal_unix_permissions lint fixes #6934 changelog: add new lint that checks for non-octal values used to set unix file permissions
What it does
Checks if the following functions expecting Unix permission bits only called with octal literals:
PermissionsExt::set_mode
PermissionsExt::from_mode
OpenOptionsExt::mode
DirBuilderExt::mode
Categories
clippy::correctness
Drawbacks
False positives maybe.
Example
This example tries to set the file permissions to
440
(r,r,-
) however it ends up as0o670
(rw,rwx,-
) due to the decimal/octal confusion, giving unintended write/execute permissions in the process.Clippy should suggest rewriting that line as
options.mode(0o440);
.The text was updated successfully, but these errors were encountered: