leakkill 0.4.1__tar.gz → 0.4.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: leakkill
3
- Version: 0.4.1
3
+ Version: 0.4.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
@@ -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.4.1"
2
+ __version__ = "0.4.2"
@@ -1,5 +1,5 @@
1
1
  """Claude Code hook: keep secrets out of AI coding agents (prompts, file reads, shell reads, generated code)."""
2
- import json, os, re, sys
2
+ import json, os, re, stat, sys
3
3
 
4
4
  from .scanner import scan_text
5
5
 
@@ -92,6 +92,6 @@ def install_git_hook():
92
92
  cmd = _self_cmd("scan --staged").replace("\\", "/")
93
93
  with open(hook, "w", newline="\n") as f:
94
94
  f.write(f'#!/bin/sh\n{cmd} || {{ echo "Commit blocked by leakkill."; exit 1; }}\n')
95
- os.chmod(hook, 0o755)
95
+ os.chmod(hook, os.stat(hook).st_mode | stat.S_IXUSR) # git only needs the owner to be able to run it
96
96
  print("Installed", hook)
97
97
  return 0
@@ -35,9 +35,10 @@ RULES = {
35
35
  "JWT": re.compile(r"\b(eyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})"),
36
36
  "Credentials in URL": re.compile(r"\b([a-z][a-z0-9+]*://[^\s:/@]+:[^\s:/@]{3,}@[^\s/\"']+)"),
37
37
  }
38
- # key = "value" where the key name looks sensitive and the value looks random
38
+ # key = "value" where the key name looks sensitive and the value looks random.
39
+ # Name parts are length-bounded so matching stays linear on huge (e.g. minified) lines.
39
40
  ASSIGN = re.compile(
40
- r"""(?i)\b[\w.-]*(?:secret|token|passwd|password|api[_-]?key|private[_-]?key|auth)[\w.-]*\b
41
+ r"""(?i)(?<![\w.-])[\w.-]{0,40}?(?:secret|token|passwd|password|api[_-]?key|private[_-]?key|auth)[\w.-]{0,40}
41
42
  \s*[:=]\s*["']([^"'\s]{12,})["']""", re.X)
42
43
  PLACEHOLDER = re.compile(r"(?i)example|placeholder|changeme|your[_-]|xxx|<.*>|\$\{|\{\{|dummy|sample|test")
43
44
  SKIP_DIRS = {".git", "node_modules", "venv", ".venv", "__pycache__", "dist", "build", ".idea", ".tox", ".mypy_cache"}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: leakkill
3
- Version: 0.4.1
3
+ Version: 0.4.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
@@ -79,3 +79,12 @@ def test_new_providers_detected_exactly():
79
79
  assert kinds(f'x = "{token}"') == [kind], (kind, kinds(f'x = "{token}"'))
80
80
  def test_openrouter_not_reported_as_openai():
81
81
  assert "OpenAI API key" not in kinds(NEW["OpenRouter key"])
82
+
83
+
84
+ def test_huge_lines_scan_in_linear_time():
85
+ """Minified bundles can have megabyte-long lines; a backtracking regex must not stall the scan."""
86
+ import time
87
+ for line in ("secret" * 100_000, 'api_key="' * 60_000, "awssecret" * 60_000):
88
+ t = time.perf_counter()
89
+ scan_line(line)
90
+ assert time.perf_counter() - t < 3, line[:20]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes