![github-actions[bot]](/assets/img/avatar_default.png)
* Create rule S7448 * Update RSPEC --------- Co-authored-by: yassin-kammoun-sonarsource <yassin-kammoun-sonarsource@users.noreply.github.com> Co-authored-by: yassin-kammoun-sonarsource <yassin.kammoun@sonarsource.com>
34 lines
862 B
Plaintext
34 lines
862 B
Plaintext
== Why is this an issue?
|
|
|
|
Using non-octal values to set Unix file permissions is problematic because they are converted to octal internally, which can lead to unexpected file permissions and potential security issues.
|
|
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,rust,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
use std::fs::OpenOptions;
|
|
use std::os::unix::fs::OpenOptionsExt;
|
|
|
|
let mut options = OpenOptions::new();
|
|
options.mode(644); // Noncompliant: Non-octal value used.
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,rust,diff-id=1,diff-type=compliant]
|
|
----
|
|
use std::fs::OpenOptions;
|
|
use std::os::unix::fs::OpenOptionsExt;
|
|
|
|
let mut options = OpenOptions::new();
|
|
options.mode(0o644); // Compliant: Octal value used.
|
|
----
|
|
|
|
== Resources
|
|
=== Documentation
|
|
|
|
* Clippy Lints - https://rust-lang.github.io/rust-clippy/master/index.html#non_octal_unix_permissions
|