diff --git a/api/analysis.go b/api/analysis.go
index aa1529d8a..b003cd707 100644
--- a/api/analysis.go
+++ b/api/analysis.go
@@ -16,6 +16,7 @@ import (
"io"
"net/http"
"os"
+ "sort"
"strconv"
"strings"
)
@@ -1364,8 +1365,7 @@ func (h AnalysisHandler) Deps(ctx *gin.Context) {
// @description sort:
// @description - provider
// @description - name
-// @description - version
-// @description - sha
+// @description - labels
// @tags dependencies
// @produce json
// @success 200 {object} []api.TechDependency
@@ -1406,16 +1406,15 @@ func (h AnalysisHandler) DepReports(ctx *gin.Context) {
// Inner Query
q := h.DB(ctx)
q = q.Select(
- "Provider",
- "Name",
- "Version",
- "SHA",
- "Labels",
- "COUNT(distinct AnalysisID) Applications")
- q = q.Model(&model.TechDependency{})
- q = q.Where("AnalysisID IN (?)", h.analysisIDs(ctx, filter))
- q = q.Where("ID IN (?)", h.depIDs(ctx, filter))
- q = q.Group("Name,SHA")
+ "d.Provider",
+ "d.Name",
+ "json_group_array(distinct j.value) Labels",
+ "COUNT(distinct d.AnalysisID) Applications")
+ q = q.Table("TechDependency d")
+ q = q.Joins(",json_each(Labels) j")
+ q = q.Where("d.AnalysisID IN (?)", h.analysisIDs(ctx, filter))
+ q = q.Where("d.ID IN (?)", h.depIDs(ctx, filter))
+ q = q.Group("d.Provider, d.Name")
// Find
db := h.DB(ctx)
db = db.Select("*")
@@ -1448,12 +1447,16 @@ func (h AnalysisHandler) DepReports(ctx *gin.Context) {
r := DepReport{
Provider: m.Provider,
Name: m.Name,
- Version: m.Version,
- SHA: m.SHA,
Applications: m.Applications,
}
if m.Labels != nil {
- _ = json.Unmarshal(m.Labels, &r.Labels)
+ var aggregated []string
+ _ = json.Unmarshal(m.Labels, &aggregated)
+ for _, s := range aggregated {
+ if s != "" {
+ r.Labels = append(r.Labels, s)
+ }
+ }
}
resources = append(resources, r)
}
@@ -1964,6 +1967,7 @@ func (r *TechDependency) With(m *model.TechDependency) {
//
// Model builds a model.
func (r *TechDependency) Model() (m *model.TechDependency) {
+ sort.Strings(r.Labels)
m = &model.TechDependency{}
m.Name = r.Name
m.Version = r.Version
@@ -2083,8 +2087,6 @@ type FileReport struct {
type DepReport struct {
Provider string `json:"provider"`
Name string `json:"name"`
- Version string `json:"version"`
- SHA string `json:"sha"`
Labels []string `json:"labels"`
Applications int `json:"applications"`
}
@@ -2101,7 +2103,7 @@ type DepAppReport struct {
Provider string `json:"provider"`
Name string `json:"name"`
Version string `json:"version"`
- SHA string `json:"rule"`
+ SHA string `json:"sha"`
Indirect bool `json:"indirect"`
Labels []string `json:"labels"`
} `json:"dependency"`
diff --git a/docs/docs.go b/docs/docs.go
index 63e0ce976..2318e3e2f 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -1,4 +1,5 @@
-// Package docs Code generated by swaggo/swag. DO NOT EDIT
+// Package docs GENERATED BY SWAG; DO NOT EDIT
+// This file was generated by swaggo/swag
package docs
import "github.com/swaggo/swag"
@@ -139,7 +140,7 @@ const docTemplate = `{
},
"/analyses/dependencies": {
"get": {
- "description": "Each report collates dependencies by name and SHA.\nfilters:\n- provider\n- name\n- version\n- sha\n- indirect\n- labels\n- application.id\n- application.name\n- businessService.id\n- businessService.name\n- tag.id\nsort:\n- provider\n- name\n- version\n- sha",
+ "description": "Each report collates dependencies by name and SHA.\nfilters:\n- provider\n- name\n- version\n- sha\n- indirect\n- labels\n- application.id\n- application.name\n- businessService.id\n- businessService.name\n- tag.id\nsort:\n- provider\n- name\n- labels",
"produces": [
"application/json"
],
@@ -5849,7 +5850,7 @@ const docTemplate = `{
"provider": {
"type": "string"
},
- "rule": {
+ "sha": {
"type": "string"
},
"version": {
@@ -7429,8 +7430,6 @@ var SwaggerInfo = &swag.Spec{
Description: "",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
- LeftDelim: "{{",
- RightDelim: "}}",
}
func init() {
diff --git a/docs/index.html b/docs/index.html
index d63749231..bc2ec2a24 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -13,21 +13,27 @@
}
- Upload bucket content by ID and path.
Upload bucket content by ID and path (handles both [post] and [put] requests).
+
path Parameters
id required | |
wildcard required | |
/tasks/{id}/bucket/{wildcard}
Delete bucket content by ID and path.
Delete bucket content by ID and path.
+
path Parameters
id required | |
wildcard required | |
/tasks/{id}/bucket/{wildcard}
Update a task report.
Request Body schema: application/json
activity | |
completed | |
createTime | |
createUser | |
| Array of objects (api.TaskError) |
id | |
result | |
status | |
task | |
total | |
updateUser | |
Request samples
Content typeapplication/json
{"completed": 0,
"createTime": "string",
"createUser": "string",
"errors":
[{"description": "string",
"severity": "string"
}
], "id": 0,
"result": { },
"status": "string",
"task": 0,
"total": 0,
"updateUser": "string"
}
Response samples
Content typeapplication/json
{"completed": 0,
"createTime": "string",
"createUser": "string",
"errors":
[{"description": "string",
"severity": "string"
}
], "id": 0,
"result": { },
"status": "string",
"task": 0,
"total": 0,
"updateUser": "string"
}
Create a task report.
Request Body schema: application/json
activity | |
completed | |
createTime | |
createUser | |
| Array of objects (api.TaskError) |
id | |
result | |
status | |
task | |
total | |
updateUser | |
Request samples
Content typeapplication/json
{"completed": 0,
"createTime": "string",
"createUser": "string",
"errors":
[{"description": "string",
"severity": "string"
}
], "id": 0,
"result": { },
"status": "string",
"task": 0,
"total": 0,
"updateUser": "string"
}
Response samples
Content typeapplication/json
{"completed": 0,
"createTime": "string",
"createUser": "string",
"errors":
[{"description": "string",
"severity": "string"
}
], "id": 0,
"result": { },
"status": "string",
"task": 0,
"total": 0,
"updateUser": "string"
}
Submit a task.
Request Body schema: application/json
activity | |
addon required | |
| |
| |
canceled | |
createTime | |
createUser | |
data required | |
| Array of objects (api.TaskError) |
id | |
image | |
locator | |
name | |
pod | |
policy | |
priority | |
purged | |
retries | |
started | |
state | |
terminated | |
| |
updateUser | |
variant | |
Request samples
Content typeapplication/json
{"addon": "string",
"canceled": true,
"createTime": "string",
"createUser": "string",
"data": { },
"errors":
[{"description": "string",
"severity": "string"
}
], "id": 0,
"image": "string",
"locator": "string",
"name": "string",
"pod": "string",
"policy": "string",
"priority": 0,
"purged": true,
"retries": 0,
"started": "string",
"state": "string",
"terminated": "string",
"ttl":
{"created": 0,
"failed": 0,
"pending": 0,
"postponed": 0,
"running": 0,
"succeeded": 0
}, "updateUser": "string",
"variant": "string"
}
Response samples
Content typeapplication/json
[{"connected": true,
"createTime": "string",
"createUser": "string",
"id": 0,
"insecure": true,
"kind": "jira-cloud",
"lastUpdated": "string",
"message": "string",
"name": "string",
"updateUser": "string",
"url": "string"
}
]
Create a tracker.
Request Body schema: application/json
connected | |
createTime | |
createUser | |
id | |
required | |
insecure | |
kind required | string Enum: "jira-cloud" "jira-onprem" |
lastUpdated | |
message | |
name required | |
updateUser | |
url required | |
Request samples
Content typeapplication/json
{"connected": true,
"createTime": "string",
"createUser": "string",
"id": 0,
"insecure": true,
"kind": "jira-cloud",
"lastUpdated": "string",
"message": "string",
"name": "string",
"updateUser": "string",
"url": "string"
}
Response samples
Content typeapplication/json
{"connected": true,
"createTime": "string",
"createUser": "string",
"id": 0,
"insecure": true,
"kind": "jira-cloud",
"lastUpdated": "string",
"message": "string",
"name": "string",
"updateUser": "string",
"url": "string"
}
Response samples
Content typeapplication/json
{"connected": true,
"createTime": "string",
"createUser": "string",
"id": 0,
"insecure": true,
"kind": "jira-cloud",
"lastUpdated": "string",
"message": "string",
"name": "string",
"updateUser": "string",
"url": "string"
}
Update a tracker.
Request Body schema: application/json
connected | |
createTime | |
createUser | |
id | |
required | |
insecure | |
kind required | string Enum: "jira-cloud" "jira-onprem" |
lastUpdated | |
message | |
name required | |
updateUser | |
url required | |
Request samples
Content typeapplication/json
{"connected": true,
"createTime": "string",
"createUser": "string",
"id": 0,
"insecure": true,
"kind": "jira-cloud",
"lastUpdated": "string",
"message": "string",
"name": "string",
"updateUser": "string",
"url": "string"
}
List a tracker's projects.
List a tracker's projects.
+
Response samples
Content typeapplication/json
[{"id": "string",
"name": "string"
}
]
Get a tracker project by ID.
Get a tracker project by ID.
+
/trackers/{id}/projects/{id2}
Response samples
Content typeapplication/json
{"id": "string",
"name": "string"
}
List a tracker project's issue types.
List a tracker project's issue types.
+
/trackers/{id}/projects/{id2}/issuetypes
Response samples
Content typeapplication/json
[{"id": "string",
"name": "string"
}
]