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

fix brakeman warning about possible command injection #20130

Merged
merged 1 commit into from
May 7, 2020

Conversation

d-m-u
Copy link
Contributor

@d-m-u d-m-u commented May 6, 2020

This line's in our brakeman ignore right now because we were supposed to get back to it later.

Confidence: Medium
Category: Command Injection
Check: Execute
Message: Possible command injection
Code: system("kill -WINCH #{`pgrep -P 1 httpd`.chomp.to_i}")
File: lib/miq_apache/control.rb
Line: 55

@d-m-u
Copy link
Contributor Author

d-m-u commented May 6, 2020

@miq-bot add_label security

@miq-bot
Copy link
Member

miq-bot commented May 6, 2020

@d-m-u Cannot apply the following label because they are not recognized:

  • security

All labels for ManageIQ/manageiq: https://github.com/ManageIQ/manageiq/labels

@d-m-u
Copy link
Contributor Author

d-m-u commented May 6, 2020

phooey
@miq-bot add_label core/security
silly bot

@chessbyte
Copy link
Member

Would AwesomeSpawn.run("kill", :params {:WINCH => pid}) make more sense to build the command line without the possibility of injection?

@Fryguy
Copy link
Member

Fryguy commented May 6, 2020

I agree with @chessbyte but I'm not sure why we are shelling out at all, when the Process class should do this for us:

Process.kill("WINCH", pid)

@d-m-u d-m-u force-pushed the use_awesome_spawn_for_apache_stop branch from 7037b1c to 14dab93 Compare May 6, 2020 19:14
@d-m-u d-m-u requested a review from jrafanie as a code owner May 6, 2020 19:14
@miq-bot
Copy link
Member

miq-bot commented May 6, 2020

Checked commit d-m-u@14dab93 with ruby 2.5.7, rubocop 0.69.0, haml-lint 0.28.0, and yamllint
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@Fryguy
Copy link
Member

Fryguy commented May 6, 2020

Not sure we have specs on this. @carbonin can you review?

@@ -52,7 +52,7 @@ def self.start
def self.stop
if ENV["CONTAINER"]
pid = `pgrep -P 1 httpd`.chomp.to_i
system("kill -WINCH #{pid}") if pid > 0
Process.kill("WINCH", pid) if pid > 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@d-m-u d-m-u changed the title fix brakeman warning about possible command injection [wip] fix brakeman warning about possible command injection May 6, 2020
@miq-bot miq-bot added the wip label May 6, 2020
@d-m-u d-m-u changed the title [wip] fix brakeman warning about possible command injection fix brakeman warning about possible command injection May 6, 2020
@miq-bot miq-bot removed the wip label May 6, 2020
@carbonin carbonin merged commit 34bfb38 into ManageIQ:master May 7, 2020
@d-m-u d-m-u deleted the use_awesome_spawn_for_apache_stop branch May 7, 2020 13:21
simaishi pushed a commit that referenced this pull request May 8, 2020
fix brakeman warning about possible command injection

(cherry picked from commit 34bfb38)
@simaishi
Copy link
Contributor

simaishi commented May 8, 2020

Jansa backport details:

$ git log -1
commit 2fcab30c77b9fc6c4321a7a0d1c11d33d7e992e2
Author: Nick Carboni <ncarboni@redhat.com>
Date:   Thu May 7 08:53:48 2020 -0400

    Merge pull request #20130 from d-m-u/use_awesome_spawn_for_apache_stop

    fix brakeman warning about possible command injection

    (cherry picked from commit 34bfb385e198264a3c5ee8fa06c42b7ea1e27838)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants