-
Notifications
You must be signed in to change notification settings - Fork 33
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
sleep cmd #3339
sleep cmd #3339
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -53,6 +53,17 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// runCommand runs the rfq relayer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var sleepCommand = &cli.Command{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Name: "sleep", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Description: "run the relayer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Flags: []cli.Flag{configFlag, &commandline.LogLevel}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Action: func(c *cli.Context) (err error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
time.Sleep(time.Hour) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
return nil | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+56
to
+65
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. 🛠️ Refactor suggestion Maintain consistency with existing command patterns The sleepCommand deviates from patterns established by other commands in this file. Consider aligning with existing implementations by:
Example metrics integration: Action: func(c *cli.Context) (err error) {
+ metricsProvider := metrics.Get()
+ metricsProvider.IncCounter("rfq_relayer_sleep_command_started", nil)
+ defer func() {
+ if err != nil {
+ metricsProvider.IncCounter("rfq_relayer_sleep_command_error", nil)
+ }
+ }()
Multiple issues with sleepCommand implementation
Consider this improved implementation: var sleepCommand = &cli.Command{
Name: "sleep",
- Description: "run the relayer",
+ Description: "pause execution for one hour",
- Flags: []cli.Flag{configFlag, &commandline.LogLevel},
Action: func(c *cli.Context) (err error) {
- time.Sleep(time.Hour)
+ logger := commandline.GetLogger()
+ logger.Info("starting sleep command")
+
+ select {
+ case <-c.Context.Done():
+ logger.Info("sleep interrupted")
+ return c.Context.Err()
+ case <-time.After(time.Hour):
+ logger.Info("sleep completed")
+ return nil
+ }
return nil
},
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
var relayerURLFlag = &cli.StringFlag{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Name: "relayer-url", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Usage: "relayer url", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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.
Security Concern: Sleep command could enable DoS attacks
Adding a command that pauses execution for an hour raises significant security concerns:
Consider:
Would you like me to propose a more secure implementation?
💡 Codebase verification
Documentation and purpose concerns confirmed
The implementation shows that this command simply makes the process sleep for one hour without any clear purpose. The command's description is misleading as it states "run the relayer" but actually just sleeps. There is:
Please:
🔗 Analysis chain
Missing documentation and context
The PR lacks description of why this command is needed. Please provide:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 40
Script:
Length of output: 1035