@@ -435,7 +435,7 @@ func (c *HealthChecker) tryCustomHealthCheck(ctx context.Context, config *Health
435435// performHTTPCheck performs a direct HTTP health check to a specific URL.
436436func (c * HealthChecker ) performHTTPCheck (ctx context.Context , urlStr string ) * httpHealthCheckResult {
437437 startTime := time .Now ()
438- req , err := http .NewRequestWithContext (ctx , "GET" , urlStr , nil )
438+ req , err := http .NewRequestWithContext (ctx , http . MethodGet , urlStr , nil )
439439 if err != nil {
440440 return & httpHealthCheckResult {
441441 Endpoint : urlStr ,
@@ -497,7 +497,7 @@ func (c *HealthChecker) performCommandCheck(ctx context.Context, args []string,
497497 ResponseTime : 0 ,
498498 }
499499
500- cmd := exec .CommandContext (ctx , args [0 ], args [1 :]... )
500+ cmd := exec .CommandContext (ctx , args [0 ], args [1 :]... ) // #nosec G204 -- Args from Docker HEALTHCHECK config, not user input
501501 err := cmd .Run ()
502502 result .ResponseTime = time .Since (startTime )
503503
@@ -521,9 +521,9 @@ func (c *HealthChecker) performShellCheck(ctx context.Context, command string, s
521521
522522 var cmd * exec.Cmd
523523 if runtime .GOOS == "windows" {
524- cmd = exec .CommandContext (ctx , "cmd" , "/C" , command )
524+ cmd = exec .CommandContext (ctx , "cmd" , "/C" , command ) // #nosec G204 -- Command from Docker HEALTHCHECK CMD-SHELL config
525525 } else {
526- cmd = exec .CommandContext (ctx , "sh" , "-c" , command )
526+ cmd = exec .CommandContext (ctx , "sh" , "-c" , command ) // #nosec G204 -- Command from Docker HEALTHCHECK CMD-SHELL config
527527 }
528528
529529 err := cmd .Run ()
@@ -607,7 +607,7 @@ func (c *HealthChecker) checkSingleEndpoint(ctx context.Context, port int, endpo
607607 url := fmt .Sprintf ("http://localhost:%d%s" , port , endpoint )
608608
609609 startTime := time .Now ()
610- req , err := http .NewRequestWithContext (ctx , "GET" , url , nil )
610+ req , err := http .NewRequestWithContext (ctx , http . MethodGet , url , nil )
611611 if err != nil {
612612 return nil
613613 }
0 commit comments