Skip to content

Commit 0768ced

Browse files
committed
feat: SCA-57 add maven flag to dfscan
1 parent a3c18ff commit 0768ced

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

api/create_sub_task.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ type CreateSubTaskRequest struct {
3131
ExtraData *string `json:"extra_data,omitempty"`
3232
IsAutonomous bool `json:"is_autonomous"`
3333
Distribution string `json:"distribution"`
34+
BuildOptions struct {
35+
MavenVersion string `json:"maven_version,omitempty"`
36+
JdkVersion string `json:"jdk_version,omitempty"`
37+
} `json:"build_options"`
3438
}
3539

3640
type CreateSubTaskResponse struct {

api/start_check.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package api
22

3-
import "github.com/murphysecurity/murphysec/model"
3+
import (
4+
"github.com/murphysecurity/murphysec/model"
5+
"github.com/murphysecurity/murphysec/toolver"
6+
)
47

58
func StartCheck(client *Client, task *model.ScanTask) error {
69
checkNotNull(client)
@@ -12,5 +15,19 @@ func StartCheck(client *Client, task *model.ScanTask) error {
1215
if task.MavenSourceId != "" {
1316
data["package_private_id"] = task.MavenSourceId
1417
}
18+
var buildOptions = make(map[string]any)
19+
data["build_options"] = buildOptions
20+
if toolver.Default.Maven.MavenVersion != "" {
21+
buildOptions["maven_version"] = "jdk" + toolver.Default.Maven.MavenVersion
22+
}
23+
if toolver.Default.Maven.JdkVersion != "" {
24+
buildOptions["jdk_version"] = "maven" + toolver.Default.Maven.JdkVersion
25+
}
26+
if len(toolver.Default.Maven.AdditionalArgs) > 0 {
27+
buildOptions["arguments"] = toolver.Default.Maven.AdditionalArgs
28+
}
29+
if len(toolver.Default.Maven.AdditionalPrependArgs) > 0 {
30+
buildOptions["prepend_arguments"] = toolver.Default.Maven.AdditionalPrependArgs
31+
}
1532
return client.DoJson(client.PostJson(joinURL(client.baseUrl, "/platform3/v3/client/start_check"), data), nil)
1633
}

cmd/murphy/internal/scan/cmd.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func Cmd() *cobra.Command {
7474
c.Flags().StringVar(&extraData, "extra-data", "", "specify the extra data")
7575
c.Flags().BoolVar(&scanCodeHash, "scan-snippets", false, "Enable scanning of code snippets to detect SBOM and vulnerabilities. Disabled by default")
7676
c.Flags().BoolVar(&binaryOnly, "binary-only", false, "only scan binary files, skip source code scanning")
77+
c.Flags().StringArrayVar(&toolver.Default.Maven.AdditionalPrependArgs, "maven-prepend-arg", []string{}, "Prepend an argument to the Maven command. Can be specified multiple times.")
78+
c.Flags().StringArrayVar(&toolver.Default.Maven.AdditionalArgs, "maven-arg", []string{}, "Append an argument to the Maven command. Can be specified multiple times.")
79+
c.Flags().StringVar(&toolver.Default.Maven.JdkVersion, "maven-jdk", "", "specify JDK version for Maven build")
80+
c.Flags().StringVar(&toolver.Default.Maven.MavenVersion, "maven-version", "", "specify Maven version for Maven build")
7781
return &c
7882
}
7983

0 commit comments

Comments
 (0)