Skip to content

Commit

Permalink
Fixed Gitleaks --no-git doesn't work anymore (#3112)
Browse files Browse the repository at this point in the history
* Fixed Gitleaks --no-git doesn't work anymore (#2945)

* Regression on the `--no-git` option which was systematically deleted.

  This prevents Gitleaks from treating git repository as a regular directory and scan those files.

* Update CHANGELOG.md
  • Loading branch information
VictorRos authored Nov 14, 2023
1 parent 427d115 commit 57095f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Updated lintr config template to use `linters_with_defaults()` (formerly `with_defaults()`)
- Update base image to `python:3.11.6-alpine3.18`

- Fixes
- Fix issue Gitleaks `--no-git` does not work anymore, [#2945](https://github.com/oxsecurity/megalinter/issues/2945), in [PR 3112](https://github.com/oxsecurity/megalinter/pull/3112)

- CI
- Upgrade pymdown-extensions and markdown, by @BryanQuigley in [#3053](https://github.com/oxsecurity/megalinter/pull/3053)


- Linter versions upgrades
- [protolint](https://github.com/yoheimuta/protolint) from 0.46.2 to **0.46.3** on 2023-10-29
- [checkov](https://www.checkov.io/) from 3.0.12 to **3.0.13** on 2023-10-30
Expand Down
13 changes: 7 additions & 6 deletions megalinter/linters/GitleaksLinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ def get_github_sha(self):
# Manage presence of --no-git in command line
def build_lint_command(self, file=None):
cmd = super().build_lint_command(file)
# --no-git / --redact has been sent by user in REPOSITORY_GITLEAKS_ARGUMENTS
# --redact has been sent by user in REPOSITORY_GITLEAKS_ARGUMENTS
# make sure that it's only once in the arguments list
if (
"--redact" in self.cli_lint_user_args
or "--no-git" in self.cli_lint_user_args
):
if "--redact" in self.cli_lint_user_args:
cmd = list(dict.fromkeys(cmd))

# --no-git has been sent by user in REPOSITORY_GITLEAKS_ARGUMENTS
# make sure that it's only once in the arguments list
if "--no-git" in self.cli_lint_user_args:
cmd = list(dict.fromkeys(cmd))
# --no-git has been sent by default from ML descriptor
# but as it is a git repo, remove all --no-git from arguments list
if "--no-git" in cmd and utils.is_git_repo(self.workspace):
elif "--no-git" in cmd and utils.is_git_repo(self.workspace):
cmd = list(filter(lambda a: a != "--no-git", cmd))

if (
Expand Down

0 comments on commit 57095f0

Please sign in to comment.