leakkill 0.7.1__tar.gz → 0.7.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {leakkill-0.7.1/src/leakkill.egg-info → leakkill-0.7.2}/PKG-INFO +4 -4
  2. {leakkill-0.7.1 → leakkill-0.7.2}/README.md +3 -3
  3. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/__init__.py +1 -1
  4. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/cli.py +18 -1
  5. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/scanner.py +97 -10
  6. {leakkill-0.7.1 → leakkill-0.7.2/src/leakkill.egg-info}/PKG-INFO +4 -4
  7. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill.egg-info/SOURCES.txt +1 -0
  8. leakkill-0.7.2/tests/test_real_world.py +99 -0
  9. {leakkill-0.7.1 → leakkill-0.7.2}/LICENSE +0 -0
  10. {leakkill-0.7.1 → leakkill-0.7.2}/THIRD_PARTY_NOTICES.md +0 -0
  11. {leakkill-0.7.1 → leakkill-0.7.2}/pyproject.toml +0 -0
  12. {leakkill-0.7.1 → leakkill-0.7.2}/setup.cfg +0 -0
  13. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/__main__.py +0 -0
  14. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/agents.py +0 -0
  15. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/aws.py +0 -0
  16. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/baseline.py +0 -0
  17. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/gitleaks_rules.py +0 -0
  18. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/guard.py +0 -0
  19. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/providers.py +0 -0
  20. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/report.py +0 -0
  21. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill/sarif.py +0 -0
  22. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill.egg-info/dependency_links.txt +0 -0
  23. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill.egg-info/entry_points.txt +0 -0
  24. {leakkill-0.7.1 → leakkill-0.7.2}/src/leakkill.egg-info/top_level.txt +0 -0
  25. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_agents.py +0 -0
  26. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_cli.py +0 -0
  27. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_coverage_gaps.py +0 -0
  28. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_fuzz.py +0 -0
  29. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_guard.py +0 -0
  30. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_guard_agents.py +0 -0
  31. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_import_gitleaks.py +0 -0
  32. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_providers.py +0 -0
  33. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_redos.py +0 -0
  34. {leakkill-0.7.1 → leakkill-0.7.2}/tests/test_scanner.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: leakkill
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Find leaked secrets, check if they're live, revoke them in one command, and keep them out of AI coding agents
5
5
  Author-email: Ayush <andymylove24@gmail.com>
6
6
  License-Expression: MIT
@@ -70,7 +70,7 @@ docker run --rm -v "$PWD:/scan" ghcr.io/ayushanand27/leakkill --history # every
70
70
  | `leakkill install-hook` | Git pre-commit hook that blocks commits containing secrets | Never |
71
71
  | `leakkill install-agent-hooks` | Stop AI coding agents (Claude Code, Cursor, GitHub Copilot, OpenAI Codex) reading `.env` and keys, sending secrets in prompts, or writing secrets into code | Never |
72
72
 
73
- Every scan command also accepts `--staged` (pre-commit), `--history` (every commit on every branch,
73
+ Every scan command also accepts `--include-ignored` (also scan `.gitignore`d files, which are left out by default), `--staged` (pre-commit), `--history` (every commit on every branch,
74
74
  including secrets you already "deleted"), `--agents` (secrets your AI coding agents stored on this machine, see
75
75
  below), `--exclude-tests` and `--json`.
76
76
 
@@ -173,7 +173,7 @@ leakkill somewhat; false alarms on four clean repositories (requests, flask, dja
173
173
 
174
174
  ### How it's tested
175
175
 
176
- - 155 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 93%).
176
+ - 163 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 93%).
177
177
  - Property-based fuzz tests: the scanner never crashes on random input, never prints a raw secret, finds a
178
178
  planted token in any surrounding text, and gives the same answer scanning a whole file or line by line.
179
179
  (Fuzzing found two real bugs before release: a guard crash and a slow-input case, both fixed.)
@@ -325,7 +325,7 @@ baseline doesn't make it safe: revoke real keys first.
325
325
  # .pre-commit-config.yaml
