Skip to content

Commit

Permalink
fix linting errors
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Kumar Sahu <[email protected]>
  • Loading branch information
viveksahu26 committed Sep 30, 2024
1 parent 2556e37 commit b75e059
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 52 deletions.
37 changes: 17 additions & 20 deletions pkg/compliance/bsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,16 @@ func bsiComponentDepth(doc sbom.Document, component sbom.GetComponent) *db.Recor
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
}
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
} else {
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
if bsiPrimaryDependencies[common.GetID(component.GetSpdxID())] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
} else {
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}
}
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
if bsiPrimaryDependencies[common.GetID(component.GetSpdxID())] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")

} else if doc.Spec().GetSpecType() == "cyclonedx" {
if component.GetPrimaryCompInfo().IsPresent() {
result = strings.Join(bsiGetAllPrimaryDepenciesByName, ", ")
Expand All @@ -393,17 +392,15 @@ func bsiComponentDepth(doc sbom.Document, component sbom.GetComponent) *db.Recor
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
}
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
} else {
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
if bsiPrimaryDependencies[id] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
} else {
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}
}
allDepByName = common.GetDependenciesByName(dependencies, bsiCompIDWithName)
if bsiPrimaryDependencies[id] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}

return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationships", 0.0, "")
Expand Down
3 changes: 0 additions & 3 deletions pkg/compliance/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ func CheckCopyright(cp string) (string, bool) {
return cp, cp != "NOASSERTION" && cp != "NONE"
}

func GetPrimaryDependencies(component sbom.GetComponent) {
}

// ComponentsLists return component lists as a map
func ComponentsLists(doc sbom.Document) map[string]bool {
componentList := make(map[string]bool)
Expand Down
51 changes: 22 additions & 29 deletions pkg/compliance/ntia.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,6 @@ func ntiaSbomCreatedTimestamp(doc sbom.Document) *db.Record {
return db.NewRecordStmt(SBOM_TIMESTAMP, "SBOM Data Fields", result, score, "")
}

func extractName(comp string) string {
for x, y := range compIDWithName {
if strings.Contains(comp, x) {
return y
}
}
return ""
}

var (
compIDWithName = make(map[string]string)
componentList = make(map[string]bool)
Expand Down Expand Up @@ -328,21 +319,24 @@ func ntiaComponentDependencies(doc sbom.Document, component sbom.GetComponent) *

dependencies = doc.GetRelationships(component.GetID())
if dependencies == nil {

if primaryDependencies[common.GetID(component.GetSpdxID())] {
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
}
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
} else {
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
if primaryDependencies[common.GetID(component.GetSpdxID())] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
} else {
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}

}
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)

if primaryDependencies[common.GetID(component.GetSpdxID())] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}

result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")

} else if doc.Spec().GetSpecType() == "cyclonedx" {
if component.GetPrimaryCompInfo().IsPresent() {
result = strings.Join(getAllPrimaryDepenciesByName, ", ")
Expand All @@ -356,17 +350,16 @@ func ntiaComponentDependencies(doc sbom.Document, component sbom.GetComponent) *
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "included-in", 10.0, "")
}
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), "no-relationship", 0.0, "")
} else {
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
if primaryDependencies[id] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
} else {
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}
}
allDepByName = common.GetDependenciesByName(dependencies, compIDWithName)
if primaryDependencies[id] {
allDepByName = append([]string{"included-in"}, allDepByName...)
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")
}
result = strings.Join(allDepByName, ", ")
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, 10.0, "")

}
return db.NewRecordStmt(COMP_DEPTH, component.GetName(), result, score, "")
}
Expand Down

0 comments on commit b75e059

Please sign in to comment.