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

breaking-change(configtest, scan): categorize error #1501

Closed
wants to merge 2 commits into from

Conversation

MaineK00n
Copy link
Collaborator

@MaineK00n MaineK00n commented Jul 25, 2022

What did you implement:

When scanning servers together in the CIDR Range or when many servers are defined in config.toml, I wanted to classify servers that have been successfully "configtest" or "scan" and those that have not.

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

setup

$ vagrant up
$ ssh vagrant@192.168.56.2 -i /home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa
vagrant@ubuntu-focal:~$ sudo apt install -y lsof iproute2 debian-goodies
$ ssh vagrant@192.168.56.3 -i /home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa
  • Vagrantfile
Vagrant.configure("2") do |config|
    # pass
    config.vm.define "host1" do |host1|
      host1.vm.box = "ubuntu/focal64"
      host1.vm.network :private_network, ip: "192.168.56.2"
    end
  
    # not installed the commands(lsof, iproute2, debian-goodies) required by vuls
    config.vm.define "host2" do |host2|
      host2.vm.box = "ubuntu/focal64"
      host2.vm.network :private_network, ip: "192.168.56.3"
    end

    # ssh config error
    config.vm.define "host3" do |host3|
        host3.vm.box = "ubuntu/focal64"
        host3.vm.network :private_network, ip: "192.168.56.4"
    end
  
    if Vagrant.has_plugin?("vagrant-vbguest")
      config.vbguest.auto_update = false  
    end
  
    config.vm.provision "shell", privileged: false do |s|
      ssh_pub_key = ""
      if File.file?("/home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa.pub")
        ssh_pub_key = File.readlines("/home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa.pub").first.strip
      else
        puts "No SSH key found. You will need to remedy this before pushing to the repository."
      end
      s.inline = <<-SHELL
        if grep -sq "#{ssh_pub_key}" /home/vagrant/.ssh/authorized_keys; then
          echo "SSH keys already provisioned."
          exit 0;
        fi
        echo "SSH key provisioning."
        mkdir -p /home/vagrant/.ssh/
        touch /home/vagrant/.ssh/authorized_keys
        echo #{ssh_pub_key} >> /home/vagrant/.ssh/authorized_keys
      SHELL
    end
  end

configtest

$ vuls configtest
...
Configtest Summary
==================
localhost                	Pass            
vuls-target(192.168.56.2)	Pass            
vuls-target(192.168.56.3)	ErrUncategorized	debian-goodies is not installed                                                                     
vuls-target(192.168.56.4)	ErrSSHConfig    	Failed to find the host in known_hosts. Please exec `$ /usr/bin/ssh -i                              
                         	                	/home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa -p 22 -l vagrant        
                         	                	192.168.56.4` or `$ /usr/bin/ssh-keyscan -H -p 22 192.168.56.4 >> ~/.ssh/known_hosts`               
vuls-target(192.168.56.5)	ErrIPUnreachable	dial tcp 192.168.56.5:22: connect: no route to host
  • config.toml
[servers.vuls-target]
host                = "192.168.56.0/29"
ignoreIPAddresses = ["192.168.56.1", "192.168.56.6"]
user               = "vagrant"
keyPath            = "/home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa"
scanMode           = ["fast-root"]
scanModules        = ["ospkg"]

Checklist:

You don't have to satisfy all of the following.

  • 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

Reference

@MaineK00n MaineK00n self-assigned this Jul 25, 2022
@MaineK00n MaineK00n changed the title feat(configtest, scan): categorize error breaking-change(configtest, scan): categorize error Jul 25, 2022
@MaineK00n MaineK00n force-pushed the MaineK00n/categorize-error branch 4 times, most recently from 0d6622f to 9486224 Compare July 27, 2022 11:46
@MaineK00n MaineK00n marked this pull request as ready for review July 27, 2022 11:49
@MaineK00n MaineK00n force-pushed the MaineK00n/categorize-error branch 4 times, most recently from 0520773 to a9de1ff Compare July 28, 2022 01:15
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.

None yet

1 participant