Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gitleaks to 8.18.1 and custom rules #85

Merged
merged 14 commits into from
Dec 5, 2023

Conversation

markdboyd
Copy link
Contributor

@markdboyd markdboyd commented Dec 4, 2023

Changes proposed in this pull request:

caulking was flagging lines such as this as secrets because of the word keyword:

https://github.com/cloud-gov/logsearch-for-cloudfoundry/blob/develop/jobs/upload-kibana-objects/templates/kibana-objects/index-pattern/logs.json.erb#L10

I began exploring how to update our local.toml to ignore these false positives. Initially, I planned to leverage the regexTarget: "line feature added in v8.16.0 to ignore any lines with "type":"keyword", so I updated to Gitleaks v8.18.1.

But I was having issues with this repo's tests after upgrading to 8.18.1. It turns out that you need an id for every rule and that without that property, you get unexpected results.

I was adding id attributes to all of our rules when I also discovered that you can have your custom config extend the default config that comes with gitleaks. By doing this, we can eliminate all of the rules from gitleaks that we copied into our custom config as of gitleaks version 4.1.1 and instead just inherit them from gitleaks core. We also benefit from new rules that have been added to gitleaks core.

Specifically, I removed the Generic Credential rule that now exists as generic-api-key in gitleaks core. Removing this rule and relying on the defaults from gitleaks resolved my initial issues.

I did preserve some of our custom rules that didn't seem like they are covered in the upstream gitleaks core.

security considerations

This is a pretty significant refactor of our configuration, but with definite security benefits:

  • no need to separately maintain rules from upstream gitleaks core
  • less custom configuration to maintain
  • getting more/new rules from upstream gitleaks core

make audit is passing with these changes, demonstrating that at least as far the tests demonstrate, these changes provide the same security guarantees.

@markdboyd markdboyd requested review from pburkholder and a team December 4, 2023 22:41
local.toml Outdated Show resolved Hide resolved
@pburkholder
Copy link
Contributor

This looks awesome.

I was able to update to this version with:

git checkout update-gitleaks-version-config
make clean
make install

I think only make clean install will be needed by our team to update once we merge.

The make audit command works as expected (it fails #14 because I'm not on main and the latest commit, so that's expected.)

However, bats development.bats fails 9 of the 33 tests. I haven't dug into why yet. We'll need to clean those up before merging. A great start though!

rcgottlieb
rcgottlieb previously approved these changes Dec 5, 2023
@pburkholder
Copy link
Contributor

Passes local tests for me. :shipit:

@markdboyd markdboyd merged commit 375920b into main Dec 5, 2023
2 checks passed
@markdboyd markdboyd deleted the update-gitleaks-version-config branch December 5, 2023 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants