Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Rename scan request type #20288

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions api/v2.0/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1176,11 +1176,11 @@ paths:
- $ref: '#/parameters/projectName'
- $ref: '#/parameters/repositoryName'
- $ref: '#/parameters/reference'
- name: scan_request_type
- name: scanType
in: body
required: false
schema:
$ref: '#/definitions/ScanRequestType'
$ref: '#/definitions/ScanType'
responses:
'202':
$ref: '#/responses/202'
Expand Down Expand Up @@ -6766,13 +6766,6 @@ definitions:
type: string
description: Version of the scanner adapter
example: "v0.9.1"
ScanRequestType:
type: object
properties:
scan_type:
type: string
description: 'The scan type for the scan request. Two options are currently supported, vulnerability and sbom'
enum: [vulnerability, sbom]
ScanOverview:
type: object
description: 'The scan overview attached in the metadata of tag'
Expand Down
3 changes: 2 additions & 1 deletion src/controller/scan/base_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -742,10 +742,11 @@ func (bc *basicController) GetSBOMSummary(ctx context.Context, art *ar.Artifact,
return map[string]interface{}{}, nil
}
reportContent := reports[0].Report
result := map[string]interface{}{}
if len(reportContent) == 0 {
log.Warning("no content for current report")
return result, nil
}
result := map[string]interface{}{}
err = json.Unmarshal([]byte(reportContent), &result)
return result, err
}
Expand Down
4 changes: 2 additions & 2 deletions src/server/v2.0/handler/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func (s *scanAPI) ScanArtifact(ctx context.Context, params operation.ScanArtifac
if !distribution.IsDigest(params.Reference) {
options = append(options, scan.WithTag(params.Reference))
}
if params.ScanRequestType != nil && validScanType(params.ScanRequestType.ScanType) {
scanType = params.ScanRequestType.ScanType
if params.ScanType != nil && validScanType(params.ScanType.ScanType) {
scanType = params.ScanType.ScanType
options = append(options, scan.WithScanType(scanType))
}
res := rbac.ResourceScan
Expand Down
Loading