Skip to content

Commit

Permalink
🧹 remove useless if conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Feb 16, 2024
1 parent f797eee commit 7c4033b
Showing 1 changed file with 38 additions and 40 deletions.
78 changes: 38 additions & 40 deletions sbom/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,54 +98,52 @@ func GenerateBom(r *ReportCollectionJson) ([]Sbom, error) {
bom.Packages = append(bom.Packages, bomPkg)
}
}
if rb.PythonPackages != nil {
for _, pkg := range rb.PythonPackages {
bomPkg := &Package{
Name: pkg.Name,
Version: pkg.Version,
Purl: pkg.Purl,
Cpes: pkg.CPEs,
Type: "pypi",
}

// deprecated path, all files are now in the FilePaths field
// TODO: update once the python resource returns multiple results
if pkg.FilePath != "" {
bomPkg.EvidenceList = append(bomPkg.EvidenceList, &Evidence{
Type: EvidenceType_EVIDENCE_TYPE_FILE,
Value: pkg.FilePath,
})
}
for _, pkg := range rb.PythonPackages {
bomPkg := &Package{
Name: pkg.Name,
Version: pkg.Version,
Purl: pkg.Purl,
Cpes: pkg.CPEs,
Type: "pypi",
}

for _, filepath := range pkg.FilePaths {
bomPkg.EvidenceList = append(bomPkg.EvidenceList, &Evidence{
Type: EvidenceType_EVIDENCE_TYPE_FILE,
Value: filepath,
})
}
// deprecated path, all files are now in the FilePaths field
// TODO: update once the python resource returns multiple results
if pkg.FilePath != "" {
bomPkg.EvidenceList = append(bomPkg.EvidenceList, &Evidence{
Type: EvidenceType_EVIDENCE_TYPE_FILE,
Value: pkg.FilePath,
})
}

bom.Packages = append(bom.Packages, bomPkg)
for _, filepath := range pkg.FilePaths {
bomPkg.EvidenceList = append(bomPkg.EvidenceList, &Evidence{
Type: EvidenceType_EVIDENCE_TYPE_FILE,
Value: filepath,
})
}

bom.Packages = append(bom.Packages, bomPkg)
}
if rb.NpmPackages != nil {
for _, pkg := range rb.NpmPackages {
bomPkg := &Package{
Name: pkg.Name,
Version: pkg.Version,
Purl: pkg.Purl,
Cpes: pkg.CPEs,
Type: "npm",
}

for _, filepath := range pkg.FilePaths {
bomPkg.EvidenceList = append(bomPkg.EvidenceList, &Evidence{
Type: EvidenceType_EVIDENCE_TYPE_FILE,
Value: filepath,
})
}
for _, pkg := range rb.NpmPackages {
bomPkg := &Package{
Name: pkg.Name,
Version: pkg.Version,
Purl: pkg.Purl,
Cpes: pkg.CPEs,
Type: "npm",
}

bom.Packages = append(bom.Packages, bomPkg)
for _, filepath := range pkg.FilePaths {
bomPkg.EvidenceList = append(bomPkg.EvidenceList, &Evidence{
Type: EvidenceType_EVIDENCE_TYPE_FILE,
Value: filepath,
})
}

bom.Packages = append(bom.Packages, bomPkg)
}
}
boms = append(boms, bom)
Expand Down

0 comments on commit 7c4033b

Please sign in to comment.