Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions agent/utils/clam/clam.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ func AddScanTask(taskItem *task.Task, clam model.Clam, timeNow string) {
}
strategy = fmt.Sprintf("--%s=%s", clam.InfectedStrategy, dir)
}
taskItem.Logf("clamdscan --fdpass %s %s", strategy, clam.Path)
args := []string{"--fdpass"}
if strategy != "" {
args = append(args, strategy)
}
args = append(args, clam.Path)
taskItem.Logf("clamdscan %s", strings.Join(args, " "))
mgr := cmd.NewCommandMgr(cmd.WithIgnoreExist1(), cmd.WithTimeout(time.Duration(clam.Timeout)*time.Second), cmd.WithTask(*taskItem))
if err := mgr.Run("clamdscan", "--fdpass", strategy, clam.Path); err != nil {
if err := mgr.Run("clamdscan", args...); err != nil {
return fmt.Errorf("clamdscan failed, %v", err)
}
return nil
Expand Down
17 changes: 16 additions & 1 deletion agent/utils/cmd/cmdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (c *CommandHelper) pipeContext() (context.Context, context.CancelFunc) {
func (c *CommandHelper) buildPipeCommands(ctx context.Context, commands []PipeCommand) []*exec.Cmd {
cmds := make([]*exec.Cmd, 0, len(commands))
for _, item := range commands {
cmdItem := exec.CommandContext(ctx, item.Name, item.Args...)
cmdItem := exec.CommandContext(ctx, item.Name, filterEmptyArgs(item.Args)...)
cmdItem.Env = append(os.Environ(), c.env...)
cmdItem.Env = append(cmdItem.Env, item.Env...)
cmdItem.Dir = c.workDir
Expand Down Expand Up @@ -305,6 +305,7 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) {
var newContext context.Context
var cancel context.CancelFunc
var outputFile *os.File
arg = filterEmptyArgs(arg)

if c.timeout != 0 {
if c.context == nil {
Expand Down Expand Up @@ -411,6 +412,20 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) {
}
}

func filterEmptyArgs(args []string) []string {
if len(args) == 0 {
return args
}
filtered := args[:0]
for _, arg := range args {
if arg == "" {
continue
}
filtered = append(filtered, arg)
}
return filtered
}

func contextDone(ctx context.Context) <-chan struct{} {
if ctx == nil {
return nil
Expand Down
8 changes: 6 additions & 2 deletions core/app/api/v2/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (b *BaseApi) Login(c *gin.Context) {
if user == nil || user.MfaStatus != constant.StatusEnable {
go saveLoginLogs(c, req.Name, wrapLoginErr(msgKey, err))
}
if msgKey == "ErrAuth" || msgKey == "ErrEntrance" {
if msgKey == "ErrAuth" || msgKey == "ErrEntrance" || msgKey == "ErrNoneNode" {
if msgKey == "ErrAuth" {
global.IPTracker.RecordFailure(ip)
global.IPTracker.SetNeedCaptcha(ip)
Expand Down Expand Up @@ -109,6 +109,10 @@ func (b *BaseApi) MFALogin(c *gin.Context) {

user, msgKey, err := xpack.AuthProvider.MFALogin(c, req, string(entrance))
go saveLoginLogs(c, loginLogUserName(user, req.SessionID), wrapLoginErr(msgKey, err))
if msgKey == "ErrNoneNode" {
helper.BadAuth(c, msgKey, err)
return
}
if msgKey == "ErrMFA" {
global.IPTracker.RecordFailure(ip)
failures := initauth.GetMFASessionStore().RecordFailure(req.SessionID)
Expand Down Expand Up @@ -164,7 +168,7 @@ func (b *BaseApi) PasskeyFinishLogin(c *gin.Context) {
entrance := loadEntranceFromRequest(c)
user, msgKey, err := xpack.AuthProvider.PasskeyFinishLogin(c, sessionID, entrance)
go saveLoginLogs(c, loginLogUserName(user, ""), wrapLoginErr(msgKey, err))
if msgKey == "ErrAuth" || msgKey == "ErrEntrance" {
if msgKey == "ErrAuth" || msgKey == "ErrEntrance" || msgKey == "ErrNoneNode" {
if msgKey == "ErrAuth" {
global.IPTracker.SetNeedCaptcha(common.GetRealClientIP(c))
}
Expand Down
11 changes: 9 additions & 2 deletions core/middleware/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,21 @@ func OperationLog() gin.HandlerFunc {

func loadOperationUser(c *gin.Context) string {
sessionUser, ok := c.Get(psessionUtils.GinContextSessionUserKey)
if ok {
psession, ok := sessionUser.(psessionUtils.SessionUser)
if ok {
return psession.Name
}
}
apiUsername, ok := c.Get("API_AUTH_USERNAME")
if !ok {
return ""
}
psession, ok := sessionUser.(psessionUtils.SessionUser)
username, ok := apiUsername.(string)
if !ok {
return ""
}
return psession.Name
return username
}

func fillOperationDetail(operationDic *operationJson, formatMap map[string]interface{}) {
Expand Down
17 changes: 16 additions & 1 deletion core/utils/cmd/cmdx.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (c *CommandHelper) pipeContext() (context.Context, context.CancelFunc) {
func (c *CommandHelper) buildPipeCommands(ctx context.Context, commands []PipeCommand) []*exec.Cmd {
cmds := make([]*exec.Cmd, 0, len(commands))
for _, item := range commands {
cmdItem := exec.CommandContext(ctx, item.Name, item.Args...)
cmdItem := exec.CommandContext(ctx, item.Name, filterEmptyArgs(item.Args)...)
cmdItem.Env = append(os.Environ(), c.env...)
cmdItem.Env = append(cmdItem.Env, item.Env...)
cmdItem.Dir = c.workDir
Expand Down Expand Up @@ -284,6 +284,7 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) {
var newContext context.Context
var cancel context.CancelFunc
var outputFile *os.File
arg = filterEmptyArgs(arg)

if c.timeout != 0 {
if c.context == nil {
Expand Down Expand Up @@ -378,6 +379,20 @@ func (c *CommandHelper) run(name string, arg ...string) (string, error) {
}
}

func filterEmptyArgs(args []string) []string {
if len(args) == 0 {
return args
}
filtered := args[:0]
for _, arg := range args {
if arg == "" {
continue
}
filtered = append(filtered, arg)
}
return filtered
}

func contextDone(ctx context.Context) <-chan struct{} {
if ctx == nil {
return nil
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/cronjob/cronjob/record/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
<el-table-column min-width="230px">
<template #default="{ row }">
<span v-if="row.id === currentRecord.id" class="select-sign"></span>
<Status class="mr-2 ml-1 float-left w-20" :status="row.status" />
<Status class="mr-2 mt-1 ml-1 float-left w-20" :status="row.status" />
<div class="mt-0.5">
<span>
{{ row.startTime }}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/toolbox/clam/record/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<el-table-column>
<template #default="{ row }">
<span v-if="row.id === currentRecord.id" class="select-sign"></span>
<Status class="mr-2 ml-1 float-left" :status="row.status" />
<Status class="mr-2 mt-1 ml-1 float-left" :status="row.status" />
<div class="mt-0.5 float-left">
<span>
{{ dateFormat(0, 0, row.startTime) }}
Expand Down
Loading