Skip to content

Commit

Permalink
refactor: remove ctx in struct
Browse files Browse the repository at this point in the history
  • Loading branch information
iseki0 committed Oct 21, 2024
1 parent 218459d commit 1637661
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 14 deletions.
1 change: 0 additions & 1 deletion cmd/murphy/internal/internalcmd/scanner_scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func scannerScanRun(cmd *cobra.Command, args []string) {
}

var scantask = &model.ScanTask{
Ctx: ctx,
ProjectPath: scanDir,
AccessType: model.AccessTypeCli,
Mode: model.ScanModeSource,
Expand Down
1 change: 0 additions & 1 deletion cmd/murphy/internal/scan/sbomscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ func SbomScan() *cobra.Command {
func processDir(ctx context.Context, dir string) ([]byte, error) {
var e error
var task = model.ScanTask{
Ctx: ctx,
ProjectPath: dir,
}
ctx = model.WithScanTask(ctx, &task)
Expand Down
2 changes: 0 additions & 2 deletions cmd/murphy/internal/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ func envScan(ctx context.Context) (task *model.ScanTask, e error) {
cv.DisplaySubtaskCreated(ctx, createTaskResp.ProjectsName, createTaskResp.SubtaskID)
// create task object
task = &model.ScanTask{
Ctx: ctx,
Mode: createSubtask.ScanMode,
AccessType: createSubtask.AccessType,
TaskId: createTaskResp.TaskID,
Expand Down Expand Up @@ -175,7 +174,6 @@ func scan(ctx context.Context, dir string, accessType model.AccessType, mode mod

// create task object
task := &model.ScanTask{
Ctx: ctx,
Mode: mode,
AccessType: accessType,
ProjectPath: dir,
Expand Down
9 changes: 1 addition & 8 deletions model/inspection_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package model
import (
"context"
"path/filepath"

"github.com/murphysecurity/murphysec/infra/logctx"
)

type InspectionTask struct {
Expand Down Expand Up @@ -49,13 +47,8 @@ func UseInspectionTask(ctx context.Context) *InspectionTask {
}

func (i *InspectionTask) AddModule(module Module) {
var logger = logctx.Use(i.ctx).Sugar()
logger.Infof("add module: %v", module)
if filepath.IsAbs(module.ModulePath) {
relPath, e := filepath.Rel(i.scanTask.ProjectPath, module.ModulePath)
if e != nil {
logger.Warnf("get module relative-path: %v", e)
}
relPath, _ := filepath.Rel(i.scanTask.ProjectPath, module.ModulePath)
module.ModulePath = relPath
}
if module.ModulePath == "." {
Expand Down
2 changes: 0 additions & 2 deletions model/scantask.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

// ScanTask 表示当前扫描任务
type ScanTask struct {
Ctx context.Context
ProjectPath string
AccessType AccessType
Mode ScanMode
Expand All @@ -24,7 +23,6 @@ type ScanTask struct {

func (s *ScanTask) BuildInspectionTask(dir string) *InspectionTask {
return &InspectionTask{
ctx: s.Ctx,
scanTask: s,
inspectionDir: dir,
}
Expand Down

0 comments on commit 1637661

Please sign in to comment.