From 128cd22f7c7c8aaf001234999e509e84ef5d6577 Mon Sep 17 00:00:00 2001 From: Richard Gomez <32133502+rgmz@users.noreply.github.com> Date: Mon, 16 Sep 2024 07:17:26 -0400 Subject: [PATCH] fix(rule): comment out errant validation case (#1509) This should be re-enabled once a more suitable fix is implemented. --- config/config_test.go | 10 +++++----- config/rule.go | 8 +++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/config/config_test.go b/config/config_test.go index 21526f21..2f373cb5 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -91,11 +91,11 @@ func TestTranslate(t *testing.T) { cfg: Config{}, wantError: fmt.Errorf("rule |id| is missing or empty, regex: (?i)(discord[a-z0-9_ .\\-,]{0,25})(=|>|:=|\\|\\|:|<=|=>|:).{0,5}['\\\"]([a-h0-9]{64})['\\\"]"), }, - { - cfgName: "no_regex_or_path", - cfg: Config{}, - wantError: fmt.Errorf("discord-api-key: both |regex| and |path| are empty, this rule will have no effect"), - }, + //{ + // cfgName: "no_regex_or_path", + // cfg: Config{}, + // wantError: fmt.Errorf("discord-api-key: both |regex| and |path| are empty, this rule will have no effect"), + //}, { cfgName: "bad_entropy_group", cfg: Config{}, diff --git a/config/rule.go b/config/rule.go index 6e07ac93..fd3f7932 100644 --- a/config/rule.go +++ b/config/rule.go @@ -60,10 +60,12 @@ func (r Rule) Validate() error { return fmt.Errorf("rule |id| is missing or empty" + context) } + // TODO: uncomment this once it works with |extend|. + // See: https://github.com/gitleaks/gitleaks/issues/1507#issuecomment-2352559213 // Ensure the rule actually matches something. - if r.Regex == nil && r.Path == nil { - return fmt.Errorf("%s: both |regex| and |path| are empty, this rule will have no effect", r.RuleID) - } + //if r.Regex == nil && r.Path == nil { + // return fmt.Errorf("%s: both |regex| and |path| are empty, this rule will have no effect", r.RuleID) + //} // Ensure |secretGroup| works. if r.Regex != nil && r.SecretGroup > r.Regex.NumSubexp() {