Skip to content

Commit

Permalink
fix scan params decode order
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmahanth committed Oct 18, 2023
1 parent abde656 commit 04ab161
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion deepfence_worker/tasks/malwarescan/malwarescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s MalwareScan) StartMalwareScan(ctx context.Context, task *asynq.Task) err
}
log.Info().Msgf("message tenant id %s", string(tenantID))

log.Info().Msgf(" payload: %s ", string(task.Payload()))
log.Info().Msgf("payload: %s ", string(task.Payload()))

var params utils.MalwareScanParameters

Expand Down
22 changes: 11 additions & 11 deletions deepfence_worker/tasks/sbom/generate_sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func (s SbomGenerator) GenerateSbom(ctx context.Context, task *asynq.Task) error
{Key: "namespace", Value: []byte(tenantID)},
}

log.Info().Msgf("payload: %s ", string(task.Payload()))

if err := json.Unmarshal(task.Payload(), &params); err != nil {
return err
}

res, scanCtx := tasks.StartStatusReporter(params.ScanId,
func(status tasks.ScanStatus) error {
sb, err := json.Marshal(status)
Expand All @@ -105,17 +111,6 @@ func (s SbomGenerator) GenerateSbom(ctx context.Context, task *asynq.Task) error
time.Minute*20,
)

worker, err := directory.Worker(ctx)
if err != nil {
return err
}

log.Info().Msgf("payload: %s ", string(task.Payload()))

if err := json.Unmarshal(task.Payload(), &params); err != nil {
return err
}

log.Info().Msgf("Adding scan id to map:%s", params.ScanId)
scanMap.Store(params.ScanId, scanCtx)
defer func() {
Expand All @@ -130,6 +125,11 @@ func (s SbomGenerator) GenerateSbom(ctx context.Context, task *asynq.Task) error
return err
}

worker, err := directory.Worker(ctx)
if err != nil {
return err
}

// get registry credentials
authFile, creds, err := workerUtils.GetConfigFileFromRegistry(ctx, params.RegistryId)
if err != nil {
Expand Down
5 changes: 3 additions & 2 deletions deepfence_worker/tasks/sbom/scan_sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ func (s SbomParser) ScanSBOM(ctx context.Context, task *asynq.Task) error {
{Key: "namespace", Value: []byte(tenantID)},
}

log.Info().Msgf("payload: %s ", string(task.Payload()))

var params utils.SbomParameters

if err := json.Unmarshal(task.Payload(), &params); err != nil {
Expand Down Expand Up @@ -126,6 +128,7 @@ func (s SbomParser) ScanSBOM(ctx context.Context, task *asynq.Task) error {
},
time.Minute*20,
)

log.Info().Msgf("Adding scan id to map:%s", params.ScanId)
scanMap.Store(params.ScanId, scanCtx)
defer func() {
Expand All @@ -135,8 +138,6 @@ func (s SbomParser) ScanSBOM(ctx context.Context, task *asynq.Task) error {
close(res)
}()

log.Info().Msgf("payload: %s ", string(task.Payload()))

// send inprogress status

mc, err := directory.MinioClient(ctx)
Expand Down

0 comments on commit 04ab161

Please sign in to comment.