326
326
  repos:
327
327
  - repo: https://github.com/ayushanand27/leakkill
328
- rev: v0.7.1
328
+ rev: v0.7.2
329
329
  hooks:
330
330
  - id: leakkill
331
331
  ```
@@ -50,7 +50,7 @@ docker run --rm -v "$PWD:/scan" ghcr.io/ayushanand27/leakkill --history # every
50
50
  | `leakkill install-hook` | Git pre-commit hook that blocks commits containing secrets | Never |
51
51
  | `leakkill install-agent-hooks` | Stop AI coding agents (Claude Code, Cursor, GitHub Copilot, OpenAI Codex) reading `.env` and keys, sending secrets in prompts, or writing secrets into code | Never |
52
52
 
53
- Every scan command also accepts `--staged` (pre-commit), `--history` (every commit on every branch,
53
+ Every scan command also accepts `--include-ignored` (also scan `.gitignore`d files, which are left out by default), `--staged` (pre-commit), `--history` (every commit on every branch,
54
54
  including secrets you already "deleted"), `--agents` (secrets your AI coding agents stored on this machine, see
55
55
  below), `--exclude-tests` and `--json`.
56
56
 
@@ -153,7 +153,7 @@ leakkill somewhat; false alarms on four clean repositories (requests, flask, dja
153
153
 
154
154
  ### How it's tested
155
155
 
156
- - 155 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 93%).
156
+ - 163 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 93%).
157
157
  - Property-based fuzz tests: the scanner never crashes on random input, never prints a raw secret, finds a
158
158
  planted token in any surrounding text, and gives the same answer scanning a whole file or line by line.
159
159
  (Fuzzing found two real bugs before release: a guard crash and a slow-input case, both fixed.)
@@ -305,7 +305,7 @@ baseline doesn't make it safe: revoke real keys first.
305
305
  # .pre-commit-config.yaml
306
306
  repos:
307
307
  - repo: https://github.com/ayushanand27/leakkill
308
- rev: v0.7.1
308
+ rev: v0.7.2
309
309
  hooks:
310
310
  - id: leakkill
311
311
  ```
@@ -1,2 +1,2 @@
1
1
  """leakkill: find leaked secrets, check if they're live, revoke them, and guard AI coding agents."""
2
- __version__ = "0.7.1"
2
+ __version__ = "0.7.2"
@@ -35,6 +35,21 @@ class Item:
35
35
  result: providers.Result = None
36
36
 
37
37
 
38
+ def note_skipped():
39
+ """Never let "Clean." hide that some files were not looked at."""
40
+ if scanner.SKIPPED:
41
+ why = {}
42
+ for sk in scanner.SKIPPED:
43
+ why.setdefault(sk.reason, []).append(sk.path)
44
+ parts = "; ".join(f"{len(v)} {r} (e.g. {', '.join(v[:2])})" for r, v in why.items())
45
+ print(f"leakkill: skipped {len(scanner.SKIPPED)} file(s) it could not scan: {parts}", file=sys.stderr)
46
+ if scanner.IGNORED:
47
+ roots = scanner.IGNORED_ROOTS
48
+ print(f"leakkill: left out {len(scanner.IGNORED)} git-ignored file(s) (they can't be committed): "
49
+ f"{', '.join(roots[:3])}{', ...' if len(roots) > 3 else ''}. Add --include-ignored to scan them too.",
50
+ file=sys.stderr)
51
+
52
+
38
53
  def collect(args):
39
54
  if args.agents:
40
55
  found = agents.scan_agents()
@@ -43,7 +58,8 @@ def collect(args):
43
58
  elif args.staged:
44
59
  found = scanner.scan_staged()
45
60
  else:
46
- found = scanner.scan_paths(args.paths or ["."])
61
+ found = scanner.scan_paths(args.paths or ["."], include_ignored=args.include_ignored)
62
+ note_skipped()
47
63
  ignores = scanner.load_ignores()
48
64
  found = [f for f in found if not scanner.ignored(f.path, ignores)]
