repovet 0.1.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 (76) hide show
  1. repovet/__init__.py +3 -0
  2. repovet/__main__.py +6 -0
  3. repovet/analyzers/__init__.py +56 -0
  4. repovet/analyzers/agents.py +11 -0
  5. repovet/analyzers/autorun.py +14 -0
  6. repovet/analyzers/binaries.py +11 -0
  7. repovet/analyzers/dependencies.py +11 -0
  8. repovet/analyzers/download_exec.py +11 -0
  9. repovet/analyzers/obfuscation.py +11 -0
  10. repovet/analyzers/provenance.py +706 -0
  11. repovet/analyzers/trust.py +765 -0
  12. repovet/cli.py +498 -0
  13. repovet/data/SOURCES.md +72 -0
  14. repovet/data/languages.yaml +69 -0
  15. repovet/data/npm-top.txt +15916 -0
  16. repovet/data/provenance.yaml +129 -0
  17. repovet/data/pypi-top.txt +15006 -0
  18. repovet/data/trust.yaml +65 -0
  19. repovet/engine/__init__.py +1 -0
  20. repovet/engine/checks/__init__.py +37 -0
  21. repovet/engine/checks/base.py +436 -0
  22. repovet/engine/checks/blob.py +238 -0
  23. repovet/engine/checks/dependency.py +179 -0
  24. repovet/engine/checks/filename.py +48 -0
  25. repovet/engine/checks/import_ref.py +96 -0
  26. repovet/engine/checks/keypath.py +202 -0
  27. repovet/engine/checks/magic.py +115 -0
  28. repovet/engine/checks/metric.py +109 -0
  29. repovet/engine/checks/python_ast.py +113 -0
  30. repovet/engine/checks/regex.py +97 -0
  31. repovet/engine/checks/tree.py +91 -0
  32. repovet/engine/checks/unicode.py +257 -0
  33. repovet/engine/context.py +47 -0
  34. repovet/engine/loader.py +449 -0
  35. repovet/engine/runner.py +152 -0
  36. repovet/github/__init__.py +1 -0
  37. repovet/github/api.py +93 -0
  38. repovet/github/client.py +381 -0
  39. repovet/github/target.py +50 -0
  40. repovet/github/transport.py +53 -0
  41. repovet/limits.py +58 -0
  42. repovet/models.py +166 -0
  43. repovet/parsers/__init__.py +1 -0
  44. repovet/parsers/gitconfig.py +116 -0
  45. repovet/parsers/jsonc.py +36 -0
  46. repovet/parsers/manifests.py +345 -0
  47. repovet/parsers/structured.py +176 -0
  48. repovet/report/__init__.py +1 -0
  49. repovet/report/common.py +32 -0
  50. repovet/report/json_out.py +77 -0
  51. repovet/report/sanitize.py +67 -0
  52. repovet/report/sarif.py +181 -0
  53. repovet/report/terminal.py +227 -0
  54. repovet/rules/_filesets.yaml +287 -0
  55. repovet/rules/_patterns.yaml +53 -0
  56. repovet/rules/_unsupported.yaml +94 -0
  57. repovet/rules/agents.yaml +579 -0
  58. repovet/rules/autorun.yaml +1176 -0
  59. repovet/rules/binaries.yaml +276 -0
  60. repovet/rules/dependencies.yaml +179 -0
  61. repovet/rules/download_exec.yaml +130 -0
  62. repovet/rules/obfuscation.yaml +261 -0
  63. repovet/rules/provenance.yaml +204 -0
  64. repovet/rules/trust.yaml +272 -0
  65. repovet/sources/__init__.py +1 -0
  66. repovet/sources/gitmeta.py +271 -0
  67. repovet/sources/gitobjects.py +341 -0
  68. repovet/sources/gittree.py +152 -0
  69. repovet/sources/local.py +239 -0
  70. repovet/sources/remote.py +320 -0
  71. repovet/sources/tree.py +140 -0
  72. repovet-0.1.0.dist-info/METADATA +503 -0
  73. repovet-0.1.0.dist-info/RECORD +76 -0
  74. repovet-0.1.0.dist-info/WHEEL +4 -0
  75. repovet-0.1.0.dist-info/entry_points.txt +2 -0
  76. repovet-0.1.0.dist-info/licenses/LICENSE +21 -0
