Skip to content

Commit a42806c

Browse files
committed
feat: add fields to json output
- license_info_list - project_distribution - system_info
1 parent 5a1d4bc commit a42806c

File tree

2 files changed

+71
-60
lines changed

2 files changed

+71
-60
lines changed

model/idea_output.go

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package model
22

33
import (
44
"encoding/json"
5+
"time"
6+
57
"github.com/murphysecurity/fix-tools/fix"
68
"github.com/murphysecurity/murphysec/utils"
79
"github.com/repeale/fp-go"
810
"github.com/samber/lo"
9-
"time"
1011
)
1112

1213
type PluginOutput struct {
@@ -22,21 +23,24 @@ type PluginOutput struct {
2223
Medium int `json:"medium,omitempty"`
2324
Low int `json:"low,omitempty"`
2425
} `json:"issues_level_count,omitempty"`
25-
TaskId string `json:"task_id"`
26-
SubtaskId string `json:"subtask_id"`
27-
InspectErrors []InspectError `json:"inspect_errors,omitempty"`
28-
DependenciesCount int `json:"dependencies_count"`
29-
SurpassScore int `json:"surpass_score"`
30-
ProjectScore int `json:"project_score"`
31-
LicenseInfoMap map[string]LicenseItem `json:"license_info_map"`
32-
Username string `json:"username"`
33-
ProjectId string `json:"project_id"`
34-
GitURL string `json:"git_url"`
35-
IsHitProjectRule bool `json:"is_hit_project_rule"`
36-
HitProjectRule json.RawMessage `json:"hit_project_rule,omitempty"`
37-
ShareURL string `json:"share_url,omitempty"`
38-
DetailURL string `json:"detail_url,omitempty"`
39-
ScanWarningCodes []string `json:"scan_warning_codes,omitempty"`
26+
TaskId string `json:"task_id"`
27+
SubtaskId string `json:"subtask_id"`
28+
InspectErrors []InspectError `json:"inspect_errors,omitempty"`
29+
DependenciesCount int `json:"dependencies_count"`
30+
SurpassScore int `json:"surpass_score"`
31+
ProjectScore int `json:"project_score"`
32+
LicenseInfoMap map[string]LicenseItem `json:"license_info_map"`
33+
Username string `json:"username"`
34+
ProjectId string `json:"project_id"`
35+
GitURL string `json:"git_url"`
36+
IsHitProjectRule bool `json:"is_hit_project_rule"`
37+
HitProjectRule json.RawMessage `json:"hit_project_rule,omitempty"`
38+
ShareURL string `json:"share_url,omitempty"`
39+
DetailURL string `json:"detail_url,omitempty"`
40+
ScanWarningCodes []string `json:"scan_warning_codes,omitempty"`
41+
LicenseInfoList json.RawMessage `json:"license_info_list,omitempty"`
42+
ProjectDistribution json.RawMessage `json:"project_distribution,omitempty"`
43+
SystemInfo json.RawMessage `json:"system_info,omitempty"`
4044
}
4145

4246
type ScanWarning struct {
@@ -100,21 +104,24 @@ func GetIDEAOutput(task *ScanTask) PluginOutput {
100104
Medium: r.MediumNum,
101105
Low: r.LowNum,
102106
},
103-
TaskId: r.TaskId,
104-
SubtaskId: r.SubtaskId,
105-
ProjectId: r.ProjectId,
106-
InspectErrors: nil,
107-
DependenciesCount: r.RelyNum,
108-
SurpassScore: r.SurpassScore,
109-
ProjectScore: r.ProjectScore,
110-
LicenseInfoMap: r.LicenseInfoMap,
111-
Username: r.Username,
112-
GitURL: task.GitUrl,
113-
IsHitProjectRule: r.IsHitProjectRule,
114-
HitProjectRule: r.HitProjectRule,
115-
ShareURL: r.ShareURL,
116-
DetailURL: r.DetailURL,
117-
ScanWarningCodes: lo.Uniq(fp.Map(func(it ScanWarning) string { return it.Kind })(r.ScanWarnings)),
107+
TaskId: r.TaskId,
108+
SubtaskId: r.SubtaskId,
109+
ProjectId: r.ProjectId,
110+
InspectErrors: nil,
111+
DependenciesCount: r.RelyNum,
112+
SurpassScore: r.SurpassScore,
113+
ProjectScore: r.ProjectScore,
114+
LicenseInfoMap: r.LicenseInfoMap,
115+
Username: r.Username,
116+
GitURL: task.GitUrl,
117+
IsHitProjectRule: r.IsHitProjectRule,
118+
HitProjectRule: r.HitProjectRule,
119+
ShareURL: r.ShareURL,
120+
DetailURL: r.DetailURL,
121+
ScanWarningCodes: lo.Uniq(fp.Map(func(it ScanWarning) string { return it.Kind })(r.ScanWarnings)),
122+
LicenseInfoList: r.LicenseInfoList,
123+
ProjectDistribution: r.ProjectDistribution,
124+
SystemInfo: r.SystemInfo,
118125
}
119126

