Skip to content

Commit

Permalink
feat(SP-1743): upgrade to gitleaks v8 (#9)
Browse files Browse the repository at this point in the history
* feat: updating rules and tests and scripts to use gitleaks v8

* bumping gitleaks patch version and using mktemp for tmp dirs

* debugging CI

* using --no-git and removing git repo initialization

* using ephemeral runners

* removing tmp dirs logic

* using correct filename

* adding legacy (pre v8) gitleaks rules

* removing unnecessary command
  • Loading branch information
davidsalvador-tf authored Jun 28, 2022
1 parent c64aa0c commit a6a1b6d
Show file tree
Hide file tree
Showing 29 changed files with 1,170 additions and 249 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
!gitleaks_config_generator_tests.py
!requirements.txt
!global_config.toml
!global_config_legacy.toml
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
build:
name: Run tests, build, and publish if needed
runs-on: [self-hosted, bear]
runs-on: [self-hosted, bear-ephemeral]

steps:

Expand All @@ -34,7 +34,7 @@ jobs:
env:
CONTAINER_REGISTRY: ${{ secrets.ECR_REGISTRY }}

- name: Run integration tests (code samples) for global gitleaks config
- name: Run tests (code samples) for global gitleaks config
run: make test-gitleaks-config
env:
CONTAINER_REGISTRY: ${{ secrets.ECR_REGISTRY }}
Expand Down
6 changes: 5 additions & 1 deletion gitleaks_config_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@


def main():
final_config = get_final_config('global_config.toml', '.gitleaks.toml')
config_file = 'global_config_legacy.toml' # config file for gitleaks versions previous to v8
if len(sys.argv) >= 2:
config_file = 'global_config.toml'

final_config = get_final_config(config_file, '.gitleaks.toml')
print(toml.dumps(final_config))


Expand Down
8 changes: 4 additions & 4 deletions gitleaks_config_generator_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ class TestGitleaksConfigGenerator(unittest.TestCase):

def test_get_final_config_without_local_config(self):
final_config = c.get_final_config('global_config.toml', '')
self.assertFalse('*.mp3' in final_config['allowlist']['files'])
self.assertFalse('*.mp3' in final_config['allowlist']['paths'])

def test_get_final_config_with_local_config(self):
final_config = c.get_final_config('global_config.toml', 'local-config.toml')
self.assertTrue('*.mp3' in final_config['allowlist']['files'])
self.assertTrue('*.mp3' in final_config['allowlist']['paths'])

def test_merge_config(self):
final_config = c.merge_config('global_config.toml', 'local-config.toml')
self.assertTrue('*.mp3' in final_config['allowlist']['files'])
self.assertTrue(isinstance(final_config['allowlist']['description'], str))
self.assertTrue('*.mp3' in final_config['allowlist']['paths'])
self.assertTrue(isinstance(final_config['allowlist']['paths'], list))

def test_merge_old_config(self):
final_config = c.merge_config('global_config.toml', 'local-config-old.toml')
Expand Down
Loading

0 comments on commit a6a1b6d

Please sign in to comment.