forked from gitleaks/gitleaks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/add sidekiq rules (gitleaks#933)
* Add sidekiq rules * Added two new rules for sidekiq * Other: Add keywords to square rules per Zach's instructions * Validate now works, but test suite is failing * Tests are now passing * Add Sidekiq Rules: Ran go fmt * * After resolving conflicts, had to rerun the rule generator to add back the semicolon char * After running tests, had to fix one line in testdata/expected/report/sarif_simple.sarif * * Added keywords to simple.toml for sidekiq-sensitive-url so that the rule matches what is in gitleaks.toml Co-authored-by: Andrew Weiner <aweiner@frontrush.com>
- Loading branch information
Showing
8 changed files
with
284 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package rules | ||
|
||
import ( | ||
"regexp" | ||
|
||
"github.com/zricethezav/gitleaks/v8/config" | ||
) | ||
|
||
func SidekiqSecret() *config.Rule { | ||
// define rule | ||
r := config.Rule{ | ||
Description: "Sidekiq Secret", | ||
RuleID: "sidekiq-secret", | ||
SecretGroup: 1, | ||
Regex: generateSemiGenericRegex([]string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"}, | ||
`[a-f0-9]{8}:[a-f0-9]{8}`), | ||
Keywords: []string{"BUNDLE_ENTERPRISE__CONTRIBSYS__COM", "BUNDLE_GEMS__CONTRIBSYS__COM"}, | ||
} | ||
|
||
// validate | ||
tps := []string{ | ||
"BUNDLE_ENTERPRISE__CONTRIBSYS__COM: cafebabe:deadbeef", | ||
"export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef", | ||
"export BUNDLE_ENTERPRISE__CONTRIBSYS__COM = cafebabe:deadbeef", | ||
"BUNDLE_GEMS__CONTRIBSYS__COM: \"cafebabe:deadbeef\"", | ||
"export BUNDLE_GEMS__CONTRIBSYS__COM=\"cafebabe:deadbeef\"", | ||
"export BUNDLE_GEMS__CONTRIBSYS__COM = \"cafebabe:deadbeef\"", | ||
"export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef;", | ||
"export BUNDLE_ENTERPRISE__CONTRIBSYS__COM=cafebabe:deadbeef && echo 'hello world'", | ||
} | ||
return validate(r, tps, nil) | ||
} | ||
|
||
func SidekiqSensitiveUrl() *config.Rule { | ||
// define rule | ||
r := config.Rule{ | ||
Description: "Sidekiq Sensitive URL", | ||
RuleID: "sidekiq-sensitive-url", | ||
SecretGroup: 2, | ||
Regex: regexp.MustCompile(`(?i)\b(http(?:s??):\/\/)([a-f0-9]{8}:[a-f0-9]{8})@(?:gems.contribsys.com|enterprise.contribsys.com)(?:[\/|\#|\?|:]|$)`), | ||
Keywords: []string{"gems.contribsys.com", "enterprise.contribsys.com"}, | ||
} | ||
|
||
// validate | ||
tps := []string{ | ||
"https://cafebabe:deadbeef@gems.contribsys.com/", | ||
"https://cafebabe:deadbeef@gems.contribsys.com", | ||
"https://cafeb4b3:d3adb33f@enterprise.contribsys.com/", | ||
"https://cafeb4b3:d3adb33f@enterprise.contribsys.com", | ||
"http://cafebabe:deadbeef@gems.contribsys.com/", | ||
"http://cafebabe:deadbeef@gems.contribsys.com", | ||
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com/", | ||
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com", | ||
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com#heading1", | ||
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com?param1=true¶m2=false", | ||
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80", | ||
"http://cafeb4b3:d3adb33f@enterprise.contribsys.com:80/path?param1=true¶m2=false#heading1", | ||
} | ||
return validate(r, tps, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.