49
65
  if args.exclude_tests:
@@ -218,6 +234,7 @@ def parser():
218
234
  common.add_argument("--history", action="store_true", help="scan every commit on every branch")
219
235
  common.add_argument("--agents", action="store_true",
220
236
  help="scan AI agents' files on this machine: MCP configs, settings, session transcripts")
237
+ common.add_argument("--include-ignored", action="store_true", help="also scan files that .gitignore excludes")
221
238
  common.add_argument("--exclude-tests", action="store_true", help="skip test_* files and tests/ dirs")
222
239
  common.add_argument("--json", action="store_true", help="machine-readable output")
223
240
  common.add_argument("--baseline", metavar="FILE", help="ignore secrets listed in this baseline file")
@@ -1,5 +1,5 @@
1
1
  """Find secrets in files, staged changes and git history. Never touches the network."""
2
- import base64, bisect, fnmatch, math, os, re, subprocess
2
+ import base64, bisect, codecs, fnmatch, math, os, re, stat, subprocess
3
3
  from concurrent.futures import ProcessPoolExecutor
4
4
  from dataclasses import dataclass
5
5
 
@@ -352,14 +352,57 @@ def iter_files(paths):
352
352
  yield os.path.join(root, f)
353
353
 
354
354
 
355
+ MAX_SCAN_BYTES = 2_000_000
356
+
357
+
358
+ @dataclass
359
+ class Skipped:
360
+ path: str
361
+ reason: str # "too large" | "unreadable"
362
+
363
+
364
+ SKIPPED = [] # files the last scan_paths() could not scan, so callers can say so instead of claiming "Clean."
365
+ IGNORED = [] # git-ignored files the last scan_paths() left out (they can't be committed, so they aren't leaks)
366
+ IGNORED_ROOTS = [] # ...and the ignored folders/files they belong to, for a short message
367
+
368
+
369
+ def decode_text(raw):
370
+ """Bytes -> text for UTF-8 (tried first: the common case), UTF-16 (Windows PowerShell `echo >` writes it) and
371
+ single-byte text such as Latin-1. Returns None for binary data."""
372
+ if raw.startswith((codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE)):
373
+ try:
374
+ return raw.decode("utf-16")
375
+ except UnicodeDecodeError:
376
+ return None
377
+ sample = raw[:4096]
378
+ if b"\x00" in sample: # UTF-16 without a BOM looks like ASCII with a NUL on every other byte
379
+ n = len(sample) // 2
380
+ odd, even = sample[1::2].count(0), sample[0::2].count(0)
381
+ enc = "utf-16-le" if odd > 0.9 * n and even < 0.1 * n else "utf-16-be" if even > 0.9 * n and odd < 0.1 * n else None
382
+ if enc:
383
+ try:
384
+ return raw.decode(enc)
385
+ except UnicodeDecodeError:
386
+ return None
387
+ try:
388
+ return raw.decode("utf-8-sig")
389
+ except UnicodeDecodeError:
390
+ return None if b"\x00" in raw[:8192] else raw.decode("latin-1")
391
+
392
+
355
393
  def _scan_file(f):
356
394
  try:
357
- if os.path.getsize(f) > 2_000_000:
358
- return []
359
- with open(f, encoding="utf-8", errors="strict") as fh:
360
- return scan_text(fh.read(), os.path.relpath(f))
361
- except (UnicodeDecodeError, OSError):
362
- return [] # binary / unreadable
395
+ st = os.stat(f)
396
+ if not stat.S_ISREG(st.st_mode):
397
+ return [] # pipes, sockets and devices: opening a pipe blocks forever, and they hold no source code
398
+ if st.st_size > MAX_SCAN_BYTES:
399
+ return [Skipped(f, "too large")]
400
+ with open(f, "rb") as fh:
401
+ raw = fh.read()
402
+ except OSError:
403
+ return [Skipped(f, "unreadable")]
404
+ text = decode_text(raw)
405
+ return scan_text(text, os.path.relpath(f)) if text is not None else []
363
406
 
364
407
 
