gitleaks: Issue: Failed to Load Config: RuleID Missing (Starting Sept 15th, 2024)

Hi team - starting from 15th Sept 2024 we are seeing the below exception and couldn’t run GitLeaks on GitHub repos.

Can you please look into it, and fix it?

Starting: Detect Secrets
==============================================================================
Task         : Gitleaks scan
Description  : Scan git repos (or files) for secrets using regex and entropy.
Version      : 2.9.0
Author       : Joost Voskuil (joost@foxhole.nl)
Help         : [More information](https://github.com/JoostVoskuil/azure-devops-gitleaks)
==============================================================================
Thanks to Zachary Rice (https://github.com/zricethezav) for creating and maintaining gitleaks.
Thanks to Jesse Houwing (https://github.com/jessehouwing) for providing a gitleaks config that has most of Microsoft's deprecated credscan rules ported to it.

Only commits are scanned that are ommited between this build and the previous build with a max of 1000 commits.
Scanning for 1 Git commit(s) for this build. First commit is e4ca616cb93a1446b9a4a3c266015e8f84acb8cc, Last commit is e4ca616cb93a1446b9a4a3c266015e8f84acb8cc
Querying Gitleaks Latest Release GitHub Page.
The latest version of Gitleaks (8.19.1) must be downloaded...
Downloading: https://github.com/zricethezav/gitleaks/releases/download/v8.19.1/gitleaks_8.19.1_windows_x64.zip
Extracting archive
C:\Windows\system32\chcp.com 65001
Active code page: 65001
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\AzureDevOpsAgent\_work\_temp\b9765b7c-574e-41c9-a2ca-d0628a043980', 'C:\AzureDevOpsAgent\_work\_temp\21b69363-87d9-4ce0-8fcc-893949b121f7')"
Caching tool: gitleaks 8.19.1 x64
C:\AzureDevOpsAgent\_work\_tool\gitleaks\8.19.1\x64\gitleaks.exe detect --config=C:\AzureDevOpsAgent\_work\_tasks\Gitleaks_11bd67d8-bfe7-497b-967d-e800eb673119\2.9.0\configs\UDMSecretChecksv8.toml --source=C:\AzureDevOpsAgent\_work\23\s "--log-opts=e4ca616cb93a1446b9a4a3c266015e8f84acb8cc^! e4ca616cb93a1446b9a4a3c266015e8f84acb8cc" --redact --report-format=sarif --report-path=C:\AzureDevOpsAgent\_work\_temp\gitleaks-report-a9c19ea1-cc59-50ca-acc6-ed87a2323e25.sarif --exit-code=99

    ○
    │╲
    │ ○
    ○ ░
    ░    gitleaks

6:01AM FTL Failed to load config error="rule |id| is missing or empty, regex: (?i)(?:AccessToken|pat|token).*?[':=\"][a-z0-9/+]{70}==(?:'|\"|\\s|[\\r?\\n]+)"

The Task we are using is below and working as expected for the last 2+ years.

      - task: Gitleaks@2
        inputs:
          scanlocation: "$(Build.SourcesDirectory)"
          configtype: "predefined"
          predefinedconfigfile: "UDMSecretChecksv8.toml"
          scanmode: "${{ parameters.scanmode }}"
          taskfail: "${{ parameters.taskfail }}"
          reportformat: "sarif"
          verbose: true
        enabled: ${{ parameters.enabled }}
        displayName: "Detect Secrets"

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (5 by maintainers)

Most upvoted comments

Thank you all for jumping on this so fast. Confirmed it is fixed now. I just wish Microsoft was just as quick at fixing their problems… Just goes to show Open Source people are the best out there!

Working on it. Will fix it tonight

Thanks, team - confirmed that the tool is working as expected after the fix PR.

hei @rgmz sorry, i got over my head in here and forgot to give more infos. The issue is on my side the same as posted in the first comment. This are azure devOps pipelines.

Ah, I didn’t realize the GitLeaks scan was a public third-party one and not something custom-built by OP.

There appears to be an unfortunate typo in the config. I’ve opened a pull request to fix it.

[[rules]]
-d = "CSCAN0240 2" 
+id = "CSCAN0240 2" 
description = "VstsPersonalAccessToken 2" 

https://github.com/JoostVoskuil/azure-devops-gitleaks/blob/efb961dc7ca32664aaac795cd160920d449a00fc/task/v2/configs/UDMSecretChecksv8.toml#L261-L262

cut a new release here https://github.com/gitleaks/gitleaks/releases/tag/v8.19.2

will work on getting validation logic working with extended configs

We use a toml file in our repo to extend the default configuration, like mentioned in the PR I believe to cause this issue: https://github.com/gitleaks/gitleaks/pull/1463

As an example, our “local” config looks like this:

[extend]
# useDefault will extend the base configuration with the default gitleaks config:
# https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml
useDefault = true

# An array of tables that contain information that define instructions
# on how to detect secrets
[[rules]]
id = "generic-api-key"
[rules.allowlist]
	description = "False positive. Keys used for colors match the rule, and should be excluded."
	files = ['''Some_Files\.xaml''']

In this case, the generic-api-key rule incorrectly flagged some of our hex-defined colors in a XAML file. Since the update, we now get this error:

FTL Failed to load config error="generic-api-key: both |regex| and |path| are empty, this rule will have no effect"

But… the [id] isn’t empty?