repovet/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """repovet: static check of an untrusted Git repository before anything from it runs."""
2
+
3
+ __version__ = "0.1.0"
repovet/__main__.py ADDED
@@ -0,0 +1,6 @@
1
+ """Entry point for ``python -m repovet``."""
2
+
3
+ from repovet.cli import main
4
+
5
+ if __name__ == "__main__":
6
+ raise SystemExit(main())
@@ -0,0 +1,56 @@
1
+ """Analyzers, one module per area. Contract: ``analyze(ctx) -> AreaResult``."""
2
+
3
+ from collections.abc import Callable
4
+
5
+ from repovet.analyzers import (
6
+ agents,
7
+ autorun,
8
+ binaries,
9
+ dependencies,
10
+ download_exec,
11
+ obfuscation,
12
+ provenance,
13
+ trust,
14
+ )
15
+ from repovet.engine.context import ScanContext
16
+ from repovet.engine.runner import prepare_file_rules, run_rules
17
+ from repovet.models import AREAS, AreaResult, CoverageStatus
18
+
19
+ type Analyzer = Callable[[ScanContext], AreaResult]
20
+
21
+ ANALYZERS: dict[str, Analyzer] = {
22
+ autorun.AREA: autorun.analyze,
23
+ agents.AREA: agents.analyze,
24
+ obfuscation.AREA: obfuscation.analyze,
25
+ download_exec.AREA: download_exec.analyze,
26
+ binaries.AREA: binaries.analyze,
27
+ dependencies.AREA: dependencies.analyze,
28
+ provenance.AREA: provenance.analyze,
29
+ trust.AREA: trust.analyze,
30
+ }
31
+
32
+
33
+ def run_all(ctx: ScanContext) -> list[AreaResult]:
34
+ """Run every implemented area; record the others as not implemented.
35
+
36
+ Rules from ``--rules`` folders for an area without its own module still run
37
+ through the engine.
38
+ """
39
+ results: list[AreaResult] = []
40
+ # One pass over the files for the file rules of every area and the profile.
41
+ prepare_file_rules(ctx.rules.active(), ctx, [provenance.start_observing(ctx)])
42
+ for name, info in AREAS.items():
43
+ analyzer = ANALYZERS.get(name)
44
+ if analyzer is not None:
45
+ result = analyzer(ctx)
46
+ ctx.facts.update(result.facts)
47
+ results.append(result)
48
+ continue
49
+ ctx.coverage.add(
50
+ f"area:{name}",
51
+ CoverageStatus.NOT_IMPLEMENTED,
52
+ f"{name} ({info.label}): not implemented yet (milestone {info.milestone})",
53
+ )
54
+ if ctx.rules.active(name):
55
+ results.append(AreaResult(name, run_rules(ctx.rules.active(name), ctx)))
56
+ return results
@@ -0,0 +1,11 @@
1
+ """Area ``agents``: instructions and configuration for AI coding agents."""
2
+
3
+ from repovet.engine.context import ScanContext
4
+ from repovet.engine.runner import run_rules
5
+ from repovet.models import AreaResult
6
+
7
+ AREA = "agents"
8
+
9
+
10
+ def analyze(ctx: ScanContext) -> AreaResult:
11
+ return AreaResult(AREA, run_rules(ctx.rules.active(AREA), ctx))
@@ -0,0 +1,14 @@
1
+ """Area ``autorun``: code that tools run automatically (install, build, IDE, Git, shell)."""
2
+
3
+ from repovet.engine.context import ScanContext
4
+ from repovet.engine.runner import record_unsupported, run_rules
5
+ from repovet.models import AreaResult
6
+
7
+ AREA = "autorun"
8
+
9
+
10
+ def analyze(ctx: ScanContext) -> AreaResult:
11
+ findings = run_rules(ctx.rules.active(AREA), ctx)
12
+ # Auto-run surfaces that repovet recognizes but does not analyze (_unsupported.yaml).
13
+ record_unsupported(ctx)
14
+ return AreaResult(AREA, findings)
@@ -0,0 +1,11 @@
1
+ """Area ``binaries``: executables, archives, macros and file-system tricks."""
2
+
3
+ from repovet.engine.context import ScanContext
4
+ from repovet.engine.runner import run_rules
5
+ from repovet.models import AreaResult
6
+
7
+ AREA = "binaries"
8
+
9
+
10
+ def analyze(ctx: ScanContext) -> AreaResult:
11
+ return AreaResult(AREA, run_rules(ctx.rules.active(AREA), ctx))
@@ -0,0 +1,11 @@
1
+ """Area ``dependencies``: lookalike names, foreign sources and package indexes."""
2
+
3
+ from repovet.engine.context import ScanContext
4
+ from repovet.engine.runner import run_rules
5
+ from repovet.models import AreaResult
6
+
7
+ AREA = "dependencies"
8
+
9
+
10
+ def analyze(ctx: ScanContext) -> AreaResult:
11
+ return AreaResult(AREA, run_rules(ctx.rules.active(AREA), ctx))
@@ -0,0 +1,11 @@
1
+ """Area ``download_exec``: code that downloads something and runs it."""
2
+
3
+ from repovet.engine.context import ScanContext
4
+ from repovet.engine.runner import run_rules
5
+ from repovet.models import AreaResult
6
+
7
+ AREA = "download_exec"
8
+
9
+
10
+ def analyze(ctx: ScanContext) -> AreaResult:
11
+ return AreaResult(AREA, run_rules(ctx.rules.active(AREA), ctx))
@@ -0,0 +1,11 @@
1
+ """Area ``obfuscation``: code that hides what it does (encoded blobs, packers, invisible text)."""
2
+
3
+ from repovet.engine.context import ScanContext
4
+ from repovet.engine.runner import run_rules
5
+ from repovet.models import AreaResult
6
+
7
+ AREA = "obfuscation"
8
+
9
+
10
+ def analyze(ctx: ScanContext) -> AreaResult:
11
+ return AreaResult(AREA, run_rules(ctx.rules.active(AREA), ctx))