pkgwhy 1.0.0__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 (110) hide show
  1. pkgwhy-1.0.0/.gitignore +10 -0
  2. pkgwhy-1.0.0/CHANGELOG.md +101 -0
  3. pkgwhy-1.0.0/CONTRIBUTING.md +46 -0
  4. pkgwhy-1.0.0/LICENSE +22 -0
  5. pkgwhy-1.0.0/PKG-INFO +688 -0
  6. pkgwhy-1.0.0/README.md +652 -0
  7. pkgwhy-1.0.0/SECURITY.md +71 -0
  8. pkgwhy-1.0.0/docs/dynamic-sandbox.md +119 -0
  9. pkgwhy-1.0.0/docs/json-schema-compatibility.md +37 -0
  10. pkgwhy-1.0.0/docs/production-readiness.md +40 -0
  11. pkgwhy-1.0.0/docs/release-candidate-surface.md +55 -0
  12. pkgwhy-1.0.0/docs/release-checklist.md +80 -0
  13. pkgwhy-1.0.0/docs/static-rule-corpus.md +133 -0
  14. pkgwhy-1.0.0/docs/threat-model.md +58 -0
  15. pkgwhy-1.0.0/docs/versioning-policy.md +44 -0
  16. pkgwhy-1.0.0/pyproject.toml +75 -0
  17. pkgwhy-1.0.0/scripts/check_public_traces.py +154 -0
  18. pkgwhy-1.0.0/src/pkgwhy/__init__.py +3 -0
  19. pkgwhy-1.0.0/src/pkgwhy/__main__.py +6 -0
  20. pkgwhy-1.0.0/src/pkgwhy/agent/__init__.py +2 -0
  21. pkgwhy-1.0.0/src/pkgwhy/agent/judge.py +93 -0
  22. pkgwhy-1.0.0/src/pkgwhy/cli.py +676 -0
  23. pkgwhy-1.0.0/src/pkgwhy/core/__init__.py +2 -0
  24. pkgwhy-1.0.0/src/pkgwhy/core/constants.py +13 -0
  25. pkgwhy-1.0.0/src/pkgwhy/core/models.py +608 -0
  26. pkgwhy-1.0.0/src/pkgwhy/dependencies/__init__.py +2 -0
  27. pkgwhy-1.0.0/src/pkgwhy/dependencies/graph.py +68 -0
  28. pkgwhy-1.0.0/src/pkgwhy/dependencies/reason.py +79 -0
  29. pkgwhy-1.0.0/src/pkgwhy/dynamic/__init__.py +2 -0
  30. pkgwhy-1.0.0/src/pkgwhy/dynamic/analysis.py +156 -0
  31. pkgwhy-1.0.0/src/pkgwhy/explanations/__init__.py +2 -0
  32. pkgwhy-1.0.0/src/pkgwhy/explanations/explain.py +47 -0
  33. pkgwhy-1.0.0/src/pkgwhy/explanations/local_db.py +52 -0
  34. pkgwhy-1.0.0/src/pkgwhy/imports/__init__.py +2 -0
  35. pkgwhy-1.0.0/src/pkgwhy/imports/scanner.py +43 -0
  36. pkgwhy-1.0.0/src/pkgwhy/inspection/__init__.py +2 -0
  37. pkgwhy-1.0.0/src/pkgwhy/inspection/files.py +540 -0
  38. pkgwhy-1.0.0/src/pkgwhy/inspection/python_static.py +323 -0
  39. pkgwhy-1.0.0/src/pkgwhy/inspection/size.py +58 -0
  40. pkgwhy-1.0.0/src/pkgwhy/inspection/text_patterns.py +135 -0
  41. pkgwhy-1.0.0/src/pkgwhy/manifests/__init__.py +2 -0
  42. pkgwhy-1.0.0/src/pkgwhy/manifests/lockfiles.py +51 -0
  43. pkgwhy-1.0.0/src/pkgwhy/manifests/pyproject.py +37 -0
  44. pkgwhy-1.0.0/src/pkgwhy/manifests/requirements.py +27 -0
  45. pkgwhy-1.0.0/src/pkgwhy/metadata/__init__.py +2 -0
  46. pkgwhy-1.0.0/src/pkgwhy/metadata/installed.py +83 -0
  47. pkgwhy-1.0.0/src/pkgwhy/metadata/pypi.py +199 -0
  48. pkgwhy-1.0.0/src/pkgwhy/policy/__init__.py +1 -0
  49. pkgwhy-1.0.0/src/pkgwhy/policy/agent_policy.py +114 -0
  50. pkgwhy-1.0.0/src/pkgwhy/policy/audit_log.py +60 -0
  51. pkgwhy-1.0.0/src/pkgwhy/policy/tool_execution.py +76 -0
  52. pkgwhy-1.0.0/src/pkgwhy/provenance/__init__.py +2 -0
  53. pkgwhy-1.0.0/src/pkgwhy/provenance/installed.py +45 -0
  54. pkgwhy-1.0.0/src/pkgwhy/registry/__init__.py +2 -0
  55. pkgwhy-1.0.0/src/pkgwhy/registry/local.py +178 -0
  56. pkgwhy-1.0.0/src/pkgwhy/registry/manifest.py +78 -0
  57. pkgwhy-1.0.0/src/pkgwhy/registry/publish.py +142 -0
  58. pkgwhy-1.0.0/src/pkgwhy/registry/run.py +148 -0
  59. pkgwhy-1.0.0/src/pkgwhy/registry/tools.py +121 -0
  60. pkgwhy-1.0.0/src/pkgwhy/reports/__init__.py +2 -0
  61. pkgwhy-1.0.0/src/pkgwhy/reports/audit.py +81 -0
  62. pkgwhy-1.0.0/src/pkgwhy/risk/__init__.py +5 -0
  63. pkgwhy-1.0.0/src/pkgwhy/risk/rules.py +372 -0
  64. pkgwhy-1.0.0/src/pkgwhy/risk/scoring.py +231 -0
  65. pkgwhy-1.0.0/src/pkgwhy/typosquat/__init__.py +2 -0
  66. pkgwhy-1.0.0/src/pkgwhy/typosquat/detector.py +182 -0
  67. pkgwhy-1.0.0/src/pkgwhy/typosquat/popular_packages.py +34 -0
  68. pkgwhy-1.0.0/src/pkgwhy/vulnerabilities/__init__.py +2 -0
  69. pkgwhy-1.0.0/src/pkgwhy/vulnerabilities/matching.py +122 -0
  70. pkgwhy-1.0.0/src/pkgwhy/vulnerabilities/osv.py +330 -0
  71. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/extension.so +1 -0
  72. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/helper.exe +1 -0
  73. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/javascript_false_positive.js +2 -0
  74. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/javascript_signals.min.js +1 -0
  75. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/module.wasm +1 -0
  76. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/postinstall +2 -0
  77. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/pyproject.toml +3 -0
  78. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/setup.cfg +2 -0
  79. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/assets/setup.py +7 -0
  80. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/python/deserialisation.py +9 -0
  81. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/python/dynamic_execution.py +9 -0
  82. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/python/encoded_payloads.py +10 -0
  83. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/python/import_trap.py +1 -0
  84. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/python/process_environment_package_manager.py +8 -0
  85. pkgwhy-1.0.0/tests/fixtures/static_rule_corpus/python/url_credential_patterns.py +2 -0
  86. pkgwhy-1.0.0/tests/test_agent_policy.py +93 -0
  87. pkgwhy-1.0.0/tests/test_audit_log.py +52 -0
  88. pkgwhy-1.0.0/tests/test_cli.py +265 -0
  89. pkgwhy-1.0.0/tests/test_dependency_graph.py +73 -0
  90. pkgwhy-1.0.0/tests/test_dynamic.py +95 -0
  91. pkgwhy-1.0.0/tests/test_explanations.py +15 -0
  92. pkgwhy-1.0.0/tests/test_file_static_analysis.py +228 -0
  93. pkgwhy-1.0.0/tests/test_import_scanner.py +11 -0
  94. pkgwhy-1.0.0/tests/test_json_snapshots.py +358 -0
  95. pkgwhy-1.0.0/tests/test_manifests.py +104 -0
  96. pkgwhy-1.0.0/tests/test_provenance.py +173 -0
  97. pkgwhy-1.0.0/tests/test_publish.py +118 -0
  98. pkgwhy-1.0.0/tests/test_python_static.py +116 -0
  99. pkgwhy-1.0.0/tests/test_registry.py +99 -0
  100. pkgwhy-1.0.0/tests/test_reports.py +239 -0
  101. pkgwhy-1.0.0/tests/test_risk.py +106 -0
  102. pkgwhy-1.0.0/tests/test_risk_rules.py +116 -0
  103. pkgwhy-1.0.0/tests/test_runner.py +193 -0
  104. pkgwhy-1.0.0/tests/test_size.py +13 -0
  105. pkgwhy-1.0.0/tests/test_static_rule_corpus.py +131 -0
  106. pkgwhy-1.0.0/tests/test_tool_judgement.py +110 -0
  107. pkgwhy-1.0.0/tests/test_tool_manifest.py +115 -0
  108. pkgwhy-1.0.0/tests/test_tool_policy.py +73 -0
  109. pkgwhy-1.0.0/tests/test_typosquat.py +79 -0
  110. pkgwhy-1.0.0/tests/test_vulnerabilities.py +242 -0
