Skip to content

Commit

Permalink
add remaining comp test
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 25, 2024
1 parent e6a5d18 commit c5212ce
Show file tree
Hide file tree
Showing 7 changed files with 365 additions and 106 deletions.
11 changes: 8 additions & 3 deletions pkg/compliance/fsct/fsct.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package fsct

import (
"context"
"fmt"
"strings"

"github.com/interlynk-io/sbomqs/pkg/compliance/common"
Expand Down Expand Up @@ -396,7 +397,7 @@ func IsComponentPartOfPrimaryDependency(id string) bool {
func fsctPackageDependencies(doc sbom.Document, component sbom.GetComponent) *db.Record {
result, score, maturity := "no-relationships", 0.0, "None"
var dependencies []string
var compWithIncludedRel bool
compWithIncludedRel := false
var compWithNoRel bool
var compWithRel bool
var compWithRelAndIncluded bool
Expand Down Expand Up @@ -441,12 +442,13 @@ func fsctPackageDependencies(doc sbom.Document, component sbom.GetComponent) *db
}

dependencies = doc.GetRelationships(component.GetID())
if dependencies == nil {
if len(dependencies) == 0 {
// Check if any one of the dependencies exists in the ComponentList
if PrimaryDependencies[component.GetID()] {
compWithIncludedRel = true
} else {
compWithNoRel = true
}
compWithNoRel = true
} else {
allDepByName = lo.Map(dependencies, func(d string, _ int) string {
return extractName(d)
Expand All @@ -460,6 +462,7 @@ func fsctPackageDependencies(doc sbom.Document, component sbom.GetComponent) *db

}
}

switch {
case IsMinimimRequirementFulfilled && compWithIncludedRel:
score = 12.0
Expand Down Expand Up @@ -532,6 +535,7 @@ func fsctPackageLicense(component sbom.GetComponent) *db.Record {
// Truncate license content to 1-2 lines
_ = truncateContent(licenseContent, 100) // Adjust the length as needed

fmt.Println("result: ", result)
return db.NewRecordStmt(COMP_LICENSE, component.GetName(), result, score, maturity)
}

Expand All @@ -554,6 +558,7 @@ func fsctPackageCopyright(component sbom.GetComponent) *db.Record {
if isCopyrightPresent {
score = 10.0
maturity = "Minimum"
result = truncateContent(result, 50)
}

return db.NewRecordStmt(COMP_COPYRIGHT, component.GetName(), result, score, maturity)
Expand Down
Loading

0 comments on commit c5212ce

Please sign in to comment.