120127
var vulnListMapper = func(effects []ScanResultCompEffect) (rs []PluginVulnDetailInfo) {

model/result.go

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,46 @@ package model
22

33
import (
44
"encoding/json"
5+
56
"github.com/murphysecurity/murphysec/infra/date"
67
)
78

89
// ScanResultResponse 服务端输出,字段名比较迷惑,需要注意。
910
//
1011
// 标注为 <unknown> 的暂时不知道是什么,估计用不上
1112
type ScanResultResponse struct {
12-
Complete bool `json:"complete"`
13-
Branch string `json:"branch"`
14-
SubtaskId string `json:"subtask_id"`
15-
ProjectId string `json:"project_id"`
16-
TeamId string `json:"team_id"`
17-
TaskId string `json:"task_id"`
18-
UserId string `json:"user_id"`
19-
OptionalNum int `json:"optional_num"` // 可选修复数量
20-
RecommendNum int `json:"recommend_num"` // 建议修复数量
21-
StringNum int `json:"string_num"` // 强烈建议修复数量
22-
RelyNum int `json:"rely_num"` // 本次扫描依赖组件总数
23-
LeakNum int `json:"leak_num"` // 本次任务包含缺陷组件数量
24-
HighNum int `json:"high_num"` // 高危漏洞数量
25-
MediumNum int `json:"medium_num"` // 中危漏洞数量
26-
LowNum int `json:"low_num"` // 低危漏洞数量
27-
CriticalNum int `json:"critical_num"` // 严重漏洞数量
28-
SurpassScore int `json:"surpass_score"`
29-
ProjectScore int `json:"project_score"`
30-
CompInfoList []ScanResultCompInfo `json:"comp_info_list"`
31-
VulnInfoMap map[string]VulnerabilityDetailInfo `json:"vuln_info_map"`
32-
LicenseInfoMap map[string]LicenseItem `json:"license_info_map"`
33-
Username string `json:"username"`
34-
IsHitProjectRule bool `json:"is_hit_project_rule"`
35-
HitProjectRule json.RawMessage `json:"hit_project_rule,omitempty"`
36-
ShareURL string `json:"share_url"`
37-
DetailURL string `json:"detail_url"`
38-
AllowAction int `json:"allow_action"`
39-
ExpireDay int `json:"expire_day"`
40-
ScanWarnings []ScanWarning `json:"scan_warnings"`
13+
Complete bool `json:"complete"`
14+
Branch string `json:"branch"`
15+
SubtaskId string `json:"subtask_id"`
16+
ProjectId string `json:"project_id"`
17+
TeamId string `json:"team_id"`
18+
TaskId string `json:"task_id"`
19+
UserId string `json:"user_id"`
20+
OptionalNum int `json:"optional_num"` // 可选修复数量
21+
RecommendNum int `json:"recommend_num"` // 建议修复数量
22+
StringNum int `json:"string_num"` // 强烈建议修复数量
23+
RelyNum int `json:"rely_num"` // 本次扫描依赖组件总数
24+
LeakNum int `json:"leak_num"` // 本次任务包含缺陷组件数量
25+
HighNum int `json:"high_num"` // 高危漏洞数量
26+
MediumNum int `json:"medium_num"` // 中危漏洞数量
27+
LowNum int `json:"low_num"` // 低危漏洞数量
28+
CriticalNum int `json:"critical_num"` // 严重漏洞数量
29+
SurpassScore int `json:"surpass_score"`
30+
ProjectScore int `json:"project_score"`
31+
CompInfoList []ScanResultCompInfo `json:"comp_info_list"`
32+
VulnInfoMap map[string]VulnerabilityDetailInfo `json:"vuln_info_map"`
33+
LicenseInfoMap map[string]LicenseItem `json:"license_info_map"`
34+
Username string `json:"username"`
35+
IsHitProjectRule bool `json:"is_hit_project_rule"`
36+
HitProjectRule json.RawMessage `json:"hit_project_rule,omitempty"`
37+
ShareURL string `json:"share_url"`
38+
DetailURL string `json:"detail_url"`
39+
AllowAction int `json:"allow_action"`
40+
ExpireDay int `json:"expire_day"`
41+
ScanWarnings []ScanWarning `json:"scan_warnings"`
42+
LicenseInfoList json.RawMessage `json:"license_info_list,omitempty"`
43+
ProjectDistribution json.RawMessage `json:"project_distribution,omitempty"`
44+
SystemInfo json.RawMessage `json:"system_info,omitempty"`
4145
}
4246

4347
type ScanResultCompInfo struct {

0 commit comments

Comments
 (0)