Skip to content

Commit

Permalink
Add registry account search API
Browse files Browse the repository at this point in the history
  • Loading branch information
noboruma committed Dec 6, 2023
1 parent 699fd42 commit f57c15f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions deepfence_server/apiDocs/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ func (d *OpenAPIDocs) AddSearchOperations() {
"Search Cloud Nodes", "Search across all the data associated with cloud nodes",
http.StatusOK, []string{tagSearch}, bearerToken, new(SearchNodeReq), new([]CloudNodeAccountInfo))

d.AddOperation("searchRegistryAccounts", http.MethodPost, "/deepfence/search/registry-accounts",
"Search Registry Accounts", "Search across all the data associated with registry account",
http.StatusOK, []string{tagSearch}, bearerToken, new(SearchNodeReq), new([]RegistryAccount))

d.AddOperation("getCloudComplianceFilters", http.MethodPost, "/deepfence/filters/cloud-compliance",
"Get Cloud Compliance Filters", "Get all applicable filter values for cloud compliance",
http.StatusOK, []string{tagSearch}, bearerToken, new(FiltersReq), new(FiltersResult))
Expand Down Expand Up @@ -359,6 +363,10 @@ func (d *OpenAPIDocs) AddSearchOperations() {
d.AddOperation("countCloudAccounts", http.MethodPost, "/deepfence/search/count/cloud-accounts",
"Count Cloud Nodes", "Search across all the data associated with cloud nodes",
http.StatusOK, []string{tagSearch}, bearerToken, new(SearchNodeReq), new(SearchCountResp))

d.AddOperation("countRegistryAccounts", http.MethodPost, "/deepfence/search/count/registry-accounts",
"Count Registry Accounts", "Search across all the data associated with registry account",
http.StatusOK, []string{tagSearch}, bearerToken, new(SearchNodeReq), new(SearchCountResp))
}

func (d *OpenAPIDocs) AddControlsOperations() {
Expand Down
8 changes: 8 additions & 0 deletions deepfence_server/handler/search_reports.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ func (h *Handler) SearchCloudNodes(w http.ResponseWriter, r *http.Request) {
SearchCloudNodeHandler[model.CloudNodeAccountInfo](w, r, h)
}

func (h *Handler) SearchRegistryAccounts(w http.ResponseWriter, r *http.Request) {
SearchHandler[model.RegistryAccount](w, r, h)
}

func (h *Handler) NodeCount(w http.ResponseWriter, r *http.Request) {
h.NodeCountHandler(w, r)
}
Expand Down Expand Up @@ -312,6 +316,10 @@ func (h *Handler) SearchCloudComplianceScansCount(w http.ResponseWriter, r *http
h.SearchScansCount(w, r, utils.NEO4JCloudComplianceScan)
}

func (h *Handler) SearchRegistryAccountsCount(w http.ResponseWriter, r *http.Request) {
SearchCountHandler[model.RegistryAccount](w, r, h)
}

func (h *Handler) SearchScans(w http.ResponseWriter, r *http.Request, scanType utils.Neo4jScanType) {
defer r.Body.Close()
var req reporters_search.SearchScanReq
Expand Down
2 changes: 2 additions & 0 deletions deepfence_server/model/lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ type RegistryAccount struct {
ID string `json:"node_id" required:"true"`
Name string `json:"host_name" required:"true"`
ContainerImages []ContainerImage `json:"container_images" required:"true"`
RegistryType string `json:"registry_type" required:"true"`
Syncing bool `json:"syncing" required:"true"`
}

func (RegistryAccount) NodeType() string {
Expand Down
2 changes: 2 additions & 0 deletions deepfence_server/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ func SetupRoutes(r *chi.Mux, serverPort string, serveOpenapiDocs bool, ingestC c
r.Post("/cloud-compliance/scans", dfHandler.SearchCloudComplianceScans)

r.Post("/cloud-accounts", dfHandler.SearchCloudNodes)
r.Post("/registry-accounts", dfHandler.SearchRegistryAccounts)

r.Route("/count", func(r chi.Router) {
r.Get("/nodes", dfHandler.NodeCount)
Expand All @@ -301,6 +302,7 @@ func SetupRoutes(r *chi.Mux, serverPort string, serveOpenapiDocs bool, ingestC c
r.Post("/kubernetes-clusters", dfHandler.SearchKubernetesClustersCount)
r.Post("/pods", dfHandler.SearchPodsCount)
r.Post("/cloud-accounts", dfHandler.SearchCloudAccountCount)
r.Post("/registry-accounts", dfHandler.SearchRegistryAccountsCount)

r.Post("/vulnerability/scans", dfHandler.SearchVulnerabilityScansCount)
r.Post("/secret/scans", dfHandler.SearchSecretScansCount)
Expand Down

0 comments on commit f57c15f

Please sign in to comment.