365
408
  def _parallel(fn, items, jobs=None):
@@ -374,9 +417,53 @@ def _parallel(fn, items, jobs=None):
374
417
  return [f for item in items for f in fn(item)]
375
418
 
376
419
 
377
- def scan_paths(paths, jobs=None):
378
- """Scan files, in parallel across CPU cores when there are many of them."""
379
- return _parallel(_scan_file, list(iter_files(paths)), jobs)
420
+ def _git_ignored(path):
421
+ """(files, directories) under `path` that git ignores and does not track; empty outside a git repository,
422
+ and empty when `path` itself is ignored (you named a folder like `data/`: you want it scanned)."""
423
+ try:
424
+ if subprocess.run(["git", "-C", path, "check-ignore", "-q", "."], capture_output=True, timeout=30).returncode == 0:
425
+ return set(), []
426
+ r = subprocess.run(["git", "-C", path, "ls-files", "--others", "--ignored", "--exclude-standard",
427
+ "--directory", "-z"], capture_output=True, timeout=30)
428
+ except (OSError, subprocess.SubprocessError):
429
+ return set(), []
430
+ if r.returncode:
431
+ return set(), []
432
+ files, dirs = set(), []
433
+ for rel in r.stdout.decode("utf-8", "replace").split("\0"):
434
+ if rel:
435
+ full = os.path.normpath(os.path.join(os.path.abspath(path), rel))
436
+ (dirs.append(full + os.sep) if rel.endswith("/") else files.add(full))
437
+ return files, dirs
438
+
439
+
440
+ def scan_paths(paths, jobs=None, include_ignored=False):
441
+ """Scan files, in parallel across CPU cores when there are many of them.
442
+
443
+ Inside a git repository, files git ignores (a `.env` in .gitignore) are left out, because they can never be
444
+ committed; tracked files are always scanned. They are listed in IGNORED; `include_ignored` scans them too."""
445
+ files = list(iter_files(paths))
446
+ IGNORED[:] = []
447
+ IGNORED_ROOTS[:] = []
448
+ if not include_ignored:
449
+ skip_files, skip_dirs = set(), []
450
+ for p in paths:
451
+ if os.path.isdir(p):
452
+ f, d = _git_ignored(p)
453
+ skip_files |= f
454
+ skip_dirs += d
455
+ if skip_files or skip_dirs:
456
+ def root_of(f): # the git-ignored folder (or the file itself) that covers f, else None
457
+ full = os.path.normpath(os.path.abspath(f))
458
+ return full if full in skip_files else next((d for d in skip_dirs if full.startswith(d)), None)
459
+ roots = {f: root_of(f) for f in files}
460
+ IGNORED[:] = [f for f in files if roots[f]]
461
+ IGNORED_ROOTS[:] = sorted({os.path.relpath(roots[f]) + (os.sep if roots[f].endswith(os.sep) else "")
462
+ for f in IGNORED})
463
+ files = [f for f in files if not roots[f]]
464
+ out = _parallel(_scan_file, files, jobs)
465
+ SKIPPED[:] = [r for r in out if isinstance(r, Skipped)]
466
+ return [r for r in out if not isinstance(r, Skipped)]
380
467
 
381
468
 
382
469
  def _git(*args):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: leakkill
3
- Version: 0.7.1
3
+ Version: 0.7.2
4
4
  Summary: Find leaked secrets, check if they're live, revoke them in one command, and keep them out of AI coding agents
5
5
  Author-email: Ayush <andymylove24@gmail.com>
6
6
  License-Expression: MIT
@@ -70,7 +70,7 @@ docker run --rm -v "$PWD:/scan" ghcr.io/ayushanand27/leakkill --history # every
70
70
  | `leakkill install-hook` | Git pre-commit hook that blocks commits containing secrets | Never |
71
71
  | `leakkill install-agent-hooks` | Stop AI coding agents (Claude Code, Cursor, GitHub Copilot, OpenAI Codex) reading `.env` and keys, sending secrets in prompts, or writing secrets into code | Never |
72
72
 
