-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor to use new scope.Error method #2208
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,13 +46,13 @@ func (self *EnvFunction) Call(ctx context.Context, | |
|
||
err := vql_subsystem.CheckAccess(scope, acls.MACHINE_STATE) | ||
if err != nil { | ||
scope.Log("environ: %s", err) | ||
scope.Error("environ: %s", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May not be a critical error - if running with lower privileges we do want to just ignore |
||
return false | ||
} | ||
|
||
err = arg_parser.ExtractArgsWithContext(ctx, scope, args, arg) | ||
if err != nil { | ||
scope.Log("environ: %s", err.Error()) | ||
scope.Error("environ: %s", err.Error()) | ||
return false | ||
} | ||
|
||
|
@@ -80,14 +80,14 @@ func init() { | |
|
||
err := vql_subsystem.CheckAccess(scope, acls.MACHINE_STATE) | ||
if err != nil { | ||
scope.Log("environ: %s", err) | ||
scope.Error("environ: %s", err) | ||
return result | ||
} | ||
|
||
arg := &EnvPluginArgs{} | ||
err = arg_parser.ExtractArgsWithContext(ctx, scope, args, arg) | ||
if err != nil { | ||
scope.Log("%s: %s", "environ", err.Error()) | ||
scope.Error("%s: %s", "environ", err.Error()) | ||
return result | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ func (self MailPlugin) Call( | |
|
||
err := vql_subsystem.CheckAccess(scope, acls.SERVER_ADMIN) | ||
if err != nil { | ||
scope.Log("mail: %s", err) | ||
scope.Error("mail: %s", err) | ||
return | ||
} | ||
|
||
|
@@ -77,7 +77,7 @@ func (self MailPlugin) Call( | |
arg := &MailPluginArgs{} | ||
err = arg_parser.ExtractArgsWithContext(ctx, scope, args, arg) | ||
if err != nil { | ||
scope.Log("mail: %v", err) | ||
scope.Error("mail: %v", err) | ||
return | ||
} | ||
if time.Since(last_mail) < time.Duration(arg.Period)*time.Second { | ||
|
@@ -149,7 +149,7 @@ func (self MailPlugin) Call( | |
// Send the email to Bob, Cora and Dan. | ||
err = d.DialAndSend(m) | ||
if err != nil { | ||
scope.Log("mail: %v", err) | ||
scope.Error("mail: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may not be critical - can be an intermittant failure |
||
// Failed to send the mail but we should emit | ||
// the row anyway so it gets logged in the | ||
// artifact CSV file. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ func (self ShellPlugin) Call( | |
|
||
err := vql_subsystem.CheckAccess(scope, acls.EXECVE) | ||
if err != nil { | ||
scope.Log("shell: %v", err) | ||
scope.Error("shell: %v", err) | ||
return | ||
} | ||
|
||
|
@@ -76,7 +76,7 @@ func (self ShellPlugin) Call( | |
arg := &ShellPluginArgs{} | ||
err = arg_parser.ExtractArgsWithContext(ctx, scope, args, arg) | ||
if err != nil { | ||
scope.Log("shell: %v", err) | ||
scope.Error("shell: %v", err) | ||
return | ||
} | ||
|
||
|
@@ -121,19 +121,19 @@ func (self ShellPlugin) Call( | |
|
||
stdout_pipe, err := command.StdoutPipe() | ||
if err != nil { | ||
scope.Log("shell: no command to run") | ||
scope.Error("shell: no command to run") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably the wrong message :-) IDK - is this critical or not? it might be or it might be intermittent (e.g. tool failed to download etc) |
||
return | ||
} | ||
|
||
stderr_pipe, err := command.StderrPipe() | ||
if err != nil { | ||
scope.Log("shell: no command to run") | ||
scope.Error("shell: no command to run") | ||
return | ||
} | ||
|
||
err = command.Start() | ||
if err != nil { | ||
scope.Log("shell: %v", err) | ||
scope.Error("shell: %v", err) | ||
select { | ||
case <-ctx.Done(): | ||
return | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
//go:build cgo && yara | ||
// +build cgo,yara | ||
|
||
/* | ||
|
@@ -85,7 +86,7 @@ func (self YaraScanPlugin) Call( | |
arg := &YaraScanPluginArgs{} | ||
err := arg_parser.ExtractArgsWithContext(ctx, scope, args, arg) | ||
if err != nil { | ||
scope.Log("yarascan: %v", err) | ||
scope.Error("yarascan: %v", err) | ||
return | ||
} | ||
|
||
|
@@ -99,7 +100,7 @@ func (self YaraScanPlugin) Call( | |
|
||
err = vql_subsystem.CheckFilesystemAccess(scope, arg.Accessor) | ||
if err != nil { | ||
scope.Log("yara: %s", err.Error()) | ||
scope.Error("yara: %s", err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably not critical error |
||
return | ||
} | ||
|
||
|
@@ -127,15 +128,15 @@ func (self YaraScanPlugin) Call( | |
|
||
accessor, err := accessors.GetAccessor(arg.Accessor, scope) | ||
if err != nil { | ||
scope.Log("yara: %v", err) | ||
scope.Error("yara: %v", err) | ||
return | ||
} | ||
|
||
for _, filename_any := range arg.Files { | ||
filename, err := accessors.ParseOSPath( | ||
ctx, scope, accessor, filename_any) | ||
if err != nil { | ||
scope.Log("yara: %v", err) | ||
scope.Error("yara: %v", err) | ||
return | ||
} | ||
matcher.filename = filename | ||
|
@@ -212,14 +213,14 @@ func (self *scanReporter) scanFileByAccessor( | |
|
||
accessor, err := accessors.GetAccessor(accessor_name, self.scope) | ||
if err != nil { | ||
self.scope.Log("yara: %v", err) | ||
self.scope.Error("yara: %v", err) | ||
return | ||
} | ||
|
||
// Open the file with the accessor | ||
f, err := accessor.OpenWithOSPath(self.filename) | ||
if err != nil { | ||
self.scope.Log("yara: Failed to open %v with accessor %v: %v", | ||
self.scope.Error("yara: Failed to open %v with accessor %v: %v", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is definitely not a critical error - we fail to open files all the time |
||
self.filename, accessor_name, err) | ||
return | ||
} | ||
|
@@ -494,7 +495,7 @@ func (self YaraProcPlugin) Call( | |
arg := &YaraProcPluginArgs{} | ||
err := arg_parser.ExtractArgsWithContext(ctx, scope, args, arg) | ||
if err != nil { | ||
scope.Log("proc_yara: %v", err) | ||
scope.Error("proc_yara: %v", err) | ||
return | ||
} | ||
|
||
|
@@ -509,7 +510,7 @@ func (self YaraProcPlugin) Call( | |
generated_rules := RuleGenerator(scope, arg.Rules) | ||
rules, err = yara.Compile(generated_rules, variables) | ||
if err != nil { | ||
scope.Log("Failed to initialize YARA compiler: %v", err) | ||
scope.Error("Failed to initialize YARA compiler: %v", err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one is definitely critical error |
||
return | ||
} | ||
|
||
|
@@ -520,7 +521,7 @@ func (self YaraProcPlugin) Call( | |
arg.Pid, yara.ScanFlagsProcessMemory, | ||
300*time.Second) | ||
if err != nil { | ||
scope.Log("proc_yara: pid %v: %v", arg.Pid, err) | ||
scope.Error("proc_yara: pid %v: %v", arg.Pid, err) | ||
return | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are probably fine for Error - it means the args are not valid somehow and may be a syntax error (BTW these are automatically marked as error anyway here
velociraptor/flows/logs.go
Line 80 in 2d77179