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(scanner/suse): skip table header in zypper -q lu #2093

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

MaineK00n
Copy link
Collaborator

If this Pull Request is work in progress, Add a prefix of “[WIP]” in the title.

What did you implement:

The current method of skipping table headers in the output of zypper -q lu does not work when spaces are added.
So, until we read a line consisting only of -+, we assume it is a table header.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

a2c6f9dcb28a:~ # zypper -q lu
S  | Repository                                                   | Name     | Current Version | Available Version | Arch
---+--------------------------------------------------------------+----------+-----------------+-------------------+-------
v  | Update repository with updates from SUSE Linux Enterprise 15 | iproute2 | 5.14-150400.1.8 | 6.4-150600.7.3.1  | x86_64

before

$ vuls scan -debug
...
[Dec 18 20:36:05] DEBUG [docker] Executing... zypper -q --no-color lu
[Dec 18 20:36:07] DEBUG [docker] execResult: servername: docker
  cmd: /usr/bin/ssh -o StrictHostKeyChecking=yes -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=auto -o ControlPath=/home/mainek00n/.vuls/cm-a3722a6d-%C -o Controlpersist=10m -l root -p 2222 -i /home/mainek00n/github/github.com/MaineK00n/vuls-targets-docker/.ssh/id_rsa -o PasswordAuthentication=no 127.0.0.1
  exitstatus: 0
  stdout: S  | Repository                                                   | Name     | Current Version | Available Version | Arch
---+--------------------------------------------------------------+----------+-----------------+-------------------+-------
v  | Update repository with updates from SUSE Linux Enterprise 15 | iproute2 | 5.14-150400.1.8 | 6.4-150600.7.3.1  | x86_64

  stderr: stty: 'standard input': Inappropriate ioctl for device

  err: %!s(<nil>)
[Dec 18 20:36:07] DEBUG [localhost] Panic: runtime error: index out of range [1] with length 1 on docker

after

$ vuls scan -debug
...
Scan Summary
================
docker	opensuse.leap15.6	148 installed, 1 updatable

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 Dec 18, 2024
Copy link
Collaborator

@shino shino left a comment

Choose a reason for hiding this comment

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

🎉

@MaineK00n MaineK00n merged commit b0c5dec into master Dec 18, 2024
7 checks passed
@MaineK00n MaineK00n deleted the MaineK00n/patch-2 branch December 18, 2024 13:20
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.

2 participants