[REQ] add guardrails for parsing OS version
sozercan opened this issue · comments
What kind of request is this?
Improvement of existing experience
What is your request or suggestion?
For example, for ubuntu if a scanner return X.Y.Z, copa tries to pull in the ubuntu:X.Y.Z image which doesn't exist
related to #437
Are you willing to submit PRs to contribute to this feature request?
- Yes, I am willing to implement it.
Hii @sozercan I am interested in this issue. Can you assign it to me.
Also Can you explain me what we actually want through this. Do we need to throw error as per this for ubuntu if a scanner return X.Y.Z, copa tries to pull in the ubuntu:X.Y.Z image which doesn't exist
that image doesn't exist or check availability of the Docker image corresponding to the reported OS version before attempting to pull it
On first looking, I got this idea
We can change like this
case strings.Contains(osType, "ubuntu"):
// For Ubuntu, extract the major and minor version (e.g., 22.04)
versionParts := strings.Split(osVersion, ".")
if len(versionParts) >= 2 {
osVersion = strings.Join(versionParts[:2], ".")
} else {
return "", "", fmt.Errorf("invalid Ubuntu version format: %s", osVersion)
}
return "ubuntu", osVersion, nil
here. By defining osVersion := osData["VERSION_ID"]
in getOSType function. This can easily remove this issue. WDYT @sozercan @ashnamehrotra
Most of work on this issue with this approach is complete, If you all agree then i would like to raise a PR.
/assign
Hii @ashnamehrotra I have used getOSVersion() function as you suggested and raised a PR, PTAL whenever you find time :)