Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix wrong API status return #1523

Merged
merged 1 commit into from
Sep 7, 2023
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
4 changes: 2 additions & 2 deletions deepfence_server/apiDocs/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,10 +495,10 @@ func (d *OpenApiDocs) AddScansOperations() {
http.StatusAccepted, []string{tagCompliance}, bearerToken, new(ComplianceScanTriggerReq), nil)
d.AddOperation("stopMalwareScan", http.MethodPost, "/deepfence/scan/stop/malware",
"Stop Malware Scan", "Stop Malware Scan on agent or registry",
http.StatusOK, []string{tagMalwareScan}, bearerToken, new(StopScanRequest), nil)
http.StatusAccepted, []string{tagMalwareScan}, bearerToken, new(StopScanRequest), nil)
d.AddOperation("stopSecretScan", http.MethodPost, "/deepfence/scan/stop/secret",
"Stop Secret Scan", "Stop Secret Scan on agent or registry",
http.StatusOK, []string{tagSecretScan}, bearerToken, new(StopScanRequest), nil)
http.StatusAccepted, []string{tagSecretScan}, bearerToken, new(StopScanRequest), nil)

// Status scan
d.AddOperation("statusVulnerabilityScan", http.MethodPost, "/deepfence/scan/status/vulnerability",
Expand Down
12 changes: 6 additions & 6 deletions deepfence_server/handler/scan_reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (h *Handler) StartVulnerabilityScanHandler(w http.ResponseWriter, r *http.R

h.AuditUserActivity(r, EVENT_VULNERABILITY_SCAN, ACTION_START, reqs, true)

err = httpext.JSON(w, http.StatusOK, model.ScanTriggerResp{ScanIds: scan_ids, BulkScanId: bulkId})
err = httpext.JSON(w, http.StatusAccepted, model.ScanTriggerResp{ScanIds: scan_ids, BulkScanId: bulkId})
if err != nil {
log.Error().Msg(err.Error())
}
Expand Down Expand Up @@ -275,7 +275,7 @@ func (h *Handler) StartSecretScanHandler(w http.ResponseWriter, r *http.Request)

h.AuditUserActivity(r, EVENT_SECRET_SCAN, ACTION_START, reqs, true)

err = httpext.JSON(w, http.StatusOK, model.ScanTriggerResp{ScanIds: scan_ids, BulkScanId: bulkId})
err = httpext.JSON(w, http.StatusAccepted, model.ScanTriggerResp{ScanIds: scan_ids, BulkScanId: bulkId})
if err != nil {
log.Error().Msg(err.Error())
}
Expand Down Expand Up @@ -361,7 +361,7 @@ func (h *Handler) StartComplianceScanHandler(w http.ResponseWriter, r *http.Requ

h.AuditUserActivity(r, EVENT_COMPLIANCE_SCAN, ACTION_START, reqs, true)

err = httpext.JSON(w, http.StatusOK, model.ScanTriggerResp{ScanIds: scanIds, BulkScanId: bulkId})
err = httpext.JSON(w, http.StatusAccepted, model.ScanTriggerResp{ScanIds: scanIds, BulkScanId: bulkId})
if err != nil {
log.Error().Msg(err.Error())
}
Expand Down Expand Up @@ -391,7 +391,7 @@ func (h *Handler) StartMalwareScanHandler(w http.ResponseWriter, r *http.Request

h.AuditUserActivity(r, EVENT_MALWARE_SCAN, ACTION_START, reqs, true)

err = httpext.JSON(w, http.StatusOK, model.ScanTriggerResp{ScanIds: scan_ids, BulkScanId: bulkId})
err = httpext.JSON(w, http.StatusAccepted, model.ScanTriggerResp{ScanIds: scan_ids, BulkScanId: bulkId})
if err != nil {
log.Error().Msg(err.Error())
}
Expand Down Expand Up @@ -722,7 +722,7 @@ func (h *Handler) stopSecretScan(w http.ResponseWriter, r *http.Request) {

h.AuditUserActivity(r, req.ScanType, ACTION_STOP, req, true)

w.WriteHeader(http.StatusNoContent)
w.WriteHeader(http.StatusAccepted)
}

func (h *Handler) stopMalwareScan(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -754,7 +754,7 @@ func (h *Handler) stopMalwareScan(w http.ResponseWriter, r *http.Request) {

h.AuditUserActivity(r, req.ScanType, ACTION_STOP, req, true)

w.WriteHeader(http.StatusNoContent)
w.WriteHeader(http.StatusAccepted)
}

func (h *Handler) StatusVulnerabilityScanHandler(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions deepfence_server/model/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ type IngestedContainerImage struct {
DockerImageVirtualSize string `json:"docker_image_virtual_size" required:"true"`
DockerImageID string `json:"docker_image_id" required:"true"`
ShortImageID string `json:"short_image_id"`
Metadata Metadata `json:"metadata" required:"true" nested_json:"true"`
Metadata Metadata `json:"metadata" nested_json:"true"`
}

func (IngestedContainerImage) NodeType() string {
Expand Down Expand Up @@ -322,7 +322,7 @@ type ContainerImage struct {
DockerImageVirtualSize string `json:"docker_image_virtual_size" required:"true"`
DockerImageID string `json:"docker_image_id" required:"true"`
DockerImageTagList []string `json:"docker_image_tag_list" required:"true"`
Metadata Metadata `json:"metadata" required:"true" nested_json:"true"`
Metadata Metadata `json:"metadata" nested_json:"true"`
VulnerabilitiesCount int64 `json:"vulnerabilities_count" required:"true"`
VulnerabilityScanStatus string `json:"vulnerability_scan_status" required:"true"`
VulnerabilityLatestScanId string `json:"vulnerability_latest_scan_id" required:"true"`
Expand Down