Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go exec command security linting messages using golangci

Tags:

go

I'm adding a linter for gosec for golangci-lint and everything is covered except the following:

exec.Command(params[0], params[1:]…)

I know that I can disable this lint but I don't want to do it. Is there a way to fix the code to satisfy this lint?

the error is:

 G204: Subprocess launched with function call as argument or cmd arguments ```
like image 440
Beno Odr Avatar asked Nov 14 '19 15:11

Beno Odr


2 Answers

Instead of disabling the linter you could exclude the specific line with an annotation;

exec.Command(params[0], params[1:]...) //nolint:gosec
like image 106
Ferdy Avatar answered Sep 28 '22 01:09

Ferdy


If you want to disable only this check, you can

exec.Command(params[0], params[1:]...) // #nosec G204

like image 38
OmarOthman Avatar answered Sep 28 '22 00:09

OmarOthman