From 05799228729fd4aeb8c4fcaafb9b73df172c947e Mon Sep 17 00:00:00 2001 From: Leonid Bossis Date: Wed, 26 Jul 2023 22:04:32 -0400 Subject: [PATCH] Consumes csgrep changes to support a new option: limit-msg-len defaulting to 512 (OSH-67) Fixes: https://github.com/csutils/csdiff/issues/114 Related: https://issues.redhat.com/browse/OSH-67 --- make-srpm.sh | 2 +- py/plugins/gitleaks.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/make-srpm.sh b/make-srpm.sh index 238ef336..1ba3b398 100755 --- a/make-srpm.sh +++ b/make-srpm.sh @@ -124,7 +124,7 @@ Tool for plugging static analyzers into the build process, free of mock. %package -n csmock-common Summary: Core of csmock (a mock wrapper for Static Analysis tools) -Requires: csdiff > 3.0.2 +Requires: csdiff > 3.0.3 Requires: csgcca Requires: cswrap Requires: mock diff --git a/py/plugins/gitleaks.py b/py/plugins/gitleaks.py index 1a935aa7..03caf558 100644 --- a/py/plugins/gitleaks.py +++ b/py/plugins/gitleaks.py @@ -34,8 +34,7 @@ GITLEAKS_LOG = "/builddir/gitleaks-capture.log" -FILTER_CMD = "csgrep '%s' --mode=json --warning-rate-limit=%i > '%s'" - +FILTER_CMD = "csgrep '%s' --mode=json --warning-rate-limit=%i --limit-msg-len=%i > '%s'" class PluginProps: def __init__(self): @@ -72,6 +71,10 @@ def init_parser(self, parser): "--gitleaks-rate-limit", type=int, default=1024, help="drop warnings if their count exceeds the specified limit") + parser.add_argument( + "--gitleaks-limit-msg-len", type=int, default=512, + help="trim message if it exceeds max message length") + parser.add_argument( "--gitleaks-refresh", action="store_true", help="force download of gitleaks binary executable (in a .tar.gz) from") @@ -145,7 +148,7 @@ def fetch_gitleaks_hook(results, props): def filter_hook(results): src = results.dbgdir_raw + GITLEAKS_OUTPUT dst = "%s/gitleaks-capture.js" % results.dbgdir_uni - cmd = FILTER_CMD % (src, args.gitleaks_rate_limit, dst) + cmd = FILTER_CMD % (src, args.gitleaks_rate_limit, args.gitleaks_limit_msg_len, dst) return results.exec_cmd(cmd, shell=True) props.post_process_hooks += [filter_hook]