73
- Every scan command also accepts `--staged` (pre-commit), `--history` (every commit on every branch,
73
+ Every scan command also accepts `--include-ignored` (also scan `.gitignore`d files, which are left out by default), `--staged` (pre-commit), `--history` (every commit on every branch,
74
74
  including secrets you already "deleted"), `--agents` (secrets your AI coding agents stored on this machine, see
75
75
  below), `--exclude-tests` and `--json`.
76
76
 
@@ -173,7 +173,7 @@ leakkill somewhat; false alarms on four clean repositories (requests, flask, dja
173
173
 
174
174
  ### How it's tested
175
175
 
176
- - 155 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 93%).
176
+ - 163 tests on Linux, macOS and Windows with Python 3.9 and 3.13; CI fails below 88% branch coverage (currently 93%).
177
177
  - Property-based fuzz tests: the scanner never crashes on random input, never prints a raw secret, finds a
178
178
  planted token in any surrounding text, and gives the same answer scanning a whole file or line by line.
179
179
  (Fuzzing found two real bugs before release: a guard crash and a slow-input case, both fixed.)
@@ -325,7 +325,7 @@ baseline doesn't make it safe: revoke real keys first.
325
325
  # .pre-commit-config.yaml
326
326
  repos:
327
327
  - repo: https://github.com/ayushanand27/leakkill
328
- rev: v0.7.1
328
+ rev: v0.7.2
329
329
  hooks:
330
330
  - id: leakkill
331
331
  ```
@@ -27,5 +27,6 @@ tests/test_guard.py
27
27
  tests/test_guard_agents.py
28
28
  tests/test_import_gitleaks.py
29
29
  tests/test_providers.py
30
+ tests/test_real_world.py
30
31
  tests/test_redos.py
31
32
  tests/test_scanner.py
@@ -0,0 +1,99 @@
1
+ """Bugs found by using leakkill like a newcomer on Windows and in a normal git project."""
2
+ import os, subprocess, sys
3
+
4
+ import pytest
5
+
6
+ from leakkill import cli, scanner
7
+
8
+ GH = "ghp_" + "a1B2c3D4e5F6g7H8i9J0k1L2m3N4o5P6q7R8"
9
+ LINE = f'TOKEN = "{GH}"\n'
10
+
11
+
12
+ def found(tmp_path, **kw):
13
+ return {os.path.basename(f.path) for f in scanner.scan_paths([str(tmp_path)], **kw)}
14
+
15
+
16
+ def test_text_in_other_encodings_is_scanned(tmp_path):
17
+ (tmp_path / "utf16_bom.py").write_bytes(LINE.replace("\n", "\r\n").encode("utf-16")) # PowerShell 5 `echo >`
18
+ (tmp_path / "utf16_le_nobom.txt").write_bytes(LINE.encode("utf-16-le"))
19
+ (tmp_path / "utf16_be_nobom.txt").write_bytes(LINE.encode("utf-16-be"))
20
+ (tmp_path / "latin1.py").write_bytes(("# caf\xe9\n" + LINE).encode("latin-1"))
21
+ (tmp_path / "bom.py").write_bytes(b"\xef\xbb\xbf" + LINE.encode())
22
+ (tmp_path / "plain.py").write_text(LINE)
23
+ assert found(tmp_path) == {"utf16_bom.py", "utf16_le_nobom.txt", "utf16_be_nobom.txt", "latin1.py", "bom.py",
24
+ "plain.py"}
25
+
26
+
27
+ def test_decode_text_binary_and_edges():
28
+ assert scanner.decode_text(b"\xff\xfe\x00\x00\xd8") is None or True # never raises
29
+ assert scanner.decode_text(b"\x00\x01\xff\xfe\x00\x80" * 50) is None # binary with invalid UTF-8
30
+ assert scanner.decode_text(b"") == ""
31
+ assert scanner.decode_text("héllo".encode("utf-8")) == "héllo"
32
+
33
+
34
+ @pytest.mark.skipif(not hasattr(os, "mkfifo"), reason="needs named pipes")
35
+ def test_named_pipe_does_not_hang_the_scan(tmp_path):
36
+ os.mkfifo(tmp_path / "pipe")
37
+ (tmp_path / "app.py").write_text(LINE)
38
+ code = ("import sys; from leakkill import scanner; "
39
+ f"print(len(scanner.scan_paths([{str(tmp_path)!r}], jobs=1)))")
40
+ r = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True, timeout=30)
41
+ assert r.stdout.strip() == "1" # a blocked read would have hit the timeout
42
+
43
+
44
+ def test_skipped_files_are_reported_not_hidden(tmp_path, monkeypatch, capsys):
45
+ (tmp_path / "huge.sql").write_text(LINE * 5)
46
+ monkeypatch.setattr(scanner, "MAX_SCAN_BYTES", 10)
47
+ assert scanner.scan_paths([str(tmp_path)]) == []
48
+ assert [(os.path.basename(s.path), s.reason) for s in scanner.SKIPPED] == [("huge.sql", "too large")]
49
+ cli.note_skipped()
50
+ assert "skipped 1 file(s) it could not scan: 1 too large" in capsys.readouterr().err
51
+
52
+
53
+ def git(cwd, *args):
54
+ subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True)
55
+
56
+
57
+ def test_gitignored_files_are_left_out_but_tracked_ones_never(tmp_path, capsys):
58
+ git(tmp_path, "init", "-q")
59
+ git(tmp_path, "config", "user.email", "t@example.com")
60
+ git(tmp_path, "config", "user.name", "t")
61
+ (tmp_path / ".gitignore").write_text(".env\nprivate/\n")
62
+ (tmp_path / "private").mkdir()
63
+ (tmp_path / "private" / "out.py").write_text(LINE)
64
+ (tmp_path / ".env").write_text(LINE)
65
+ (tmp_path / "app.py").write_text(LINE)
66
+ (tmp_path / "old.env.py").write_text(LINE)
67
+ git(tmp_path, "add", "-f", "old.env.py") # tracked
68
+ (tmp_path / ".gitignore").write_text(".env\nprivate/\nold.env.py\n") # ignored later, but still tracked
69
+ assert found(tmp_path) == {"app.py", "old.env.py"}
70
+ assert sorted(os.path.basename(f) for f in scanner.IGNORED) == [".env", "out.py"]
71
+ cli.note_skipped()
72
+ assert "left out 2 git-ignored file(s)" in capsys.readouterr().err
73
+ assert found(tmp_path, include_ignored=True) == {"app.py", "old.env.py", ".env", "out.py"}
74
+ assert scanner.IGNORED == []
75
+
76
+
77
+ def test_no_git_means_everything_is_scanned(tmp_path):
78
+ (tmp_path / ".gitignore").write_text(".env\n") # not a repository: the file means nothing
79
+ (tmp_path / ".env").write_text(LINE)
80
+ assert found(tmp_path) == {".env"}
81
+
82
+
83
+ def test_cli_include_ignored_flag(tmp_path, monkeypatch):
84
+ git(tmp_path, "init", "-q")
85
+ (tmp_path / ".gitignore").write_text(".env\n")
86
+ (tmp_path / ".env").write_text(LINE)
87
+ monkeypatch.chdir(tmp_path)
88
+ assert cli.main(["scan"]) == 0
89
+ assert cli.main(["scan", "--include-ignored"]) == 1
90
+
91
+
92
+ def test_naming_an_ignored_folder_scans_it(tmp_path):
93
+ git(tmp_path, "init", "-q")
94
+ (tmp_path / ".gitignore").write_text("data/\n")
95
+ (tmp_path / "data").mkdir()
96
+ (tmp_path / "data" / "dump.txt").write_text(LINE)
97
+ assert {os.path.basename(f.path) for f in scanner.scan_paths([str(tmp_path / "data")])} == {"dump.txt"}
98
+ assert scanner.IGNORED == []
99
+ assert found(tmp_path) == set() and len(scanner.IGNORED) == 1 # but scanning the repo root leaves it out
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes