Skip to content

Commit 480e816

Browse files
committed
integrated opensca for risk analysis
Signed-off-by: Vivek Kumar Sahu <vivekkumarsahu650@gmail.com>
1 parent b3f4692 commit 480e816

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

pkg/scvs/scvs.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package scvs
1616

1717
import (
18+
"bytes"
1819
"fmt"
1920
"os"
2021
"os/exec"
@@ -164,10 +165,31 @@ func IsSBOMTimestamped(d sbom.Document, s *scvsScore) bool {
164165

165166
// 2.8 SBOM is analyzed for risk(L1, L2, L3)
166167
func IsSBOMAnalyzedForRisk(d sbom.Document, s *scvsScore) bool {
167-
// N/A
168-
s.setDesc("Not Supported(N/A)")
168+
// // N/A
169+
// s.setDesc("Not Supported(N/A)")
170+
// return false
171+
172+
// Run OpenSCA CLI to check for vulnerabilities
173+
cmd := exec.Command("opensca-cli", "scan", "--path", "~/sbom/sbomqs-fossa.spdx.json ")
174+
175+
var out bytes.Buffer
176+
cmd.Stdout = &out
177+
err := cmd.Run()
178+
if err != nil {
179+
s.setDesc("Error running OpenSCA CLI: " + err.Error())
180+
return false
181+
}
182+
183+
// Parse the output to check for vulnerabilities
184+
output := out.String()
185+
if strings.Contains(output, "Vulnerabilities found") {
186+
s.setDesc("Vulnerabilities found in SBOM components")
187+
return true
188+
}
189+
190+
s.setDesc("No vulnerabilities found")
169191
return false
170-
} // 2.8
192+
}
171193

172194
// 2.9 SBOM contains a complete and accurate inventory of all components the SBOM describes(L1, L2, L3)
173195
func IsSBOMHasInventoryOfDependencies(d sbom.Document, s *scvsScore) bool {

0 commit comments

Comments
 (0)