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(redhat): detect RedHat version #1387

Merged
merged 2 commits into from Feb 12, 2022

Conversation

MaineK00n
Copy link
Collaborator

What did you implement:

In this part, we are trying to validate the major version, but release is supposed to be in the form of 8.5, which will cause an error in strings.Atoi(release).
This PR fixes the validation to the major version correctly.

vuls/scanner/redhatbase.go

Lines 151 to 158 in 671be3f

ver, err := strconv.Atoi(release)
if err != nil {
logging.Log.Warnf("Failed to parse RedHat/CentOS version number: %s", release)
return true, newCentOS(c)
}
if ver < 5 {
logging.Log.Warnf("Versions prior to RedHat/CentOS 5 are not supported, detected version is %s", release)
}

Type of change

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

How Has This Been Tested?

master

$ vuls configtest
vuls configtest
[Feb 11 20:16:31]  INFO [localhost] vuls-v0.19.3-build-20220211_201157_671be3f
[Feb 11 20:16:31]  INFO [localhost] Validating config...
[Feb 11 20:16:31]  INFO [localhost] Detecting Server/Container OS... 
[Feb 11 20:16:31]  INFO [localhost] Detecting OS of servers... 
[Feb 11 20:16:31]  WARN [localhost] Failed to parse RedHat/CentOS version number: 8.5
[Feb 11 20:16:31]  INFO [localhost] (1/1) Detected: vagrant:
...

MaineK00n/fix-detect-redhat-version

go run cmd/vuls/main.go configtest
[Feb 11 20:16:24]  INFO [localhost] vuls-`make build` or `make install` will show the version-
[Feb 11 20:16:24]  INFO [localhost] Validating config...
[Feb 11 20:16:24]  INFO [localhost] Detecting Server/Container OS... 
[Feb 11 20:16:24]  INFO [localhost] Detecting OS of servers... 
[Feb 11 20:16:24]  INFO [localhost] (1/1) Detected: vagrant: redhat 8.5
...

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 Feb 11, 2022
@MaineK00n MaineK00n force-pushed the MaineK00n/fix-detect-redhat-version branch from 53b7822 to 90008fc Compare February 11, 2022 11:28
@kotakanbe kotakanbe merged commit e585592 into master Feb 12, 2022
@kotakanbe kotakanbe deleted the MaineK00n/fix-detect-redhat-version branch February 12, 2022 11:09
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

2 participants