karnak-scan 0.2.0__py3-none-any.whl

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 (47) hide show
  1. karnak_scan/__init__.py +19 -0
  2. karnak_scan/__main__.py +7 -0
  3. karnak_scan/app.py +48 -0
  4. karnak_scan/cli.py +1055 -0
  5. karnak_scan/core/__init__.py +3 -0
  6. karnak_scan/core/cache.py +584 -0
  7. karnak_scan/core/context.py +247 -0
  8. karnak_scan/core/engine.py +319 -0
  9. karnak_scan/core/finding.py +200 -0
  10. karnak_scan/core/git.py +186 -0
  11. karnak_scan/core/heuristics.py +299 -0
  12. karnak_scan/core/http.py +868 -0
  13. karnak_scan/core/redact.py +120 -0
  14. karnak_scan/core/rules.py +275 -0
  15. karnak_scan/core/suppress.py +393 -0
  16. karnak_scan/core/textutil.py +39 -0
  17. karnak_scan/core/walker.py +453 -0
  18. karnak_scan/modules/__init__.py +17 -0
  19. karnak_scan/modules/artifacts.py +407 -0
  20. karnak_scan/modules/cicd.py +461 -0
  21. karnak_scan/modules/deps.py +1840 -0
  22. karnak_scan/modules/githist.py +259 -0
  23. karnak_scan/modules/patterns.py +1824 -0
  24. karnak_scan/modules/secrets.py +254 -0
  25. karnak_scan/report/__init__.py +45 -0
  26. karnak_scan/report/html.py +386 -0
  27. karnak_scan/report/json_out.py +151 -0
  28. karnak_scan/report/payload.py +497 -0
  29. karnak_scan/report/sarif.py +426 -0
  30. karnak_scan/report/terminal.py +586 -0
  31. karnak_scan/rules/patterns_compiled.json +308 -0
  32. karnak_scan/rules/patterns_generic.json +182 -0
  33. karnak_scan/rules/patterns_iac.json +240 -0
  34. karnak_scan/rules/patterns_javascript.json +314 -0
  35. karnak_scan/rules/patterns_scripting.json +319 -0
  36. karnak_scan/rules/secrets.json +567 -0
  37. karnak_scan/ui.py +674 -0
  38. karnak_scan/web/__init__.py +1 -0
  39. karnak_scan/web/brand.py +273 -0
  40. karnak_scan/web/server.py +661 -0
  41. karnak_scan-0.2.0.dist-info/METADATA +356 -0
  42. karnak_scan-0.2.0.dist-info/RECORD +47 -0
  43. karnak_scan-0.2.0.dist-info/WHEEL +5 -0
  44. karnak_scan-0.2.0.dist-info/entry_points.txt +3 -0
  45. karnak_scan-0.2.0.dist-info/licenses/LICENSE +202 -0
  46. karnak_scan-0.2.0.dist-info/licenses/NOTICE +4 -0
  47. karnak_scan-0.2.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,19 @@
1
+ """Karnak - a security reconnaissance tool for codebases and the surface they expose.
2
+
3
+ Four scan surfaces, one CLI:
4
+
5
+ * source analysis (hardcoded secrets, dangerous patterns)
6
+ * repository and supply chain (git history, dependencies, CI/CD, committed artifacts)
7
+ * attack surface derived from the code (routes, handlers, auth coverage)
8
+ * live target reconnaissance (DNS, TLS, HTTP, open ports) - gated behind explicit
9
+ authorization and a mandatory scope allowlist
10
+
11
+ Deliberately dependency-free: the core runs on the standard library alone, because a
12
+ security tool needs to work on a locked-down box you do not control. `rich` and `PyYAML`
13
+ are used when present and fall back cleanly when not.
14
+ """
15
+
16
+ from __future__ import annotations
17
+
18
+ __version__ = "0.2.0"
19
+ __all__ = ["__version__"]
@@ -0,0 +1,7 @@
1
+ """`python -m karnak_scan ...`, the same as the `karnak` command."""
2
+
3
+ import sys
4
+
5
+ from .cli import main
6
+
7
+ sys.exit(main())
karnak_scan/app.py ADDED
@@ -0,0 +1,48 @@
1
+ """Entry point for the double-click app (the PyInstaller build in packaging/).
2
+
3
+ Double-clicked, there are no arguments: it opens `karnak ui` in the browser, starting at
4
+ the user's home folder, and stops by itself once the page has been closed for a while,
5
+ because there may be no terminal to press Ctrl+C in. Given arguments, the same file is
6
+ the full command line (`Karnak.exe code . --html report.html`), which is also how CI
7
+ smoke-tests a build without a browser.
8
+ """
9
+
10
+ from __future__ import annotations
11
+
12
+ import sys
13
+ from pathlib import Path
14
+ from typing import List, Optional, Sequence
15
+
16
+ # Long enough to read a report in another tab and come back; short enough that a
17
+ # forgotten app does not run all day. The page's heartbeat keeps it alive while open.
18
+ IDLE_TIMEOUT_SECONDS = 15 * 60
19
+
20
+
21
+ def _user_args(argv: Sequence[str]) -> List[str]:
22
+ # macOS can pass a process serial number (-psn_0_12345) to apps opened from Finder.
23
+ return [a for a in argv if not a.startswith("-psn_")]
24
+
25
+
26
+ def main(argv: Optional[Sequence[str]] = None) -> int:
27
+ args = _user_args(sys.argv[1:] if argv is None else argv)
28
+ if args:
29
+ from .cli import main as cli_main
30
+
31
+ return cli_main(args)
32
+
33
+ from .ui import serve
34
+
35
+ return serve(
36
+ Path.home(),
37
+ open_browser=True,
38
+ stream=sys.stdout,
39
+ idle_timeout=IDLE_TIMEOUT_SECONDS,
40
+ how_to_stop=(
41
+ "Use the Quit button in the page, or close this window. It also stops by "
42
+ "itself 15 minutes after the page is closed."
43
+ ),
44
+ )
45
+
46
+
47
+ if __name__ == "__main__":
48
+ raise SystemExit(main())