@@ -0,0 +1,10 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.py[cod]
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ pip-wheel-metadata/
@@ -0,0 +1,101 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 - 2026-06-30
4
+
5
+ - Promote the `1.0.0rc1` release-candidate surface to the final 1.0.0 tracked codebase after local release-prep review.
6
+ - Freeze the 1.0.0 feature surface for package intelligence, static rule evidence, vulnerability/provenance decision support, agent policy JSON, local registry/runner safety, and release-process documentation.
7
+ - Keep dynamic analysis explicitly experimental and outside the stable security decision surface for this release.
8
+ - Align README, SECURITY, package metadata, and version metadata for final local `1.0.0` validation.
9
+ - Harden release validation with artifact trace scanning, cache metadata validation, Markdown audit warnings, hermetic JSON snapshots, and exact rule catalog membership tests.
10
+ - Align final release wording and package classifier for local 1.0.0 hardening.
11
+ - Harden final review checks for offline-first documentation, trace path matching, dynamic boundary wording, Markdown escaping, static corpus import traps, and rule-category ordering.
12
+
13
+ ## 0.9.5a0 - Unreleased pre-alpha
14
+
15
+ - Add release checklist, versioning policy, threat model, and production-readiness blocker documentation.
16
+ - Improve public responsible disclosure guidance without configuring external services or secrets.
17
+ - Link release/process documentation from README, SECURITY, and CONTRIBUTING.
18
+ - Add CI CLI smoke checks and public trace hygiene scanning without publishing secrets or deployment steps.
19
+ - Align local package metadata for the `0.9.5a0` release/process hardening candidate.
20
+
21
+ ## 0.9.0a0 - Unreleased pre-alpha
22
+
23
+ - Keep dynamic analysis experimental for this release, with no production sandboxing claim.
24
+ - Keep `pkgwhy dynamic inspect` as a safe-fail CLI skeleton that refuses host execution of unknown package code and does not invoke Docker or run containers.
25
+ - Add tests that assert the dynamic result warnings and limitations carry the explicit experimental boundary.
26
+ - Align README, SECURITY, CLI help, and local package metadata for the `0.9.0a0` dynamic-analysis boundary.
27
+
28
+ ## 0.8.0a0 - Unreleased pre-alpha
29
+
30
+ - Start static rule corpus/schema hardening with a versioned static rule catalog snapshot.
31
+ - Add stable rule ID ordering helpers and tests to catch accidental rule renames, removals, or reordering.
32
+ - Add static rule corpus documentation covering rule categories, rule families, fixture strategy, and compatibility expectations.
33
+ - Add controlled Python static-signal corpus fixtures for dynamic execution, dynamic imports, deserialisation, encoded payloads, subprocess/package-manager use, environment access, URL/domain extraction, and credential masking.
34
+ - Add controlled JavaScript, native, WASM, shell, and build-file corpus fixtures with false-positive coverage for JavaScript call-like substrings.
35
+ - Add normalized golden JSON snapshot tests and schema compatibility policy documentation for agent-facing package, audit, precheck, and tool judgement output.
36
+ - Document static rule ID lifecycle, evidence location expectations, corpus fixture coverage, and false-positive/false-negative limitations.
37
+ - Harden OSV response decoding, audited-version PyPI provenance status, rule catalog snapshots, and JSON/static corpus regression tests.
38
+
39
+ ## 0.7.0a0 - Unreleased pre-alpha
40
+
41
+ - Harden explicit OSV.dev audit lookups with a local response cache, stale-cache fallback, cache status warnings, and continued offline-by-default behavior.
42
+ - Keep vulnerability matching conservative by treating OSV `limit` events as upper bounds, not fixed-version recommendations.
43
+ - Add advisory source URL evidence to known-vulnerability matches and audit-level vulnerability/provenance source summaries.
44
+ - Bump audit JSON output to `pkgwhy.audit.v2` for the expanded source summary fields.
45
+ - Add optional `pkgwhy audit --pypi` provenance lookup from PyPI JSON without inferring Trusted Publishing or attestation status.
46
+ - Report PyPI source distribution presence only when PyPI file metadata actually lists a source archive.
47
+ - Add tests for OSV parsing, matching, caching, source attribution, PyPI provenance, and audit integration.
48
+ - Document that cached advisory data can be stale and that missing vulnerability matches are not proof of safety.
49
+
50
+ ## 0.6.0a0 - Unreleased pre-alpha
51
+
52
+ - Add schema-versioned agent policy defaults with conservative non-interactive decisions for package use.
53
+ - Add `pkgwhy agent policy`, `pkgwhy agent precheck <package> --json`, and package-focused `pkgwhy agent judge <package> --json`.
54
+ - Add schema-versioned agent package precheck output that embeds the package judgement and records policy reasons.
55
+ - Add compact local agent decision logs that omit full package evidence.
56
+ - Harden local registry publish and judgement paths by failing closed on corrupt registry indexes.
57
+ - Block duplicate owner/name/version publishes instead of silently replacing existing registry entries.
58
+ - Reject symlinked tool bundle members during local publish and keep stored registry paths bounded to the registry root during tool judgement.
59
+ - Add `pkgwhy run --non-interactive` to apply stricter tool execution policy from the CLI.
60
+ - Include successful pre-run policy decision, reasons, and warnings in local tool execution logs.
61
+ - Continue to treat signatures as `not_implemented` and virtual environments as dependency isolation only, not OS sandboxing.
62
+
63
+ ## 0.5.0a0 - Unreleased pre-alpha
64
+
65
+ - Start the experimental dynamic sandbox design phase without enabling arbitrary dynamic package execution.
66
+ - Add a dynamic sandbox threat model covering static-vs-dynamic boundaries, no-host-execution defaults, network-off defaults, scratch filesystem expectations, no-secrets constraints, event model goals, and current limitations.
67
+ - Add a safe-fail `pkgwhy dynamic inspect` command skeleton that refuses host execution until a sandbox backend exists.
68
+ - Add schema-versioned dynamic analysis result models with empty event lists unless a backend actually observes events.
69
+ - Add controlled fixture-only dynamic execution test support that runs only local test fixtures under a fixture root with a scratch working directory and minimal environment.
70
+ - Add a Docker executable detection boundary for the future container backend without invoking Docker or running containers.
71
+ - Document that missing sandbox backends must fail safely rather than falling back to host execution.
72
+
73
+ ## 0.4.0a0 - Unreleased pre-alpha
74
+
75
+ - Add stronger static-analysis rule evidence while keeping `pkgwhy` in pre-alpha decision-support positioning.
76
+ - Add structured file/line/symbol evidence for Python dynamic execution, dynamic imports, deserialisation-risk APIs, unsafe YAML load, encoded-payload handling, subprocess/shell execution, environment/secret-like references, and package-manager manipulation.
77
+ - Add static setup/build-file analysis for `setup.py`, `setup.cfg`, and `pyproject.toml` build-backend metadata without running build scripts.
78
+ - Add source URL/domain extraction as evidence only, with explicit false-positive notes.
79
+ - Add conservative credential-like assignment detection with suspicious values masked in output.
80
+ - Add JavaScript rule evidence for minification/density, dynamic execution, encoded-payload handling, source-map references, and obfuscation-like patterns.
81
+ - Add native extension, executable, and WASM binary rule evidence while documenting that these artifacts are not automatically malicious.
82
+ - Surface compact rule-evidence summaries in human `inspect`, `risk`, and `judge` output while preserving schema-versioned JSON judgement output.
83
+
84
+ ## 0.3.0a0 - Unreleased pre-alpha
85
+
86
+ - Add a vulnerability/provenance/risk-model foundation while keeping `pkgwhy` in pre-alpha decision-support positioning.
87
+ - Add OSV-like vulnerability record models, parser, explicit OSV.dev client boundary, and conservative version-range matching.
88
+ - Add optional `pkgwhy audit --vulnerability-file` support for controlled local advisory data and explicit `pkgwhy audit --osv` support for live OSV.dev lookup.
89
+ - Add metadata-derived provenance/source-trust summaries to package judgement JSON, with Trusted Publishing, attestation verification, and sdist/wheel comparison marked as unknown or not implemented.
90
+ - Add `pkgwhy.risk_model.v1`, rule IDs, rule severity, confidence, and evidence fields to package judgement JSON.
91
+ - Document that vulnerability databases can be incomplete and that missing vulnerability matches are not proof of safety.
92
+
93
+ ## 0.2.0a0 - Unreleased pre-alpha
94
+
95
+ - Prepare the first PyPI/TestPyPI developer-preview candidate with the local registry and runner MVP included.
96
+ - Add GitHub repository, homepage, issue, and changelog metadata for `https://github.com/devlukeg/pkgwhy`.
97
+ - Start local package intelligence foundation with `scan`, `explain`, `why`, `inspect`, and `judge --json`.
98
+ - Add metadata-first inspection, package-size scanning, AST-only Python capability signals, dependency classification, and conservative judgement models.
99
+ - Add local registry, local publish, local tool inspect/judge, and local `pkgwhy run` MVP with hash verification, per-tool virtual environments, execution logs, and explicit non-sandboxing warning.
100
+ - Add initial local tool execution policy checks for hash verification, non-interactive defaults, unsupported execution modes, unsigned-tool warnings, and deferred dependency installation.
101
+ - Document that results are static evidence and decision support, not proof of package safety or malware certainty.
@@ -0,0 +1,46 @@
1
+ # Contributing
2
+
3
+ `pkgwhy` is in the 1.0.0 release line. Small, focused issues and pull requests are easiest to review.
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ python -m venv .venv
9
+ .venv/bin/python -m pip install -e ".[dev]"
10
+ .venv/bin/python -m pytest
11
+ ```
12
+
13
+ ## Engineering Expectations
14
+
15
+ - Inspection code should read metadata, package files, text, and AST without importing or executing inspected package code.
16
+ - Keep inspection paths separate from the explicit `pkgwhy run` execution path for local private tools.
17
+ - Keep agent policy decisions separate from package inspection and local tool execution.
18
+ - Prefer static metadata, file, text, and AST analysis.
19
+ - Use conservative security language.
20
+ - Malware, source availability, vulnerability, risk, signature, hash, and review claims should be backed by evidence from the implementation or the cited source.
21
+ - Full sandboxing should be described only for isolation that is actually implemented and tested.
22
+ - Keep JSON output stable for agent workflows.
23
+ - Keep release, publishing, repository visibility, and distribution changes out of ordinary feature pull requests.
24
+
25
+ ## Before Submitting Changes
26
+
27
+ Run:
28
+
29
+ ```bash
30
+ .venv/bin/python -m pytest
31
+ git diff --check
32
+ .venv/bin/python -m pkgwhy --help
33
+ .venv/bin/python -m pkgwhy agent policy --help
34
+ .venv/bin/python -m pkgwhy registry --help
35
+ .venv/bin/python -m pkgwhy run --help
36
+ .venv/bin/python -m build
37
+ .venv/bin/python -m twine check dist/*
38
+ ```
39
+
40
+ For release work, also follow [docs/release-checklist.md](docs/release-checklist.md), [docs/versioning-policy.md](docs/versioning-policy.md), and [docs/production-readiness.md](docs/production-readiness.md).
41
+
42
+ Publishing automation, external services, payment processing, secrets, and cloud backends are not included in this release line.
43
+
44
+ Repository: <https://github.com/devlukeg/pkgwhy>
45
+
46
+ Issues: <https://github.com/devlukeg/pkgwhy/issues>
pkgwhy-1.0.0/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luke Gerakiteys
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+