Skip to content

Commit ad35777

Browse files
committed
fix linting errors
Signed-off-by: Vivek Kumar Sahu <vivekkumarsahu650@gmail.com>
1 parent c9f80ca commit ad35777

File tree

8 files changed

+31
-69
lines changed

8 files changed

+31
-69
lines changed

golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ linters:
1313
- stylecheck
1414
- staticcheck
1515
- unconvert
16-
- whitespace
1716

1817
linters-settings:
1918
unparam:

pkg/compliance/common/common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func CheckSwid(swid []swid.SWID) (string, bool) {
218218
results := []string{}
219219
for _, s := range swid {
220220
if s.GetTagID() != "" && s.GetName() != "" {
221-
result := string(s.GetTagID()) + ", " + string(s.GetName())
221+
result := s.GetTagID() + ", " + s.GetName()
222222
results = append(results, result)
223223
}
224224
}

pkg/compliance/compliance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func ComplianceResult(ctx context.Context, doc sbom.Document, reportType, fileNa
8181
octResult(ctx, doc, fileName, outFormat)
8282

8383
case reportType == FSCT_V3:
84-
fsct.FsctResult(ctx, doc, fileName, outFormat)
84+
fsct.Result(ctx, doc, fileName, outFormat)
8585

8686
default:
8787
fmt.Println("No compliance type is provided")

pkg/compliance/fsct/fsct.go

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,20 @@ import (
2525
"github.com/samber/lo"
2626
)
2727

28-
func FsctResult(ctx context.Context, doc sbom.Document, fileName string, outFormat string) {
28+
func Result(ctx context.Context, doc sbom.Document, fileName string, outFormat string) {
2929
log := logger.FromContext(ctx)
3030
log.Debug("fsct compliance")
3131

3232
dtb := db.NewDB()
3333

3434
// SBOM Level
35-
dtb.AddRecord(FsctSbomAuthor(doc))
36-
dtb.AddRecord(FsctSbomTimestamp(doc))
37-
dtb.AddRecord(FsctSbomType(doc))
38-
dtb.AddRecord(FsctSbomPrimaryComponent(doc))
35+
dtb.AddRecord(SbomAuthor(doc))
36+
dtb.AddRecord(SbomTimestamp(doc))
37+
dtb.AddRecord(SbomType(doc))
38+
dtb.AddRecord(SbomPrimaryComponent(doc))
3939

4040
// component Level
41-
dtb.AddRecords(FsctComponents(doc))
41+
dtb.AddRecords(Components(doc))
4242

4343
if outFormat == "json" {
4444
fsctJSONReport(dtb, fileName)
@@ -53,7 +53,7 @@ func FsctResult(ctx context.Context, doc sbom.Document, fileName string, outForm
5353
}
5454
}
5555

56-
func FsctSbomPrimaryComponent(doc sbom.Document) *db.Record {
56+
func SbomPrimaryComponent(doc sbom.Document) *db.Record {
5757
result, score, maturity := "", 0.0, "None"
5858

5959
// waiting for NTIA to get merged
@@ -67,7 +67,7 @@ func FsctSbomPrimaryComponent(doc sbom.Document) *db.Record {
6767
return db.NewRecordStmt(SBOM_PRIMARY_COMPONENT, "doc", result, score, maturity)
6868
}
6969

70-
func FsctSbomType(doc sbom.Document) *db.Record {
70+
func SbomType(doc sbom.Document) *db.Record {
7171
result, score, maturity := "", 0.0, "None"
7272

7373
lifecycles := doc.Lifecycles()
@@ -82,7 +82,7 @@ func FsctSbomType(doc sbom.Document) *db.Record {
8282
return db.NewRecordStmt(SBOM_TYPE, "doc", result, score, maturity)
8383
}
8484

85-
func FsctSbomTimestamp(doc sbom.Document) *db.Record {
85+
func SbomTimestamp(doc sbom.Document) *db.Record {
8686
result, score, maturity := "", 0.0, "None"
8787

8888
if result = doc.Spec().GetCreationTimestamp(); result != "" {
@@ -94,7 +94,7 @@ func FsctSbomTimestamp(doc sbom.Document) *db.Record {
9494
return db.NewRecordStmt(SBOM_TIMESTAMP, "doc", result, score, maturity)
9595
}
9696

97-
func FsctSbomAuthor(doc sbom.Document) *db.Record {
97+
func SbomAuthor(doc sbom.Document) *db.Record {
9898
result, score, maturity := "", 0.0, ""
9999
authorPresent, toolPresent := false, false
100100
toolResult, authorResult := "", ""
@@ -161,7 +161,7 @@ func extractName(comp string) string {
161161
return ""
162162
}
163163

164-
func FsctComponents(doc sbom.Document) []*db.Record {
164+
func Components(doc sbom.Document) []*db.Record {
165165
records := []*db.Record{}
166166

167167
if len(doc.Components()) == 0 {
@@ -182,7 +182,6 @@ func FsctComponents(doc sbom.Document) []*db.Record {
182182
}
183183
}
184184
} else if doc.Spec().GetSpecType() == "cyclonedx" {
185-
186185
CompIDWithName[component.GetID()] = component.GetName()
187186
ComponentList[component.GetID()] = true
188187
if component.GetPrimaryCompInfo().IsPresent() {
@@ -214,7 +213,6 @@ func FsctComponents(doc sbom.Document) []*db.Record {
214213
IsMinimimRequirementFulfilled = true
215214
GetAllPrimaryDepenciesByName = allDepByName
216215
}
217-
218216
}
219217
} else if doc.Spec().GetSpecType() == "cyclonedx" {
220218
// strings.Contains(s.PrimaryComponent.ID, string(sc.PackageSPDXIdentifier))
@@ -242,11 +240,9 @@ func FsctComponents(doc sbom.Document) []*db.Record {
242240
IsMinimimRequirementFulfilled = true
243241
GetAllPrimaryDepenciesByName = allDepByName
244242
}
245-
246243
}
247244
}
248245
}
249-
250246
for _, component := range doc.Components() {
251247
records = append(records, fsctPackageName(component))
252248
records = append(records, fsctPackageVersion(component))
@@ -343,7 +339,6 @@ func fsctPackageUniqIDs(component sbom.GetComponent) *db.Record {
343339
score = 10.0
344340
maturity = "Minimum"
345341
result = strings.Join(uniqIDResults, ", ")
346-
347342
}
348343
return db.NewRecordStmt(COMP_UNIQ_ID, component.GetName(), result, score, maturity)
349344
}
@@ -391,15 +386,14 @@ func IsComponentPartOfPrimaryDependency(id string) bool {
391386
}
392387

393388
func fsctPackageDependencies(doc sbom.Document, component sbom.GetComponent) *db.Record {
394-
result, score, maturity := "no-relationships", 0.0, "None"
389+
result, score, maturity := "", 0.0, ""
395390
var dependencies []string
396391
compWithIncludedRel := false
397392
var compWithNoRel bool
398393
var compWithRel bool
399394
var compWithRelAndIncluded bool
400395
var allDepByName []string
401396
if doc.Spec().GetSpecType() == "spdx" {
402-
403397
if component.GetPrimaryCompInfo().IsPresent() {
404398
result = strings.Join(GetAllPrimaryDepenciesByName, ", ")
405399
score = 10.0
@@ -427,7 +421,6 @@ func fsctPackageDependencies(doc sbom.Document, component sbom.GetComponent) *db
427421
// no dependency
428422
compWithRel = true
429423
}
430-
431424
}
432425
} else if doc.Spec().GetSpecType() == "cyclonedx" {
433426
if component.GetPrimaryCompInfo().IsPresent() {
@@ -452,13 +445,10 @@ func fsctPackageDependencies(doc sbom.Document, component sbom.GetComponent) *db
452445
if PrimaryDependencies[component.GetID()] {
453446
compWithRelAndIncluded = true
454447
allDepByName = append([]string{"included-in"}, allDepByName...)
455-
// allDepByName = append(allDepByName, "included-in")
456448
}
457449
compWithRel = true
458-
459450
}
460451
}
461-
462452
switch {
463453
case IsMinimimRequirementFulfilled && compWithIncludedRel:
464454
score = 12.0

pkg/compliance/fsct/fsct_report.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"sigs.k8s.io/release-utils/version"
2828
)
2929

30+
// nolint
3031
const (
3132
SBOM_AUTHOR = iota
3233
SBOM_TIMESTAMP

pkg/compliance/fsct/fsct_test.go

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
139139
}{
140140
{
141141
name: "CDX SBOM with author name only",
142-
actual: FsctSbomAuthor(cdxDocWithSbomAuthorName()),
142+
actual: SbomAuthor(cdxDocWithSbomAuthorName()),
143143
expected: desired{
144144
score: 10.0,
145145
result: "Samantha Wright",
@@ -150,7 +150,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
150150
},
151151
{
152152
name: "CDX SBOM with author name and email",
153-
actual: FsctSbomAuthor(cdxDocWithSbomAuthorNameAndEmail()),
153+
actual: SbomAuthor(cdxDocWithSbomAuthorNameAndEmail()),
154154
expected: desired{
155155
score: 10.0,
156156
result: "Samantha Wright (samantha.wright@example.com)",
@@ -161,7 +161,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
161161
},
162162
{
163163
name: "CDX SBOM with author name and contact",
164-
actual: FsctSbomAuthor(cdxDocWithSbomAuthorNameAndContact()),
164+
actual: SbomAuthor(cdxDocWithSbomAuthorNameAndContact()),
165165
expected: desired{
166166
score: 10.0,
167167
result: "Samantha Wright (800-555-1212)",
@@ -172,7 +172,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
172172
},
173173
{
174174
name: "CDX SBOM with author name, email and contact",
175-
actual: FsctSbomAuthor(cdxDocWithSbomAuthorNameEmailAndContact()),
175+
actual: SbomAuthor(cdxDocWithSbomAuthorNameEmailAndContact()),
176176
expected: desired{
177177
score: 10.0,
178178
result: "Samantha Wright (samantha.wright@example.com, 800-555-1212)",
@@ -183,7 +183,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
183183
},
184184
{
185185
name: "CDX SBOM with a tool",
186-
actual: FsctSbomAuthor(cdxDocWithTool()),
186+
actual: SbomAuthor(cdxDocWithTool()),
187187
expected: desired{
188188
score: 0.0,
189189
result: "sbom-tool-9.1.2",
@@ -194,7 +194,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
194194
},
195195
{
196196
name: "CDX SBOM with multiple tools",
197-
actual: FsctSbomAuthor(cdxDocWithMultipleTools()),
197+
actual: SbomAuthor(cdxDocWithMultipleTools()),
198198
expected: desired{
199199
score: 0.0,
200200
result: "sbom-tool-9.1.2, syft-1.1.2",
@@ -205,7 +205,7 @@ func TestFsctCDXSbomAuthorFields(t *testing.T) {
205205
},
206206
{
207207
name: "CDX SBOM with a Author and tool",
208-
actual: FsctSbomAuthor(cdxDocWithAuthorAndTools()),
208+
actual: SbomAuthor(cdxDocWithAuthorAndTools()),
209209
expected: desired{
210210
score: 12.0,
211211
result: "Samantha Wright (samantha.wright@example.com, 800-555-1212), sbom-tool-9.1.2",
@@ -270,7 +270,7 @@ func TestFsctCDXOtherSbomLevelFields(t *testing.T) {
270270
}{
271271
{
272272
name: "CDX SBOM with timestamp",
273-
actual: FsctSbomTimestamp(cdxDocWithTimestamp()),
273+
actual: SbomTimestamp(cdxDocWithTimestamp()),
274274
expected: desired{
275275
score: 10.0,
276276
result: "2020-04-13T20:20:39+00:00",
@@ -281,7 +281,7 @@ func TestFsctCDXOtherSbomLevelFields(t *testing.T) {
281281
},
282282
{
283283
name: "CDX SBOM with custom phase lifecycle",
284-
actual: FsctSbomType(cdxDocWithCustomPhaseLifecycles()),
284+
actual: SbomType(cdxDocWithCustomPhaseLifecycles()),
285285
expected: desired{
286286
score: 15.0,
287287
result: "platform-integration-testing",
@@ -292,7 +292,7 @@ func TestFsctCDXOtherSbomLevelFields(t *testing.T) {
292292
},
293293
{
294294
name: "CDX SBOM with pre-defined phase lifecycle",
295-
actual: FsctSbomType(cdxDocWithPreDefinedPhaseLifecycles()),
295+
actual: SbomType(cdxDocWithPreDefinedPhaseLifecycles()),
296296
expected: desired{
297297
score: 15.0,
298298
result: "build",
@@ -303,7 +303,7 @@ func TestFsctCDXOtherSbomLevelFields(t *testing.T) {
303303
},
304304
{
305305
name: "CDX SBOM with primary component",
306-
actual: FsctSbomPrimaryComponent(cdxDocWithPrimaryComponent()),
306+
actual: SbomPrimaryComponent(cdxDocWithPrimaryComponent()),
307307
expected: desired{
308308
score: 10.0,
309309
result: "git@github.com:interlynk/sbomqs.git",
@@ -402,7 +402,7 @@ func TestFsctSPDXSbomLevelFields(t *testing.T) {
402402
}{
403403
{
404404
name: "SPDX SBOM with lifecycle",
405-
actual: FsctSbomType(spdxDocWithLifecycles()),
405+
actual: SbomType(spdxDocWithLifecycles()),
406406
expected: desired{
407407
score: 15.0,
408408
result: "hellow, this is sbom build phase",
@@ -413,7 +413,7 @@ func TestFsctSPDXSbomLevelFields(t *testing.T) {
413413
},
414414
{
415415
name: "SPDX SBOM with primary component",
416-
actual: FsctSbomPrimaryComponent(spdxDocWithPrimaryComponent()),
416+
actual: SbomPrimaryComponent(spdxDocWithPrimaryComponent()),
417417
expected: desired{
418418
score: 10.0,
419419
result: "SPDXRef-DocumentRoot-File-sbomqs-linux-amd64",
@@ -424,7 +424,7 @@ func TestFsctSPDXSbomLevelFields(t *testing.T) {
424424
},
425425
{
426426
name: "SPDX SBOM with author name only",
427-
actual: FsctSbomAuthor(spdxDocWithSbomAuthor()),
427+
actual: SbomAuthor(spdxDocWithSbomAuthor()),
428428
expected: desired{
429429
score: 10.0,
430430
result: "Jane Doe",
@@ -435,7 +435,7 @@ func TestFsctSPDXSbomLevelFields(t *testing.T) {
435435
},
436436
{
437437
name: "SPDX SBOM with tool only",
438-
actual: FsctSbomAuthor(spdxDocWithSbomTool()),
438+
actual: SbomAuthor(spdxDocWithSbomTool()),
439439
expected: desired{
440440
score: 0.0,
441441
result: "syft-1.9.0",
@@ -446,7 +446,7 @@ func TestFsctSPDXSbomLevelFields(t *testing.T) {
446446
},
447447
{
448448
name: "SPDX SBOM with Author and tool both",
449-
actual: FsctSbomAuthor(spdxDocWithSbomAuthorAndTool()),
449+
actual: SbomAuthor(spdxDocWithSbomAuthorAndTool()),
450450
expected: desired{
451451
score: 12.0,
452452
result: "Jane Doe, syft-1.9.0",
@@ -766,21 +766,6 @@ func TestFsctComponentLevelOnSpdxAndCdx(t *testing.T) {
766766
}
767767
}
768768

769-
func cdxCompWithUniqID() sbom.GetComponent {
770-
name := "cobra"
771-
p := []purl.PURL{}
772-
npurl := purl.NewPURL("pkg:github/spf13/cobra@e94f6d0dd9a5e5738dca6bce03c4b1207ffbc0ec")
773-
if npurl.Valid() {
774-
p = append(p, npurl)
775-
}
776-
777-
comp := sbom.Component{
778-
Name: name,
779-
Purls: p,
780-
}
781-
return comp
782-
}
783-
784769
func primaryCompWithHigherChecksum() (sbom.Document, sbom.GetComponent) {
785770
primary := sbom.PrimaryComp{}
786771

@@ -1384,17 +1369,6 @@ func cdxCompWithOmniBorID() sbom.GetComponent {
13841369
return comp
13851370
}
13861371

1387-
func cdxCompWithCPE() sbom.GetComponent {
1388-
comp := sbom.NewComponent()
1389-
comp.Name = "packageurl-go"
1390-
PackageURL := "pkg:github/package-url/packageurl-go@7cb81af9593b9512bb946c55c85609948c48aab9"
1391-
1392-
prl := purl.NewPURL(PackageURL)
1393-
comp.Purls = []purl.PURL{prl}
1394-
1395-
return comp
1396-
}
1397-
13981372
func cdxCompWithPurlOmniSwhidAndSwid() sbom.GetComponent {
13991373
comp := sbom.NewComponent()
14001374
comp.Name = "acme"

pkg/engine/compliance.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func getSbomDocument(ctx context.Context, ep *Params) (*sbom.Document, error) {
8686

8787
if IsURL(path) {
8888
log.Debugf("Processing Git URL path :%s\n", path)
89-
9089
url, sbomFilePath := path, path
9190
var err error
9291

pkg/sbom/spdx.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ func (s *SpdxDoc) parsePrimaryCompAndRelationships() {
344344
continue
345345
}
346346
s.Dependencies[CleanKey(string(aBytes))] = append(s.Dependencies[CleanKey(string(aBytes))], CleanKey(string(bBytes)))
347-
348347
}
349348
}
350349
s.PrimaryComponent.Dependecies = totalDependencies

0 commit comments

Comments
 (0)