Skip to content

Commit

Permalink
if go.mod exists, run go get ./... first, then only run gosec if go g…
Browse files Browse the repository at this point in the history
…et ./... succeeds
  • Loading branch information
ghbren committed Jun 11, 2020
1 parent 364eb56 commit a4b5052
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/salus/scanners/gosec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ def run
shell_return = Dir.chdir(@repository.path_to_repo) do
# sometimes the go.sum needs to be forced updated to be able to correctly build packages.
# forcing go get seems to do the trick
run_shell("go get ./...")
if File.size?('go.mod')
go_get_ret = run_shell("go get ./...")
if go_get_ret.status != 0
go_get_err = "Unable to start gosec because go get ./... failed. #{go_get_ret.stderr}"
report_error(go_get_err, status: go_get_ret.status)
report_stderr(go_get_err)
return report_failure
end
end
cmd = "gosec #{config_options}-fmt=json ./..."
run_shell(cmd)
end
Expand Down

0 comments on commit a4b5052

Please sign in to comment.