-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
59 support passing a gitleaks toml to allow custom rules (#65)
* feat: can pass custom toml rule files to gitleaks * feat: specified gitpython version * fix: change test requirements install * feat: 3.10 * feat: added tests for toml file feature --------- Co-authored-by: Victoria Kotiwcki <victoria.kotwicki@punksecurity.co.uk>
- Loading branch information
1 parent
dda1852
commit b548e2f
Showing
12 changed files
with
264 additions
and
188 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
name: bandit | ||
on: [pull_request] | ||
jobs: | ||
sast: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.10.9 | ||
- name: Install Bandit | ||
run: pip install bandit | ||
- name: Run bandit | ||
run: bandit -r . | ||
name: bandit | ||
on: [pull_request] | ||
jobs: | ||
sast: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Bandit | ||
run: pip install bandit | ||
- name: Run bandit | ||
run: bandit -r . |
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
name: behave | ||
on: [pull_request] | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Run Buildx | ||
run: | | ||
docker buildx build . \ | ||
--load \ | ||
--progress=plain \ | ||
--tag secret-magpie \ | ||
--platform linux/amd64 | ||
- name: Install and run behave | ||
run: | | ||
docker run \ | ||
-e SKIP_IN_RUNNER="" \ | ||
-e SECRETMAGPIE_GITHUB_PAT=${{ secrets.SECRETMAGPIE_GITHUB_PAT }} \ | ||
-e SECRETMAGPIE_ADO_PAT=${{ secrets.SECRETMAGPIE_ADO_PAT }} \ | ||
-e SECRETMAGPIE_GITLAB_PAT=${{ secrets.SECRETMAGPIE_GITLAB_PAT }} \ | ||
--entrypoint sh \ | ||
secret-magpie \ | ||
-c "pip install behave; python -m behave" | ||
name: behave | ||
on: [pull_request] | ||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Run Buildx | ||
run: | | ||
docker buildx build . \ | ||
--load \ | ||
--progress=plain \ | ||
--tag secret-magpie \ | ||
--platform linux/amd64 | ||
- name: Install and run behave | ||
run: | | ||
docker run \ | ||
-e SKIP_IN_RUNNER="" \ | ||
-e SECRETMAGPIE_GITHUB_PAT=${{ secrets.SECRETMAGPIE_GITHUB_PAT }} \ | ||
-e SECRETMAGPIE_ADO_PAT=${{ secrets.SECRETMAGPIE_ADO_PAT }} \ | ||
-e SECRETMAGPIE_GITLAB_PAT=${{ secrets.SECRETMAGPIE_GITLAB_PAT }} \ | ||
--entrypoint sh \ | ||
secret-magpie \ | ||
-c "pip install -r test-requirements.txt; python -m behave" |
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
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 |
---|---|---|
@@ -1,60 +1,68 @@ | ||
Feature: Validate that the results files produced by secret-magpie-cli is of valid form and contains expected data. | ||
@localrepos | ||
@fixture.wantsSSHKey | ||
Scenario Outline: Validate that the <format> output is of valid form when a repo contains multi-line secrets | ||
When we run secret-magpie-cli with output format <format> and engines: all | ||
Then the results file will be of valid form | ||
|
||
Examples: | ||
| format | | ||
| json | | ||
| csv | | ||
|
||
@localrepos | ||
@fixture.wantsAWSSecret | ||
Scenario Outline: Ensure that the secrets column is blank when using format <format> and we disable storing secrets | ||
When we run secret-magpie-cli with secret storing disabled, output format <format> and engines: all | ||
Then the secret field within the output will be blank | ||
|
||
Examples: | ||
| format | | ||
| json | | ||
| csv | | ||
|
||
@localrepos | ||
Scenario: Ensure that when we run secret-magpie-cli with no engines enabled, we get the correct error | ||
When we run secret-magpie-cli with engines: none | ||
Then secret-magpie-cli's output will be | ||
""" | ||
ERROR: No tools to scan with | ||
""" | ||
|
||
@github.secretmagpie-testing | ||
Scenario: Ensure that we clean up repos that we've cloned when using a remote | ||
When we run secret-magpie-cli with engines: all | ||
Then directory 7c484be0 won't exist | ||
And directory 42cbad53 won't exist | ||
|
||
@no-cleanup | ||
@github.secretmagpie-testing | ||
@rmtree.7c484be0 | ||
@rmtree.42cbad53 | ||
Scenario: Ensure that we clean up repos that we've cloned when using a remote | ||
When we run secret-magpie-cli with engines: all | ||
Then directory 7c484be0 will exist | ||
And directory 42cbad53 will exist | ||
|
||
@localrepos | ||
@wantsAWSSecret | ||
Scenario: Ensure that the date field within the repo is parseable in ISO8601 format. | ||
When we run secret-magpie-cli with engines: all | ||
Then the date column of results.csv will be ISO8601 format | ||
|
||
@localrepos | ||
@wantsAWSSecret | ||
Scenario: Ensure that secret-magpie-cli gives the expected error when we run it with an invalid threshold date | ||
When we run secret-magpie-cli in multi branch mode, ignoring commits older than invaliddate extra context disabled, secret storing enabled, output format csv and engines: all | ||
Then secret-magpie-cli's output will be | ||
""" | ||
ERROR: Invalid ISO format string. | ||
""" | ||
Feature: Validate that the results files produced by secret-magpie-cli is of valid form and contains expected data. | ||
@localrepos | ||
@fixture.wantsSSHKey | ||
Scenario Outline: Validate that the <format> output is of valid form when a repo contains multi-line secrets | ||
When we run secret-magpie-cli with output format <format> and engines: all | ||
Then the results file will be of valid form | ||
|
||
Examples: | ||
| format | | ||
| json | | ||
| csv | | ||
|
||
@localrepos | ||
@fixture.wantsAWSSecret | ||
Scenario Outline: Ensure that the secrets column is blank when using format <format> and we disable storing secrets | ||
When we run secret-magpie-cli with secret storing disabled, output format <format> and engines: all | ||
Then the secret field within the output will be blank | ||
|
||
Examples: | ||
| format | | ||
| json | | ||
| csv | | ||
|
||
@localrepos | ||
Scenario: Ensure that when we run secret-magpie-cli with no engines enabled, we get the correct error | ||
When we run secret-magpie-cli with engines: none | ||
Then secret-magpie-cli's output will be | ||
""" | ||
ERROR: No tools to scan with | ||
""" | ||
|
||
@github.secretmagpie-testing | ||
Scenario: Ensure that we clean up repos that we've cloned when using a remote | ||
When we run secret-magpie-cli with engines: all | ||
Then directory 7c484be0 won't exist | ||
And directory 42cbad53 won't exist | ||
|
||
@no-cleanup | ||
@github.secretmagpie-testing | ||
@rmtree.7c484be0 | ||
@rmtree.42cbad53 | ||
Scenario: Ensure that we clean up repos that we've cloned when using a remote | ||
When we run secret-magpie-cli with engines: all | ||
Then directory 7c484be0 will exist | ||
And directory 42cbad53 will exist | ||
|
||
@localrepos | ||
@wantsAWSSecret | ||
Scenario: Ensure that the date field within the repo is parseable in ISO8601 format. | ||
When we run secret-magpie-cli with engines: all | ||
Then the date column of results.csv will be ISO8601 format | ||
|
||
@localrepos | ||
@wantsAWSSecret | ||
Scenario: Ensure that secret-magpie-cli gives the expected error when we run it with an invalid threshold date | ||
When we run secret-magpie-cli in multi branch mode, ignoring commits older than invaliddate extra context disabled, secret storing enabled, output format csv and engines: all | ||
Then secret-magpie-cli's output will be | ||
""" | ||
ERROR: Invalid ISO format string. | ||
""" | ||
|
||
@localrepos | ||
Scenario: Ensure that secret-magpie-cli gives the expected error when we provide an invalid gitleaks toml file | ||
When we run secret-magpie-cli with a gitleaks rules_not_found.toml file | ||
Then secret-magpie-cli's output will be | ||
""" | ||
ERROR: File at rules_not_found.toml not found. | ||
""" |
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.