Skip to content

Commit

Permalink
Merge pull request #37 from Mystery00/master
Browse files Browse the repository at this point in the history
fix: force specific project name cause scan failed
  • Loading branch information
iseki-working authored Jun 13, 2022
2 parents e33f280 + 2055962 commit b8389a0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
9 changes: 3 additions & 6 deletions cmd/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var CliJsonOutput bool

var DeepScan bool
var ProjectId string
var SpecificProjectName string

func scanCmd() *cobra.Command {
c := &cobra.Command{
Expand All @@ -39,10 +38,8 @@ func scanCmd() *cobra.Command {
tt = model.TaskTypeJenkins
}
task := model.CreateScanTask(projectDir, model.TaskKindNormal, tt)
if SpecificProjectName != "" {
task.ProjectName = SpecificProjectName
// force set project dir, in order to create new project
task.ProjectDir = fmt.Sprintf(`/%s`, SpecificProjectName)
if env.SpecificProjectName != "" {
task.ProjectName = env.SpecificProjectName
}
task.EnableDeepScan = DeepScan
ctx = model.WithScanTask(ctx, task)
Expand All @@ -58,7 +55,7 @@ func scanCmd() *cobra.Command {
c.Flags().BoolVar(&DeepScan, "deep", false, "deep scan, will upload the source code")
}
c.Flags().StringVar(&ProjectId, "project-id", "", "team id")
c.Flags().StringVar(&SpecificProjectName, "project-name", "", "force specific project name")
c.Flags().StringVar(&env.SpecificProjectName, "project-name", "", "force specific project name")
c.Flags().BoolVar(&env.DisableGit, "skip-git", false, "force ignore git info")
c.Args = cobra.ExactArgs(1)
return c
Expand Down
1 change: 1 addition & 0 deletions env/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ func envi(name string, defaultValue int) int {
}
}

var SpecificProjectName = ""
var DisableGit = false
5 changes: 5 additions & 0 deletions inspector/task_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package inspector

import (
"context"
"fmt"
"github.com/google/uuid"
"github.com/murphysecurity/murphysec/api"
"github.com/murphysecurity/murphysec/conf"
Expand Down Expand Up @@ -39,6 +40,10 @@ func createTask(ctx context.Context) error {
}
req.GitInfo = v
}
if env.SpecificProjectName != "" {
// force set project dir, in order to create new project
req.TargetAbsPath = fmt.Sprintf(`/%s`, env.SpecificProjectName)
}
if res, e := api.CreateTask(req); e == nil {
c.TaskId = res.TaskInfo
c.TotalContributors = res.TotalContributors
Expand Down

0 comments on commit b8389a0

Please sign in to comment.