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(scan): warning if lsof command not found #1167

Merged
merged 1 commit into from
Feb 6, 2021
Merged

Conversation

kotakanbe
Copy link
Member

@kotakanbe kotakanbe commented Feb 6, 2021

What did you implement:

[Feb  6 08:27:21] DEBUG [c7] Executing... lsof -i -P -n | grep LISTEN                                                                        
[Feb  6 08:27:21] DEBUG [c7] execResult: servername: c7                                                                                                       
cmd: /usr/bin/ssh -tt -o StrictHostKeyChecking=yes -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=auto -o ControlPath=/home/ubuntu/.vuls/controlmaster-%r-c7.%p -o Controlpersist=10m [email protected] -p 22 -i /home/ubuntu/.ssh/stg.pem -o PasswordAuthentication=no stty cols 1000; sudo -S lsof -i -P -n | grep LISTEN                                                                                                                     
exitstatus: 1                                                                                                                                               
stdout: sudo: lsof: command not found                                                                                                                                                                                                                                                                                   
stderr:                                                                                                                                                     err: %!s(<nil>)                                                                                                                                           

#863 changed to debug message when grep count is zero, and debug message when lsof command is not found(It was error before).

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

^C⏎                                                                                                                                                                                                                                                                                                                                                                                                    ✗  ubuntu@dev  ~│g│s│g│f│vuls  ⎇ lsof-err-handle~  ./vuls scan c7
[Feb  7 07:20:00] ERROR Failed to create log file. path: /var/log/vuls/localhost.log, err: open /var/log/vuls/localhost.log: permission denied
[Feb  7 07:20:00]  INFO [localhost] vuls-v0.15.6-build-20210207_070958_cd67220
[Feb  7 07:20:00]  INFO [localhost] Start scanning
[Feb  7 07:20:00]  INFO [localhost] config: /home/ubuntu/go/src/github.com/future-architect/vuls/config.toml
[Feb  7 07:20:00]  INFO [localhost] Validating config...
[Feb  7 07:20:00]  INFO [localhost] Detecting Server/Container OS... 
[Feb  7 07:20:00]  INFO [localhost] Detecting OS of servers... 
[Feb  7 07:20:00] ERROR Failed to create log file. path: /var/log/vuls/c7.log, err: open /var/log/vuls/c7.log: permission denied
[Feb  7 07:20:00]  INFO [c7] vuls-v0.15.6-build-20210207_070958_cd67220
[Feb  7 07:20:00]  INFO [localhost] (1/1) Detected: c7: centos 7.7.1908
[Feb  7 07:20:00]  INFO [localhost] Detecting OS of containers... 
[Feb  7 07:20:00]  INFO [localhost] Checking Scan Modes... 
[Feb  7 07:20:00]  INFO [localhost] Detecting Platforms... 
[Feb  7 07:20:01]  INFO [localhost] (1/1) c7 is running on aws
[Feb  7 07:20:01]  INFO [localhost] Detecting IPS identifiers... 
[Feb  7 07:20:01]  INFO [localhost] (1/1) c7 has 0 IPS integration
[Feb  7 07:20:01]  INFO [c7] Scanning OS pkg in fast-root mode
[Feb  7 07:20:08]  WARN [c7] Failed to lsof: Failed to lsof: execResult: servername: c7
      cmd: /usr/bin/ssh -tt -o StrictHostKeyChecking=yes -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=auto -o ControlPath=/home/ubuntu/.vuls/controlmaster-%r-c7.%p -o Controlpersist=10m [email protected] -p 22 -i /home/ubuntu/.ssh/stg.pem -o PasswordAuthentication=no stty cols 1000; sudo -S lsof -i -P -n
      exitstatus: 1
      stdout: sudo: lsof: command not found
    
      stderr: 
      err: %!s(<nil>):
    github.com/future-architect/vuls/scan.(*base).lsOfListen
        /home/ubuntu/go/src/github.com/future-architect/vuls/scan/base.go:900
[Feb  7 07:20:14]  INFO [c7] Scanning listen port...


Scan Summary
================
c7      centos7.7.1908  303 installed, 134 updatable

Checklist:

  • Write tests
  • Write documentation
  • Check that there aren't other open pull requests for the same issue/feature
  • Format your source code by make fmt
  • Pass the test by make test
  • Provide verification config / commands
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES

@kotakanbe kotakanbe merged commit 51b8e16 into master Feb 6, 2021
@kotakanbe kotakanbe deleted the lsof-err-handle branch February 6, 2021 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant