Skip to content

Commit 45b2c97

Browse files
added changes for repo
1 parent 20ef665 commit 45b2c97

File tree

2 files changed

+36
-21
lines changed

2 files changed

+36
-21
lines changed

internal/sql/repository/ImageScanHistoryRepository.go

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,40 @@ import (
77
)
88

99
type ImageScanExecutionHistory struct {
10-
tableName struct{} `sql:"image_scan_execution_history" pg:",discard_unknown_columns"`
11-
Id int `sql:"id,pk"`
12-
Image string `sql:"image,notnull"` // Migrate to request Id in future
13-
ImageHash string `sql:"image_hash,notnull"` // Migrate to request metadata
14-
ExecutionTime time.Time `sql:"execution_time"`
15-
ExecutedBy int `sql:"executed_by,notnull"`
16-
RequestMetadataJson string `sql:"request_metadata_json"`
17-
ExecutionHistoryDirectoryPath string `sql:"execution_history_directory_path"` // Deprecated
18-
RequestId int `sql:"request_id"`
19-
RequestType RequestType `sql:"request_type"`
10+
tableName struct{} `sql:"image_scan_execution_history" pg:",discard_unknown_columns"`
11+
Id int `sql:"id,pk"`
12+
Image string `sql:"image,notnull"`
13+
ImageHash string `sql:"image_hash,notnull"` // TODO Migrate to request metadata
14+
ExecutionTime time.Time `sql:"execution_time"`
15+
ExecutedBy int `sql:"executed_by,notnull"`
16+
SourceMetadataJson string `sql:"source_metadata_json"` // to have relevant info to process a scan for a given source type and subtype
17+
ExecutionHistoryDirectoryPath string `sql:"execution_history_directory_path"` // Deprecated
18+
SourceType SourceType `sql:"source_type"`
19+
SourceSubType SourceSubType `sql:"source_sub_type"`
2020
}
2121

22-
type RequestType int
22+
// multiple history rows for one source event
23+
24+
type SourceType int
25+
26+
const (
27+
Image SourceType = 1
28+
Code SourceType = 2
29+
Sbom SourceType = 3 // can be used in future for direct sbom scanning
30+
)
31+
32+
type SourceSubType int
2333

2434
const (
25-
Image = 1
26-
CiWorkflow = 2
27-
CdWorkflow = 3
28-
ChartHistory = 4
35+
Ci SourceSubType = 1 // relevant for ci code(2,1) or ci built image(1,1)
36+
Manifest SourceSubType = 2 // relevant for devtron app deployment manifest/helm app manifest(2,2) or images retrieved from manifest(1,2))
2937
)
3038

39+
//Refer image_scan_deploy_info table for source_type relation
40+
// ci workflow will have scans for ci-code and ci artifact
41+
// cd workflow will have scans for deployment manifest, manifest images
42+
// helm chart will have scans for manifest images and manifest
43+
3144
type ImageScanHistoryRepository interface {
3245
Save(model *ImageScanExecutionHistory) error
3346
FindAll() ([]*ImageScanExecutionHistory, error)

internal/sql/repository/ResourceScanExecutionResultRepository.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@ type ResourceScanResult struct {
1111
ImageScanExecutionHistoryId int `sql:"image_scan_execution_history_id"`
1212
ScanDataJson string `sql:"scan_data_json"`
1313
Format ResourceScanFormat `sql:"format"`
14-
Type ResourceScanType `sql:"type"`
14+
Types []ResourceScanType `sql:"types"`
1515
ScanToolId int `sql:"scan_tool_id"`
1616
}
1717

1818
type ResourceScanFormat int
1919

2020
const (
21-
CycloneDx ResourceScanFormat = 1 //SBOM
22-
TrivyJson = 2
23-
Json = 3
21+
CycloneDxSbom ResourceScanFormat = 1 //SBOM
22+
TrivyJson = 2
23+
Json = 3
2424
)
2525

2626
type ResourceScanType int
2727

2828
const (
29-
LicenseVulnerabilities ResourceScanType = 1
30-
SecretsMisconfigurations = 2
29+
Vulnerabilities ResourceScanType = 1
30+
License = 2
31+
Config = 3
32+
Secrets = 4
3133
)
3234

3335
type ResourceScanResultRepository interface {

0 commit comments

Comments
 (0)