Sensitive data detected as part of a dynamic file generation.

Description

It is not uncommon to generate logs, backups, or data exports to static file formats. This rule checks if code exists to write sensitive data to static files.

Remediations

❌ Avoid code like the following:

File.open("users.log", "w") { |f| f.write "#{Time.now} - User #{user.email} logged in\n" }
File.open("users.csv", "w") do |f|
users.each do |user|
f.write "#{user.email},#{user.first_name},#{user.last_name}"
end
end

In instances where writing sensitive data is intentional, make sure to document its location according to your internal policies.

Associated CWE

OWASP Top 10

Configuration

To skip this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --skip-rule=ruby_lang_file_generation

To run only this rule during a scan, use the following flag

bearer scan /path/to/your-project/ --only-rule=ruby_lang_file_generation

Ready to take the next step? Learn more about Bearer Cloud.