Skip to content

Commit 16516c7

Browse files
committed
gitleaks: reuse previously downloaded Gitleaks tarball by default
Closes: #81
1 parent c18cb1b commit 16516c7

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

py/plugins/gitleaks.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def init_parser(self, parser):
6565
"--gitleaks-config",
6666
help="local configuration file to be used for gitleaks")
6767

68+
parser.add_argument(
69+
"--gitleaks-refresh", action="store_true",
70+
help="force download of gitleaks binary executable (in a .tar.gz) from")
71+
6872
def handle_args(self, parser, args, props):
6973
if args.gitleaks_config is not None:
7074
self.enable()
@@ -86,11 +90,14 @@ def fetch_gitleaks_hook(results):
8690
gitleaks_tgz_name = url.split("/")[-1]
8791
gitleaks_tgz = os.path.join(cache_dir, gitleaks_tgz_name)
8892

89-
# fetch .tar.gz
90-
ec = results.exec_cmd(['curl', '-Lfsvo', gitleaks_tgz, url])
91-
if 0 != ec:
92-
results.error("failed to download gitleaks binary executable: %s" % url)
93-
return ec
93+
if not args.gitleaks_refresh and os.path.exists(gitleaks_tgz):
94+
results.print_with_ts("reusing previously downloaded gitleaks tarball: %s" % gitleaks_tgz)
95+
else:
96+
# fetch .tar.gz
97+
ec = results.exec_cmd(['curl', '-Lfsvo', gitleaks_tgz, url])
98+
if 0 != ec:
99+
results.error("failed to download gitleaks binary executable: %s" % url)
100+
return ec
94101

95102
# extract the binary executable
96103
ec = results.exec_cmd(['tar', '-C', results.tmpdir, '-xvzf', gitleaks_tgz, 'gitleaks'])

0 commit comments

Comments
 (0)