mirror of
https://github.com/anchore/syft.git
synced 2026-11-01 23:16:30 +01:00
feat: RHEL EUS detection (#4023)
* feat: rhel eus detection Signed-off-by: Keith Zantow <kzantow@gmail.com> * chore: update tests Signed-off-by: Keith Zantow <kzantow@gmail.com> * chore: update more tests Signed-off-by: Keith Zantow <kzantow@gmail.com> * rename feature detection functions Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> --------- Signed-off-by: Keith Zantow <kzantow@gmail.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
co-authored by
Alex Goodman
parent
9cbd52bdd7
commit
02703d5c80
@@ -191,6 +191,7 @@ func (c *CreateSBOMConfig) makeTaskGroups(src source.Description) ([][]task.Task
|
||||
scopeTasks := c.scopeTasks()
|
||||
relationshipsTasks := c.relationshipTasks(src)
|
||||
unknownTasks := c.unknownsTasks()
|
||||
osFeatureDetectionTasks := c.osFeatureDetectionTasks()
|
||||
|
||||
pkgTasks, fileTasks, selectionEvidence, err := c.selectTasks(src)
|
||||
if err != nil {
|
||||
@@ -220,6 +221,11 @@ func (c *CreateSBOMConfig) makeTaskGroups(src source.Description) ([][]task.Task
|
||||
taskGroups = append(taskGroups, unknownTasks)
|
||||
}
|
||||
|
||||
// osFeatureDetectionTasks should happen after package scanning is complete
|
||||
if len(osFeatureDetectionTasks) > 0 {
|
||||
taskGroups = append(taskGroups, osFeatureDetectionTasks)
|
||||
}
|
||||
|
||||
// identifying the environment (i.e. the linux release) must be done first as this is required for package cataloging
|
||||
taskGroups = append(
|
||||
[][]task.Task{
|
||||
@@ -444,6 +450,17 @@ func (c *CreateSBOMConfig) unknownsTasks() []task.Task {
|
||||
return tasks
|
||||
}
|
||||
|
||||
// osFeatureDetectionTasks returns a set of tasks that perform post-processing feature detection and update the SBOM accordingly
|
||||
func (c *CreateSBOMConfig) osFeatureDetectionTasks() []task.Task {
|
||||
var tasks []task.Task
|
||||
|
||||
if t := task.NewOSFeatureDetectionTask(); t != nil {
|
||||
tasks = append(tasks, t)
|
||||
}
|
||||
|
||||
return tasks
|
||||
}
|
||||
|
||||
func (c *CreateSBOMConfig) validate() error {
|
||||
if c.Relationships.ExcludeBinaryPackagesWithFileOwnershipOverlap {
|
||||
if !c.Relationships.PackageFileOwnershipOverlap {
|
||||
|
||||
@@ -91,6 +91,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -110,6 +111,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -130,6 +132,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -149,6 +152,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames("file-metadata", "content", "binary-metadata"),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -169,6 +173,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
nil, // note: there is a file cataloging group, with no items in it
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -192,6 +197,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -213,6 +219,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -234,6 +241,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -255,6 +263,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -277,6 +286,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -298,6 +308,7 @@ func TestCreateSBOMConfig_makeTaskGroups(t *testing.T) {
|
||||
fileCatalogerNames(),
|
||||
relationshipCatalogerNames(),
|
||||
unknownsTaskNames(),
|
||||
osFeatureDetectionTaskNames(),
|
||||
},
|
||||
wantManifest: &catalogerManifest{
|
||||
Requested: cataloging.SelectionRequest{
|
||||
@@ -430,6 +441,10 @@ func unknownsTaskNames() []string {
|
||||
return []string{"unknowns-labeler"}
|
||||
}
|
||||
|
||||
func osFeatureDetectionTaskNames() []string {
|
||||
return []string{"os-feature-detection"}
|
||||
}
|
||||
|
||||
func environmentCatalogerNames() []string {
|
||||
return []string{"environment-cataloger"}
|
||||
}
|
||||
|
||||
@@ -480,6 +480,10 @@ func Test_toOsComponent(t *testing.T) {
|
||||
Version: "myVersion",
|
||||
},
|
||||
Properties: &[]cyclonedx.Property{
|
||||
{
|
||||
Name: "syft:distro:extendedSupport",
|
||||
Value: "false",
|
||||
},
|
||||
{
|
||||
Name: "syft:distro:id",
|
||||
Value: "myLinux",
|
||||
|
||||
@@ -102,6 +102,10 @@
|
||||
"version": "1.2.3"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"name": "syft:distro:extendedSupport",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "syft:distro:id",
|
||||
"value": "debian"
|
||||
|
||||
@@ -111,6 +111,10 @@
|
||||
"version": "1.2.3"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"name": "syft:distro:extendedSupport",
|
||||
"value": "false"
|
||||
},
|
||||
{
|
||||
"name": "syft:distro:id",
|
||||
"value": "debian"
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
<description>debian</description>
|
||||
<swid tagId="debian" name="debian" version="1.2.3"></swid>
|
||||
<properties>
|
||||
<property name="syft:distro:extendedSupport">false</property>
|
||||
<property name="syft:distro:id">debian</property>
|
||||
<property name="syft:distro:idLike:0">like!</property>
|
||||
<property name="syft:distro:prettyName">debian</property>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</component>
|
||||
</components>
|
||||
</tools>
|
||||
<component bom-ref="f28a4ba3ddfdddad" type="container">
|
||||
<component bom-ref="redacted" type="container">
|
||||
<name>user-image-input</name>
|
||||
<version>sha256:redacted</version>
|
||||
</component>
|
||||
@@ -56,6 +56,7 @@
|
||||
<description>debian</description>
|
||||
<swid tagId="debian" name="debian" version="1.2.3"></swid>
|
||||
<properties>
|
||||
<property name="syft:distro:extendedSupport">false</property>
|
||||
<property name="syft:distro:id">debian</property>
|
||||
<property name="syft:distro:idLike:0">like!</property>
|
||||
<property name="syft:distro:prettyName">debian</property>
|
||||
|
||||
@@ -25,6 +25,7 @@ type LinuxRelease struct {
|
||||
PrivacyPolicyURL string `json:"privacyPolicyURL,omitempty"`
|
||||
CPEName string `json:"cpeName,omitempty"`
|
||||
SupportEnd string `json:"supportEnd,omitempty"`
|
||||
ExtendedSupport bool `json:"extendedSupport,omitempty"`
|
||||
}
|
||||
|
||||
func (s *IDLikes) UnmarshalJSON(data []byte) error {
|
||||
|
||||
@@ -41,7 +41,7 @@ func ToFormatModel(s sbom.SBOM, cfg EncoderConfig) model.Document {
|
||||
ArtifactRelationships: toRelationshipModel(s.Relationships),
|
||||
Files: toFile(s, coordinateSorter),
|
||||
Source: toSourceModel(s.Source),
|
||||
Distro: toLinuxReleaser(s.Artifacts.LinuxDistribution),
|
||||
Distro: toLinuxRelease(s.Artifacts.LinuxDistribution),
|
||||
Descriptor: toDescriptor(s.Descriptor),
|
||||
Schema: model.Schema{
|
||||
Version: internal.JSONSchemaVersion,
|
||||
@@ -50,7 +50,7 @@ func ToFormatModel(s sbom.SBOM, cfg EncoderConfig) model.Document {
|
||||
}
|
||||
}
|
||||
|
||||
func toLinuxReleaser(d *linux.Release) model.LinuxRelease {
|
||||
func toLinuxRelease(d *linux.Release) model.LinuxRelease {
|
||||
if d == nil {
|
||||
return model.LinuxRelease{}
|
||||
}
|
||||
@@ -73,6 +73,7 @@ func toLinuxReleaser(d *linux.Release) model.LinuxRelease {
|
||||
PrivacyPolicyURL: d.PrivacyPolicyURL,
|
||||
CPEName: d.CPEName,
|
||||
SupportEnd: d.SupportEnd,
|
||||
ExtendedSupport: d.ExtendedSupport,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ func toSyftModel(doc model.Document) *sbom.SBOM {
|
||||
FileLicenses: fileArtifacts.FileLicenses,
|
||||
Executables: fileArtifacts.Executables,
|
||||
Unknowns: fileArtifacts.Unknowns,
|
||||
LinuxDistribution: toSyftLinuxRelease(doc.Distro),
|
||||
LinuxDistribution: toInternalLinuxRelease(doc.Distro),
|
||||
},
|
||||
Source: *toSyftSourceData(doc.Source),
|
||||
Descriptor: toSyftDescriptor(doc.Descriptor),
|
||||
@@ -195,7 +195,7 @@ func toSyftFileType(ty string) stereoscopeFile.Type {
|
||||
}
|
||||
}
|
||||
|
||||
func toSyftLinuxRelease(d model.LinuxRelease) *linux.Release {
|
||||
func toInternalLinuxRelease(d model.LinuxRelease) *linux.Release {
|
||||
if cmp.Equal(d, model.LinuxRelease{}) {
|
||||
return nil
|
||||
}
|
||||
@@ -218,6 +218,7 @@ func toSyftLinuxRelease(d model.LinuxRelease) *linux.Release {
|
||||
PrivacyPolicyURL: d.PrivacyPolicyURL,
|
||||
CPEName: d.CPEName,
|
||||
SupportEnd: d.SupportEnd,
|
||||
ExtendedSupport: d.ExtendedSupport,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ type Release struct {
|
||||
PrivacyPolicyURL string
|
||||
CPEName string // A CPE name for the operating system, in URI binding syntax
|
||||
SupportEnd string // The date at which support for this version of the OS ends.
|
||||
ExtendedSupport bool `cyclonedx:"extendedSupport"` // indicates there was some evidence of extended support found
|
||||
}
|
||||
|
||||
func (r *Release) String() string {
|
||||
|
||||
Reference in New Issue
Block a user