38 Commits
Author SHA1 Message Date
Fatih Çelik 8d1f98c796 Removed unnecessary functions from report template (#2040) 2026-02-21 07:30:12 -06:00
Zachary Rice b1c9c7ecbe Composite rules (#1905)
* composite rules

* add test config

* tests

* taking care of some pr comments

* naming
2025-07-20 11:13:38 -05:00
bplaxcoandAlex Layne 782f310478 Archive support (#1872)
* Start Files Source

* Keep cmd the same for now

* Get tests to pass

* s.MaxTargetMegaBytes -> s.MaxFileSize

* Tweak some log messages & use q semgroup for files

* Just call yield inside the semgroup

* Refactor a check and revert some log lines

* Move mg && misc tuning

* Add `make profile`

(Benchmark results are only added if tools are installed)

Example output:

```
========================================================================
generating profile data
------------------------------------------------------------------------
- mode: dir
  benchmark:
    tool: hyperfine
    path: profile/1748019612/dir/benchmark.json
    results:
      mean: 1.12852930166
      stddev: 0.12163775966037399
      median: 1.07242928416
      user: 3.9699382799999996
      system: 0.04382341999999999
      min: 1.03207673016
      max: 1.3913475181600001
  profile:
    - mode: cpu
      path: profile/1748019612/dir/cpu.pprof
      view: go tool pprof -http=localhost: ./gitleaks profile/1748019612/dir/cpu.pprof
    - mode: mem
      path: profile/1748019612/dir/mem.pprof
      view: go tool pprof -http=localhost: ./gitleaks profile/1748019612/dir/mem.pprof
    - mode: trace
      path: profile/1748019612/dir/trace.out
      view: go tool trace profile/1748019612/dir/trace.out
- mode: git
  ...snip...
```

* Archive support for File based sources

* Move Git to Source interface

* Scan archives in git

* Misc linter fixes

* Exclude certain diffs: --diff-filter=tuxdb

* Add git archives tests

* Log error instead of fatal

* Fix spacing in test config

* Refine source comments/wording

* Make MB conversions more readable

* Format cmd

* Adjust DetectSource logging

* MiB -> MB in logs

* Add testdata/repos/archives/dotGit/refs/.gitkeep

Without it the refs folder gets deleted and the
and then it isn't detected as a git repo ¯\_(ツ)_/¯

So then the test starts scanning the whole gitleaks
repo instead :D

* Handle finding links for archives

* Working on archive depth

* Fixes from failfast test

* cmd max-archive-depth

* added comments, fixed warnings

* removed test print

* Update README.md

* Set archive depth for DetectFiles

* Tweak logs & pass max archive for readers

* Pass ctx to Fragments

* Add make lint target and address some issues

* Fix compat issue

* Report path in fragment errors

* Apply PR suggestions & misc changes

- Update blobReader.Close() to discard the buffer
- Misc logger issues & uses
- Tweak .golangci.yaml to default to none
- Discard remaining blobReader data on close
- Undo a De Morgan's Law suggestion (and disable QF1001)

* Add http mode for diagnostics

gitleaks --diagnostics=http ...
-----

From the net/http/pprof docs:

Use the pprof tool to look at the heap profile:
```
go tool pprof http://localhost:6060/debug/pprof/heap
```

Or to look at a 30-second CPU profile:
```
go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30
```

Or to look at the goroutine blocking profile, after calling runtime.SetBlockProfileRate in your program:
```
go tool pprof http://localhost:6060/debug/pprof/block
```

Or to look at the holders of contended mutexes, after calling runtime.SetMutexProfileFraction in your program:
```
go tool pprof http://localhost:6060/debug/pprof/mutex
```

(For more info see https://pkg.go.dev/net/http/pprof)

---------

Co-authored-by: Alex Layne <alayne@redhat.com>
2025-06-01 11:29:34 -05:00
Richard Gomez c2afd56bbe Make paths and fingerprints platform-agnostic (#1622)
* test: windows

* fix: make paths platform-agnostic

this change also fixes, or skips, windows failures
2025-02-19 19:36:42 -06:00
Richard Gomez 3c7f3f0e08 feat(git): include link in report (#1698) 2025-01-19 14:03:57 -06:00
Richard Gomez 7cb5f6f64c build: upgrade sprig v2->v3 (#1674) 2024-12-20 19:44:18 -06:00
Richard Gomez 83e99bacf1 feat(report): allow user-defined templates (#1650) 2024-12-10 18:56:11 -06:00
Bryce Thuilot f3adda07ca feat: use STDOUT when report file not specified (#1642)
* feat: use STDOUT when report file not specified

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>

* fix: update tests

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>

* fix: use only '-' for stdout report

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>

---------

Signed-off-by: Bryce Thuilot <bryce@thuilot.io>
2024-12-05 09:44:07 -06:00
Taiki Ono 8e94f98e92 Add option to include Line field in report (#1616)
Signed-off-by: Taiki Ono <taiki@finatext.com>
2024-10-31 15:51:53 -05:00
Richard Gomez 525c4b4451 refactor(sarif): remove |name| and change |shortDescription| (#1473) 2024-08-19 09:11:31 -05:00
Richard Gomez d3c4b9078e Use first non-empty group if secretGroup isn't set (#1459)
* feat(detect): secret is first non-empty group

* test: fix errors

- update capture groups
- update expected data
2024-08-07 12:10:05 -05:00
Jarek Porzucek 59c0cc7183 Append ordered rules when extending (#1304) 2024-03-22 11:21:26 -05:00
Oleksandr Redko 2959fc072c refactor: simplify test asserts (#1271) 2023-10-03 10:38:08 -05:00
FrankandZachary Rice 30c6117aaa feat: Add optional redaction value, default 100 (#1229)
This commit introduces an optional value for the --redact flag, allowing
users to specify the extent of redaction for secrets. The valid range of
values is from 0 (no redaction) to 100 (full redaction).

If no value is provided, the default redaction value is set to 100,
resulting in complete redaction by replacing the secret with the term
'REDACTED'. This preserves the original behavior of the --redact flag.

Co-authored-by: Zachary Rice <zachary.rice@trufflesec.com>
2023-08-29 11:03:23 -05:00
Oleksandr Redko 46c627212c refactor: remove unnecessary removing temp files in tests (#1255) 2023-08-24 09:16:00 -05:00
eyalatox 86197b0848 add tags support for csv and sarif formats (#1176)
* add tags support for csv and sarif formats

* add tests
2023-06-15 07:16:23 -05:00
Zach b1d59bf890 fix broken vet, format some stuff 2023-06-13 16:05:04 -05:00
Malte Morgenstern 0dbdde837f Add junit report format (#920)
* add junit report format

* add fingerprint to expected test result to fix tests

* fix expected junit test report
2023-06-13 13:37:32 -05:00
Oleksandr Redko 190ac977be Fix closing file in writeJson and writeSarif (#1187) 2023-06-05 10:43:04 -05:00
Oleksandr Redko 6dbb0c5af5 Simplify tests by using T.TempDir (#1186) 2023-05-30 07:24:59 -05:00
Oleksandr Redko 6705461b33 Fix typos in *.md, comments and logs (#1185) 2023-05-30 07:08:42 -05:00
Dariusz Porowski 146f69e51b 🐛 fix(sarif): update report to pass validator (#1167)
* 🐛 fix(sarif): update report to pass validator

* ✅ test(sarif): update sarif report testdata
2023-04-28 14:15:18 -05:00
Ricky GrassmuckandZachary Rice 6d801ed61c Add support for following symlinks (#1010)
* Add support for following symlinks

* Update detect/detect.go

Co-authored-by: Zachary Rice <zricezrice@gmail.com>

* Update cmd/detect.go

Co-authored-by: Zachary Rice <zricezrice@gmail.com>
2022-10-12 19:28:53 -05:00
Zachary Rice 96eed6aa0f Pretty output (#973)
pretty output
2022-09-04 08:58:57 -05:00
Zachary Rice 3bace4c735 Feat/ignore finding (#938) 2022-08-07 12:53:58 -05:00
Zachary Rice 31650f01e7 Feature: Adding the ability to extend configuration files (#926)
* init

* working on default and path config extensions

* adding trace log level, consolidating some code

* cleaning things up, updating generate package

* fix tests

* formatting

* adding tests for extend

* extend not extends

* formatting

* only allow usedefault or path to be set

* update readme

* add note about allowlists

* more readme, expand env var for path

* actually dont support env var. ez attack
2022-07-24 11:51:50 -05:00
Zachary Rice 6e72472b60 Refactor detect, add entropy to all findings (#804)
Refactor `detect`, add `entropy` to all findings
2022-03-12 11:50:01 -06:00
rui 4b6f4d0de5 build: updates for go1.17 (#769)
* build: remove `GO111MODULE` as it turned on by default

Signed-off-by: Rui Chen <rui@chenrui.dev>

* build: update for go1.17

* run test

Signed-off-by: Rui Chen <rui@chenrui.dev>

* lint: remove unused code
2022-02-22 16:49:45 -06:00
Zachary Rice b91799aa18 fixing segfault when using a rule with only a path (#791)
* fixing segfault when using a rule with only a path

* DRYing
2022-02-22 15:58:03 -06:00
Chris Wolf d1f642a9df Sarif results with empty rules now represents as [] instead of null/nil (#786) 2022-02-19 10:20:35 -06:00
Zach Rice 44d7d89e19 always write sarif results 2021-12-28 19:13:26 -06:00
Zachary Rice 43ec22429f write a report regardless if leaks are present (#758) 2021-12-17 17:26:14 -06:00
Zachary Rice ce42947cae fix deduplication issue caused by clobbered findings (#742)
* fix deduplication issue caused by clobbered findings

* fix index

* remove indexing, slow is better than wrong
2021-12-07 19:11:37 -06:00
Zachary Rice 98d5648f6e introducing secretGroup, the best group (#734)
* working on deduping

* my eyes... oh god my poor eyes

* more readme

* more readme

* more readme

* more readme and formatting
2021-12-02 20:04:36 -06:00
Joost Voskuil 8eabfd614e Update sarif.go (#713)
* Update sarif.go

Provide correct version information for Sarif Reports

* Update test

Set version to correct Sarif version
2021-11-25 10:46:31 -06:00
Zachary Rice 93f292c3df Introducing v8.0.0 changes (#701)
* Introducing v8.0.0 changes
2021-11-22 10:43:51 -06:00
Zachary Rice 7db08bfd90 Bugs v7 (#475)
* fixing some v7 bugs
2020-12-05 11:57:43 -05:00
Zachary Rice c50906373c update to V7 (#469) 2020-12-02 17:07:31 -05:00