Skip to content
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

Improve CommandLiteralInjection #9

Open
dentarg opened this issue Jul 12, 2024 · 1 comment
Open

Improve CommandLiteralInjection #9

dentarg opened this issue Jul 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@dentarg
Copy link
Contributor

dentarg commented Jul 12, 2024

The suggestion from CommandLiteralInjection isn't great, just switching from the backtick method to system does not make what ever you are doing safe. https://ruby-doc.org/3.3.0/command_injection_rdoc.html

module EightyFourCodes
# Check for use of `/bin/ls #{params[:file]}` and %x(/bin/ls #{params[:file]})
#
# Passing user input to `` and %x without sanitization and parameterization can result in command injection
#
# @example
#
# # bad
# %x(/bin/ls #{filename})
#
# # good (parameters)
# system("/bin/ls", filename)
# # even better
# exec("/bin/ls", shell_escape(filename))
#
class CommandLiteralInjection < RuboCop::Cop::Cop
MSG = 'Do not include variables command literals. Use parameters "system(cmd, params)" or exec() instead'.freeze

@dentarg dentarg added the bug Something isn't working label Jul 12, 2024
@dentarg
Copy link
Contributor Author

dentarg commented Jul 12, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant