Skip to content

Commit 1fc8d90

Browse files
author
yubaichao
committed
Merge branch 'SCA-374' into v3
2 parents d0d82f6 + 1c270ab commit 1fc8d90

9 files changed

Lines changed: 100 additions & 5 deletions

File tree

api/create_sub_task.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type CreateSubTaskRequest struct {
2828
ProjectTagNames []string `json:"project_tag_names,omitempty"`
2929
WebhookAddr *string `json:"webhook_addr,omitempty"`
3030
WebhookMode *string `json:"webhook_mode,omitempty"`
31+
SkipSkillScan bool `json:"skip_skill_scan,omitempty"`
3132
ExtraData *string `json:"extra_data,omitempty"`
3233
IsAutonomous bool `json:"is_autonomous"`
3334
Distribution string `json:"distribution"`

api/start_check.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ func StartCheck(client *Client, task *model.ScanTask) error {
1111
var data = map[string]any{
1212
"subtask_id": task.SubtaskId,
1313
"package_private_name": task.MavenSourceName,
14+
"skip_skill_scan": task.SkipSkillScan,
1415
}
1516
if task.MavenSourceId != "" {
1617
data["package_private_id"] = task.MavenSourceId

cmd/murphy/internal/internalcmd/scanner_scan.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func scannerScanRun(cmd *cobra.Command, args []string) {
7979
ScanWarnings []scanerr.Param `json:"scan_warnings"`
8080
AutoBuildCount int `json:"auto_build_count"`
8181
AutoBuildFailedCount int `json:"auto_build_failed_count"`
82+
SkillsSummary *model.SkillSummary `json:"skills_summary,omitempty"`
83+
Skills []model.SkillItem `json:"skills"`
8284
}
8385
w := wrapper{
8486
Modules: utils.NoNilSlice(scantask.Modules),
@@ -88,6 +90,11 @@ func scannerScanRun(cmd *cobra.Command, args []string) {
8890
ScanWarnings: scanerr.GetAll(ctx),
8991
AutoBuildCount: scantask.AutoBuildCount,
9092
AutoBuildFailedCount: scantask.AutoBuildFailedCount,
93+
Skills: make([]model.SkillItem, 0),
94+
}
95+
if scantask.Result != nil {
96+
w.SkillsSummary = scantask.Result.SkillsSummary
97+
w.Skills = utils.NoNilSlice(scantask.Result.Skills)
9198
}
9299
for i := range scantask.Modules {
93100
for j := range scantask.Modules[i].Dependencies {

cmd/murphy/internal/scan/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ var sbomOutputConfig string
4343
var sbomOutputType common.SBOMFormatFlag
4444
var webhookAddr string
4545
var webhookMode common.WebhookModeFlag
46+
var skipSkills bool
4647
var extraData string
4748
var scanCodeHash bool
4849
var gradleProjectFilter gradle.ProjectFilter
@@ -78,6 +79,7 @@ func Cmd() *cobra.Command {
7879
c.Flags().StringVar(&extraData, "extra-data", "", "specify the extra data")
7980
c.Flags().BoolVar(&scanCodeHash, "scan-snippets", false, "Enable scanning of code snippets to detect SBOM and vulnerabilities. Disabled by default")
8081
c.Flags().BoolVar(&binaryOnly, "binary-only", false, "only scan binary files, skip source code scanning")
82+
c.Flags().BoolVar(&skipSkills, "skip-skills", false, "disable Skills security scanning for this run")
8183
c.Flags().StringArrayVar(&toolver.Default.Maven.AdditionalPrependArgs, "maven-prepend-arg", []string{}, "Prepend an argument to the Maven command. Can be specified multiple times.")
8284
c.Flags().StringArrayVar(&toolver.Default.Maven.AdditionalArgs, "maven-arg", []string{}, "Append an argument to the Maven command. Can be specified multiple times.")
8385
c.Flags().StringVar(&toolver.Default.Maven.JdkVersion, "maven-jdk", "", "specify JDK version for Maven build")

cmd/murphy/internal/scan/scan.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func envScan(ctx context.Context, windowsPatchScanTimeout time.Duration) (task *
4747
var hn, _ = os.Hostname()
4848
createSubtask.Dir = fmt.Sprintf("HostEnv/%s(%s)", hn, utils.GetOutBoundIP())
4949
createSubtask.ProjectTagNames = projectTagNames
50+
createSubtask.SkipSkillScan = skipSkills
5051
if createSubtask.ProjectTagNames == nil {
5152
createSubtask.ProjectTagNames = make([]string, 0)
5253
}
@@ -89,11 +90,12 @@ func envScan(ctx context.Context, windowsPatchScanTimeout time.Duration) (task *
8990
cv.DisplaySubtaskCreated(ctx, createTaskResp.ProjectsName, createTaskResp.SubtaskID)
9091
// create task object
9192
task = &model.ScanTask{
92-
Mode: createSubtask.ScanMode,
93-
AccessType: createSubtask.AccessType,
94-
TaskId: createTaskResp.TaskID,
95-
SubtaskId: createTaskResp.SubtaskID,
96-
SubtaskName: createSubtask.ProjectName,
93+
Mode: createSubtask.ScanMode,
94+
AccessType: createSubtask.AccessType,
95+
TaskId: createTaskResp.TaskID,
96+
SubtaskId: createTaskResp.SubtaskID,
97+
SkipSkillScan: createSubtask.SkipSkillScan,
98+
SubtaskName: createSubtask.ProjectName,
9799

98100
MaxSbomVersion: createTaskResp.MaxSbomVersion,
99101
}
@@ -175,6 +177,7 @@ func scan(ctx context.Context, dir string, accessType model.AccessType, mode mod
175177
createSubtask.PackagePrivateName = privateSourceName
176178
createSubtask.ProjectTagNames = projectTagNames
177179
createSubtask.IsAutonomous = scanCodeHash
180+
createSubtask.SkipSkillScan = skipSkills
178181
createSubtask.Distribution = distribution.String()
179182

180183
if createSubtask.ProjectTagNames == nil {
@@ -238,6 +241,7 @@ func scan(ctx context.Context, dir string, accessType model.AccessType, mode mod
238241
ProjectPath: dir,
239242
TaskId: createTaskResp.TaskID,
240243
SubtaskId: createTaskResp.SubtaskID,
244+
SkipSkillScan: createSubtask.SkipSkillScan,
241245
SubtaskName: createSubtask.ProjectName,
242246
MavenSourceId: privateSourceId,
243247
MavenSourceName: privateSourceName,

model/idea_output.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type PluginOutput struct {
4141
LicenseInfoList json.RawMessage `json:"license_info_list,omitempty"`
4242
ProjectDistribution json.RawMessage `json:"project_distribution,omitempty"`
4343
SystemInfo json.RawMessage `json:"system_info,omitempty"`
44+
SkillsSummary *SkillSummary `json:"skills_summary,omitempty"`
45+
Skills []SkillItem `json:"skills,omitempty"`
4446
}
4547

4648
type ScanWarning struct {
@@ -122,6 +124,8 @@ func GetIDEAOutput(task *ScanTask) PluginOutput {
122124
LicenseInfoList: r.LicenseInfoList,
123125
ProjectDistribution: r.ProjectDistribution,
124126
SystemInfo: r.SystemInfo,
127+
SkillsSummary: r.SkillsSummary,
128+
Skills: utils.NoNilSlice(r.Skills),
125129
}
126130

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

model/result.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ type ScanResultResponse struct {
4242
LicenseInfoList json.RawMessage `json:"license_info_list,omitempty"`
4343
ProjectDistribution json.RawMessage `json:"project_distribution,omitempty"`
4444
SystemInfo json.RawMessage `json:"system_info,omitempty"`
45+
SkillsSummary *SkillSummary `json:"skills_summary,omitempty"`
46+
Skills []SkillItem `json:"skills,omitempty"`
4547
}
4648

4749
type ScanResultCompInfo struct {

model/scantask.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type ScanTask struct {
1111
Mode ScanMode
1212
TaskId string
1313
SubtaskId string
14+
SkipSkillScan bool
1415
Modules []Module
1516
CodeFragments []ComponentCodeFragment
1617
Result *ScanResultResponse

model/skill_result.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package model
2+
3+
// SkillSummary 表示 Skills 检测摘要。
4+
type SkillSummary struct {
5+
Enabled bool `json:"enabled"`
6+
Total int `json:"total"`
7+
RiskCount int `json:"risk_count"`
8+
MaliciousCount int `json:"malicious_count"`
9+
SuspiciousCount int `json:"suspicious_count"`
10+
SafeCount int `json:"safe_count"`
11+
PendingCount int `json:"pending_count"`
12+
DetectionErrorCount int `json:"detection_error_count"`
13+
FailedCount int `json:"failed_count"`
14+
DetectorAvailable bool `json:"detector_available"`
15+
LLMAvailable bool `json:"llm_available"`
16+
}
17+
18+
// SkillItem 表示单个 Skill 的检测结果。
19+
type SkillItem struct {
20+
ID string `json:"id"`
21+
Name string `json:"name"`
22+
Description string `json:"description"`
23+
DirPath string `json:"dir_path"`
24+
DirName string `json:"dir_name"`
25+
Status string `json:"status"`
26+
Summary string `json:"summary"`
27+
DetectMethods []string `json:"detect_methods"`
28+
HasCodeFiles bool `json:"has_code_files"`
29+
Source SkillSourceInfo `json:"source"`
30+
Intelligence SkillIntelligenceInfo `json:"intelligence"`
31+
Analysis SkillAnalysisInfo `json:"analysis"`
32+
ErrorMessage string `json:"error_message"`
33+
}
34+
35+
// SkillSourceInfo 表示来源信息。
36+
type SkillSourceInfo struct {
37+
SourceMatched bool `json:"source_matched"`
38+
Platform string `json:"platform"`
39+
PlatformURL string `json:"platform_url"`
40+
Author string `json:"author"`
41+
Version string `json:"version"`
42+
Stars int64 `json:"stars"`
43+
OriginalName string `json:"original_name"`
44+
}
45+
46+
// SkillIntelligenceInfo 表示情报匹配结果。
47+
type SkillIntelligenceInfo struct {
48+
IsMalicious bool `json:"is_malicious"`
49+
MpsID string `json:"mps_id"`
50+
Summary string `json:"summary"`
51+
CollectedAt string `json:"collected_at"`
52+
}
53+
54+
// SkillAnalysisInfo 表示 LLM 分析结果。
55+
type SkillAnalysisInfo struct {
56+
Analyzed bool `json:"analyzed"`
57+
ModelProvider string `json:"model_provider"`
58+
ModelName string `json:"model_name"`
59+
Summary string `json:"summary"`
60+
Dimensions []SkillAnalysisDimension `json:"dimensions"`
61+
}
62+
63+
// SkillAnalysisDimension 表示单个分析维度结果。
64+
type SkillAnalysisDimension struct {
65+
Name string `json:"name"`
66+
DisplayName string `json:"display_name"`
67+
Status string `json:"status"`
68+
Detail string `json:"detail"`
69+
Evidence string `json:"evidence"`
70+
Location string `json:"location"`
71+
UserExplanation string `json:"user_explanation"`
72+
CommonRiskPatterns string `json:"common_risk_patterns"`
73+
}

0 commit comments

Comments
 (0)