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

feat: add support for CoreOS RHEL flavor #7589

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lebauce
Copy link
Contributor

@lebauce lebauce commented Sep 25, 2024

Description

CoreOS is based on RHEL but the parsing done for /etc/redhat-release reports the version of OpenShift instead of the version of RHEL, preventing vulnerability matching.

Related issues

  • Close #XXX

Related PRs

  • #XXX
  • #YYY

Remove this section if you don't have related PRs.

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@lebauce lebauce changed the title Add support for CoreOS RHEL flavor feat: add support for CoreOS RHEL flavor Sep 25, 2024
@lebauce lebauce force-pushed the main-coreos-support branch 2 times, most recently from c703a0c to 6868d15 Compare September 27, 2024 00:23
@lebauce
Copy link
Contributor Author

lebauce commented Oct 6, 2024

@knqyf263 Could you please have a look at this one ? 🙇

@lebauce
Copy link
Contributor Author

lebauce commented Nov 7, 2024

@knqyf263 @DmitriyLewen Could you please take a look at this one please ?

Comment on lines +83 to +90
split := strings.SplitN(result[2], ".", 4)
major, _ = strconv.Atoi(split[0])
if len(split) > 1 {
minor, _ = strconv.Atoi(split[1])
}
if len(split) > 2 {
rel, _ = strconv.Atoi(split[2])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment with examples why we need this split?
It seems we can just use semver.Parse on result[2]

}

coreosVersion, err := semver.Parse(fmt.Sprintf("%d.%d.%d", major, minor, rel))
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to return error here.

Comment on lines +95 to +109
if coreos4_16, _ := semver.Parse("4.16.0"); coreosVersion.GreaterThanOrEqual(coreos4_16) {
rhelVersion = "9.4"
} else if coreos4_13, _ := semver.Parse("4.13.0"); coreosVersion.GreaterThanOrEqual(coreos4_13) {
rhelVersion = "9.2"
} else if coreos4_11, _ := semver.Parse("4.11.0"); coreosVersion.GreaterThanOrEqual(coreos4_11) {
rhelVersion = "8.6"
} else if coreos4_7_24, _ := semver.Parse("4.7.24"); coreosVersion.GreaterThanOrEqual(coreos4_7_24) {
rhelVersion = "8.4"
} else if coreos4_7_0, _ := semver.Parse("4.7.0"); coreosVersion.GreaterThanOrEqual(coreos4_7_0) {
rhelVersion = "8.3"
} else if coreos4_6_0, _ := semver.Parse("4.6.0"); coreosVersion.GreaterThanOrEqual(coreos4_6_0) {
rhelVersion = "8.2"
} else {
return types.OS{}, xerrors.Errorf("coreos: invalid redhat-release")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm worried it will grow with each new version.

What if create map with versions and use constrains
e.g.: 8.6: ">= 4.11, >= 4.12"

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