-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix bash module v2 #508
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
Fix bash module v2 #508
Conversation
@@ -58,7 +59,7 @@ func bashCommandFunc(command *cobra.Command, args []string) { | |||
stopper := make(chan os.Signal, 1) | |||
signal.Notify(stopper, os.Interrupt, syscall.SIGTERM) | |||
ctx, cancelFun := context.WithCancel(context.TODO()) | |||
|
|||
ctx = context.WithValue(ctx, config.CONTEXT_KEY_MODULE_NAME, module.ModuleNameBash) |
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.
It seems that the code here is not necessary?
} | ||
|
||
func (bp *BashParser) detect(ctx context.Context, b []byte) error { | ||
if ctx.Value(config.CONTEXT_KEY_MODULE_NAME) == "EBPFProbeBash" { |
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.
I think the design here is not elegant. The pkg directory should be a business-independent third-party package, and the config package should not be referenced.
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.
- In my implementation, it's necessary to determine whether to use the bash parser based on context information.
- When setting a key in the context, it cannot be a string or any other built-in type (see https://staticcheck.io/docs/checks#SA1029).
- Therefore, a custom type contextKey is required, which needs to be introduced in "ecapture/pkg/event_processor" and "ecapture/cli/cmd" as the type for context information keys.
- I didn't delve too deeply into where to define this type in the config package. Where would be the most appropriate place to put it?"
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.
Indeed, abstraction here is a bit troublesome. I'll think about it later too
Fix #490.
in this PR: