From bb678c03b385071f6a160bd8baed0dacf399165e Mon Sep 17 00:00:00 2001 From: Thomas Hendrickson <69640071+praetorian-thendrickson@users.noreply.github.com> Date: Mon, 20 Sep 2021 17:52:51 -0400 Subject: [PATCH] =?UTF-8?q?don't=20print=20status=20of=20cloning=20message?= =?UTF-8?q?=20when=20scanning=20remote=20repository=E2=80=A6=20(#50)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * don't print status of cloning message when scanning remote repository and outputting json or sarif * highlight relevant finding lines; fix failed test (#46) --- cmd/scan.go | 3 ++- util/module.go | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/scan.go b/cmd/scan.go index 26aadb1..8be7dbb 100644 --- a/cmd/scan.go +++ b/cmd/scan.go @@ -72,7 +72,8 @@ Scans a Go module directory. To scan the current directory recursively, use goka } defer util.CleanupModule(moduleTempDir) - err = util.CloneModule(moduleTempDir, remoteModule, remoteBranch, keyFile) + // Clone the module, if the output format is JSON or SARIF don't print any progress to stdout + err = util.CloneModule(moduleTempDir, remoteModule, remoteBranch, keyFile, json || sarif) if err != nil { util.CleanupModule(moduleTempDir) diff --git a/util/module.go b/util/module.go index acab658..a0121c4 100644 --- a/util/module.go +++ b/util/module.go @@ -25,13 +25,17 @@ import ( // CloneModule clones a remote git repository // An optional keyfile may be specified for use in ssh authentication -func CloneModule(dir string, url string, branch string, keyFile string) error { +// If quiet is true, don't print clone progress to stdout +func CloneModule(dir string, url string, branch string, keyFile string, quiet bool) error { var cloneOptions git.CloneOptions - log.Printf("Cloning new remote module: %s\n", url) cloneOptions = git.CloneOptions{ - URL: url, - Progress: os.Stdout, + URL: url, + } + + if !quiet { + log.Printf("Cloning new remote module: %s\n", url) + cloneOptions.Progress = os.Stdout } if len(branch) != 0 {