Unsafe File Permissions High

Potentially dangerous settings are being assigned to a file. Either the group or world levels are being given read or write access to a file. This might allow unintended users to access private information.

Detector ID
ruby/loose-file-permissions@v1.0
Category
Common Weakness Enumeration (CWE) external icon
Tags
-

Noncompliant example

1require "fileutils"
2
3def open_file_permission_noncompliant(filename)
4
5  # Noncompliant: sets file world writable.
6  FileUtils.chmod 0222, filename
7end

Compliant example

1def open_file_permission_compliant(filename)
2
3  # Compliant: restricts group/world access.
4  FileUtils.chmod 0700, filename
5end