Skip to content

Commit 187b78d

Browse files
Merge pull request #47 from devtron-labs/pkg-version-fix
fix: version and fixed-in-version in image-scan-execution-result
2 parents a2f0784 + 4b557f2 commit 187b78d

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

pkg/security/ImageScanService.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ func (impl *ImageScanServiceImpl) ConvertEndStepOutputAndSaveVulnerabilities(ste
522522

523523
imageScanExecutionResults := make([]*repository.ImageScanExecutionResult, 0, len(vulnerabilities))
524524
for _, vul := range vulnerabilities {
525-
imageScanExecutionResult := createImageScanExecutionResultObject(executionHistoryId, vul.Name, vul.Package, tool.Id)
525+
imageScanExecutionResult := createImageScanExecutionResultObject(executionHistoryId, vul.Name, vul.Package, vul.PackageVersion, vul.FixedInVersion, tool.Id)
526526
imageScanExecutionResults = append(imageScanExecutionResults, imageScanExecutionResult)
527527
}
528528
tx, err := impl.CveStoreRepository.GetConnection().Begin()
@@ -740,7 +740,7 @@ func (impl *ImageScanServiceImpl) CreateScanExecutionRegistryForClairV4(vs []*cl
740740
cvesToUpdate = append(cvesToUpdate, cveStore)
741741
}
742742
}
743-
imageScanExecutionResult := createImageScanExecutionResultObject(executionHistory.Id, item.Name, item.Package.Name, toolId)
743+
imageScanExecutionResult := createImageScanExecutionResultObject(executionHistory.Id, item.Name, item.Package.Name, item.Package.Version, item.FixedInVersion, toolId)
744744
imageScanExecutionResultsToBeSaved = append(imageScanExecutionResultsToBeSaved, imageScanExecutionResult)
745745
}
746746
tx, err := impl.CveStoreRepository.GetConnection().Begin()
@@ -803,7 +803,7 @@ func (impl *ImageScanServiceImpl) CreateScanExecutionRegistryForClairV2(vs []*cl
803803
cvesToUpdate = append(cvesToUpdate, cveStore)
804804
}
805805
}
806-
imageScanExecutionResult := createImageScanExecutionResultObject(executionHistory.Id, item.Name, item.FeatureName, toolId)
806+
imageScanExecutionResult := createImageScanExecutionResultObject(executionHistory.Id, item.Name, item.FeatureName, item.FeatureVersion, item.FixedBy, toolId)
807807
imageScanExecutionResultsToBeSaved = append(imageScanExecutionResultsToBeSaved, imageScanExecutionResult)
808808
}
809809
tx, err := impl.CveStoreRepository.GetConnection().Begin()

pkg/security/helper.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ func createCveStoreObject(name, version, fixedInVersion, severity string, userId
1818
return cveStore
1919
}
2020

21-
func createImageScanExecutionResultObject(executionHistoryId int, vulName, packageName string, toolId int) *repository.ImageScanExecutionResult {
21+
func createImageScanExecutionResultObject(executionHistoryId int, vulName, packageName, version, fixedInVersion string, toolId int) *repository.ImageScanExecutionResult {
2222
return &repository.ImageScanExecutionResult{
2323
ImageScanExecutionHistoryId: executionHistoryId,
2424
CveStoreName: vulName,
2525
Package: packageName,
2626
ScanToolId: toolId,
27+
Version: version,
28+
FixedVersion: fixedInVersion,
2729
}
2830
}

pkg/sql/repository/ImageScanResultRepository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type ImageScanExecutionResult struct {
2828
ImageScanExecutionHistoryId int `sql:"image_scan_execution_history_id"` //TODO: remove this
2929
ScanToolId int `sql:"scan_tool_id"`
3030
Package string `sql:"package"`
31+
Version string `sql:"version"`
32+
FixedVersion string `sql:"fixed_version"`
3133
CveStore CveStore
3234
ImageScanExecutionHistory ImageScanExecutionHistory
3335
}

0 commit comments

Comments
 (0)