pyproject-api 1.12.2__tar.gz → 1.12.3__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 (48) hide show
  1. pyproject_api-1.12.3/.github/SECURITY.md +51 -0
  2. pyproject_api-1.12.3/.github/THREAT_MODEL.md +101 -0
  3. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/PKG-INFO +1 -1
  4. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/changelog.rst +13 -0
  5. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/_frontend.py +9 -3
  6. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/_version.py +2 -2
  7. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/test_frontend.py +37 -0
  8. pyproject_api-1.12.2/.github/SECURITY.md +0 -9
  9. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/FUNDING.yaml +0 -0
  10. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/dependabot.yaml +0 -0
  11. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/release.yaml +0 -0
  12. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/workflows/check.yaml +0 -0
  13. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/workflows/codeql.yaml +0 -0
  14. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/workflows/news.yaml +0 -0
  15. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/workflows/prepare-release.yaml +0 -0
  16. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/workflows/release.yaml +0 -0
  17. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.github/workflows/upgrade-release-tools.yaml +0 -0
  18. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.gitignore +0 -0
  19. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.pre-commit-config.yaml +0 -0
  20. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/.readthedocs.yml +0 -0
  21. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/CODE_OF_CONDUCT.md +0 -0
  22. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/CONTRIBUTING.md +0 -0
  23. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/LICENSE +0 -0
  24. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/README.md +0 -0
  25. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/api.rst +0 -0
  26. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/changelog.d/.gitkeep +0 -0
  27. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/changelog.d/template.jinja2 +0 -0
  28. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/conf.py +0 -0
  29. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/contributing.rst +0 -0
  30. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/docs/index.rst +0 -0
  31. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/pylock.toml +0 -0
  32. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/pyproject.toml +0 -0
  33. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/__init__.py +0 -0
  34. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/__main__.py +0 -0
  35. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/_backend.py +0 -0
  36. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/_backend.pyi +0 -0
  37. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/_util.py +0 -0
  38. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/_via_fresh_subprocess.py +0 -0
  39. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/src/pyproject_api/py.typed +0 -0
  40. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/_build_sdist.py +0 -0
  41. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/demo_pkg_inline/build.py +0 -0
  42. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/demo_pkg_inline/pyproject.toml +0 -0
  43. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/test_backend.py +0 -0
  44. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/test_frontend_setuptools.py +0 -0
  45. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/test_main.py +0 -0
  46. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/test_util.py +0 -0
  47. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tests/test_version.py +0 -0
  48. {pyproject_api-1.12.2 → pyproject_api-1.12.3}/tox.toml +0 -0
@@ -0,0 +1,51 @@
1
+ # Security policy
2
+
3
+ pyproject-api is a Python library that drives a project's PEP 517 build backend from a separate process. This policy
4
+ says how to report a security problem and how we decide whether a report is one.
5
+
6
+ ## Reporting a vulnerability
7
+
8
+ **Do not open a public issue for a security problem.** Use
9
+ [GitHub's private vulnerability reporting](https://github.com/tox-dev/pyproject-api/security/advisories/new). If neither
10
+ works for you, email [gaborjbernat@gmail.com](mailto:gaborjbernat@gmail.com).
11
+
12
+ Include what the attacker controls and what they gain, the steps or a proof of concept, and the versions and platform
13
+ you tested. Write the report yourself; unreviewed tool or model output takes longer to triage.
14
+
15
+ ## What to expect
16
+
17
+ Volunteers maintain pyproject-api, with no on-call rotation. We aim to acknowledge a report within **5 working days**
18
+ and assess it within **15 working days**. Fixes are developed in a private fork attached to the draft advisory, ship in
19
+ a new release, and the advisory, with a CVE requested through GitHub, goes out with that release. The default embargo is
20
+ **90 days** from the report; we agree any change with the reporter. We credit reporters in the advisory under the name
21
+ they choose, or not at all. There is no bug bounty.
22
+
23
+ ## Supported versions
24
+
25
+ Only the latest release receives fixes. Confirm the problem reproduces on it before reporting.
26
+
27
+ ## Vulnerability or bug
28
+
29
+ A report is a vulnerability when an attacker who controls only an input that the [threat model](THREAT_MODEL.md) lists
30
+ as untrusted breaks a guarantee pyproject-api makes. A report that first needs control of something the threat model
31
+ trusts, such as the project being built and its build backend, is a bug: we fix it in the open and publish no advisory.
32
+ Classify by who supplies the dangerous input, not by how bad the outcome sounds.
33
+
34
+ **In scope**
35
+
36
+ - A `build-system.backend-path` entry that resolves outside the project being accepted as an import location.
37
+ - A frontend call writing a result or artifact outside the directory the caller named, including while extracting
38
+ `.dist-info` from a built wheel.
39
+ - Clearing a metadata directory deleting the project root, one of its ancestors, or anything reached through a symlink
40
+ inside it.
41
+ - A hook result naming a path outside its output directory, returned to the caller as the artifact or metadata path.
42
+ - Results of one backend call being read as another call's, for example through a predictable result file.
43
+
44
+ **Out of scope**
45
+
46
+ - Code a build backend runs: building a project runs its backend, so building untrusted source runs untrusted code, as
47
+ PEP 517 intends.
48
+ - What the backend writes into the artifacts it returns.
49
+ - The interpreter, environment and `requires` the caller provisions for the backend.
50
+
51
+ If you cannot tell which side a finding falls on, report it privately and we will decide.
@@ -0,0 +1,101 @@
1
+ # Threat model
2
+
3
+ This model says what pyproject-api trusts, where untrusted input enters, and which guarantees hold at each boundary, so
4
+ a report can be classified as a vulnerability or a bug. [SECURITY.md](SECURITY.md) covers reporting; if the two
5
+ disagree, SECURITY.md wins and we fix this file.
6
+
7
+ ## How pyproject-api works
8
+
9
+ A frontend such as tox points pyproject-api at a project folder. pyproject-api reads `[build-system]` from
10
+ `pyproject.toml`, checks that every `backend-path` entry stays inside the project, and starts the backend in a
11
+ subprocess of the interpreter the caller chose: `SubprocessFrontend` starts a fresh one per call, while other frontends,
12
+ such as tox's, can keep one alive across calls (`reuse_backend`). Each hook call (`build_wheel`,
13
+ `prepare_metadata_for_build_wheel` and so on) goes to the backend's stdin as JSON, and the backend writes its answer to
14
+ a temporary JSON file that the frontend reads back. Without a metadata hook, pyproject-api builds a wheel and extracts
15
+ its `.dist-info` into the caller's metadata directory.
16
+
17
+ ```mermaid
18
+ flowchart LR
19
+ fe["Frontend, e.g. tox<br/>(trusted)"] -->|project dir, python| api["pyproject-api"]
20
+ api -->|"reads [build-system]"| proj[("Project source")]
21
+ api -->|"spawn, JSON over stdin"| be["Backend subprocess<br/>runs project-chosen code"]
22
+ be -->|"result JSON in temp file,<br/>artifacts in output dir"| api
23
+ classDef trusted fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a;
24
+ classDef boundary fill:#ffe3a3,stroke:#d29200,color:#3a2c00;
25
+ class fe,api trusted;
26
+ class proj,be boundary;
27
+ ```
28
+
29
+ ## Compared with similar tools
30
+
31
+ We drew the boundary where comparable projects in other ecosystems draw theirs. The shared rule, stated by the
32
+ [Node.js threat model](https://github.com/nodejs/node/blob/main/SECURITY.md#the-nodejs-threat-model), is that a report
33
+ which first needs a trusted element compromised is out of scope; the first triage question, as
34
+ [DOMPurify](https://github.com/cure53/DOMPurify/blob/main/SECURITY.md#what-we-consider-a-vulnerability) puts it, is what
35
+ the attacker controls.
36
+
37
+ | Project | Language | Where it draws the line |
38
+ | ----------------------------------------------------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
39
+ | [Cargo build scripts](https://doc.rust-lang.org/cargo/reference/build-scripts.html) | Rust | A package's `build.rs` runs with full rights during a build; building a crate means trusting it. |
40
+ | [Hatch](https://github.com/pypa/hatch/security/policy) | Python | Assumes the user has full control over the build environment. |
41
+ | [pnpm](https://github.com/pnpm/pnpm/security/policy) | JavaScript | Draws its boundary at filesystem permissions: the store, project, lockfile and configuration are trusted, and running it in a repository means trusting that repository. |
42
+
43
+ ## Trusted
44
+
45
+ An attacker who controls any of these already has what pyproject-api could give them:
46
+
47
+ - The frontend and the project folder, interpreter, environment and output directories it passes.
48
+ - The project's build backend and its `requires`; the backend runs with the user's rights.
49
+ - The filesystem and temporary directory.
50
+
51
+ ## Untrusted inputs
52
+
53
+ | Input | Comes from | What pyproject-api guarantees |
54
+ | -------------------------------------------- | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
55
+ | `build-system.backend-path` | The project's `pyproject.toml` | Each entry must be relative and resolve inside the project; otherwise the call fails. |
56
+ | Backend stdout and stderr | The backend and anything it imports | Captured and returned to the caller as text; hook results come only from the result file. |
57
+ | Malformed `[build-system]` | The project's `pyproject.toml` | Wrong types raise a `ValueError` naming the key; a missing table falls back to the legacy setuptools backend, as PEP 517 specifies. |
58
+ | Members of a built wheel | The backend | Only members under a top-level `.dist-info` directory are extracted, through `zipfile`'s path sanitizing. |
59
+ | Entries inside a metadata directory to clear | Earlier builds, or the backend | Refused when it is the project root or one of its ancestors; symlinks inside it are unlinked, never followed. |
60
+
61
+ ## Threats and controls
62
+
63
+ | STRIDE | Threat | Control |
64
+ | ---------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------------ |
65
+ | Tampering | `backend-path = ["../other"]` loads a backend from outside the project. | Entries outside the project are rejected. |
66
+ | Spoofing | Backend output printed to stdout is taken as a hook's result. | Results travel through a per-call temporary JSON file, not stdout. |
67
+ | Elevation of privilege | A backend runs code during a build. | Accepted by design; PEP 517 builds run the project's code. |
68
+
69
+ ## Release chain
70
+
71
+ Releases run on the shared [tox-dev/github-workflows](https://github.com/tox-dev/github-workflows) pipeline. A release
72
+ App, not a person, pushes the release commit and tag; the build installs its tools from a hash-checked `pylock.toml`
73
+ resolved with a seven-day upload cooldown by default; PyPI receives the files through
74
+ [trusted publishing](https://docs.pypi.org/trusted-publishers/) with attestations, and the GitHub Release is immutable.
75
+ Every workflow pins third-party actions to a commit SHA.
76
+
77
+ ## Vulnerability or bug
78
+
79
+ | Report | Verdict | Why |
80
+ | -------------------------------------------------------------------- | ---------------------------------------------------- | ------------------------------------------------------------ |
81
+ | `backend-path` with `../` imports a module from the parent directory | Vulnerability | The in-tree guarantee of PEP 517 is broken. |
82
+ | Building a malicious sdist runs its `setup.py` | Not a vulnerability | The backend is trusted; build untrusted source in a sandbox. |
83
+ | A backend that prints JSON confuses `get_requires_for_build_wheel` | Bug, or vulnerability if the result file is bypassed | Results must come only from the result file. |
84
+
85
+ ## Severity
86
+
87
+ - **High:** a frontend call deletes or writes outside the directory the caller named, or clearing a metadata directory
88
+ removes the project or follows a symlink inside it.
89
+ - **Medium:** a `backend-path` outside the project is accepted, a hook's returned path escapes its directory, or one
90
+ call's result is read as another's.
91
+ - **Low:** a malformed backend response crashes or hangs the frontend instead of failing with an error.
92
+
93
+ ## Accepted risks
94
+
95
+ - Every hook call runs project code; isolation from the host is the caller's job.
96
+ - The backend subprocess inherits the environment the caller passes, secrets included.
97
+
98
+ ## Keeping this current
99
+
100
+ Revisit this model when pyproject-api gains a new input source, network access, a new way to run code, or a new place it
101
+ writes to, and whenever an advisory is published.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pyproject-api
3
- Version: 1.12.2
3
+ Version: 1.12.3
4
4
  Import-Name: pyproject_api
5
5
  Summary: API to interact with the python pyproject.toml based projects
6
6
  Project-URL: Changelog, https://github.com/tox-dev/pyproject-api/blob/main/docs/changelog.rst
@@ -5,6 +5,19 @@ Release History
5
5
 
6
6
  .. towncrier release notes start
7
7
 
8
+ .. _release-1-12-3:
9
+
10
+ v1.12.3 (2026-11-02)
11
+ --------------------
12
+
13
+ .. _release-1-12-3-fixed:
14
+
15
+ Fixed
16
+ ^^^^^
17
+
18
+ - Clear stale files from reused ``.dist-info`` directories when building wheel or editable metadata (:pr:`345`) by
19
+ :user:`subotac` and :user:`gaborbernat`.
20
+
8
21
  .. _release-1-12-2:
9
22
 
10
23
  v1.12.2 (2026-10-28)
@@ -499,9 +499,15 @@ class Frontend(ABC):
499
499
  with ZipFile(str(wheel), "r") as zip_file:
500
500
  for name in zip_file.namelist(): # pragma: no branch
501
501
  root = Path(name).parts[0]
502
- if root.endswith(".dist-info"):
503
- basename = root
504
- zip_file.extract(name, extract_to)
502
+ if not root.endswith(".dist-info"):
503
+ continue
504
+ if basename is None:
505
+ destination: Final[Path] = metadata_directory / root
506
+ if destination.is_symlink(): # pragma: win32 no cover
507
+ destination.unlink()
508
+ ensure_empty_dir(destination)
509
+ basename = root
510
+ zip_file.extract(name, extract_to)
505
511
  if basename is None: # pragma: no branch
506
512
  msg = f"no .dist-info found inside generated wheel {wheel}"
507
513
  raise RuntimeError(msg)
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '1.12.2'
22
- __version_tuple__ = version_tuple = (1, 12, 2)
21
+ __version__ = version = '1.12.3'
22
+ __version_tuple__ = version_tuple = (1, 12, 3)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -610,6 +610,43 @@ def test_metadata_from_built_wheel(
610
610
  assert not err
611
611
 
612
612
 
613
+ @pytest.mark.parametrize("target", [pytest.param("wheel", id="wheel"), pytest.param("editable", id="editable")])
614
+ def test_metadata_from_built_removes_stale_files(
615
+ demo_pkg_inline: Path, tmp_path: Path, target: Literal["wheel", "editable"]
616
+ ) -> None:
617
+ metadata: Final[Path] = tmp_path / "demo_pkg_inline-1.0.0.dist-info"
618
+ metadata.mkdir()
619
+ (metadata / "entry_points.txt").write_text("obsolete entry points")
620
+ (tmp_path / "unrelated.txt").write_text("keep")
621
+
622
+ metadata_path: Final[Path] = SubprocessFrontend(
623
+ *SubprocessFrontend.create_args_from_folder(demo_pkg_inline)[:-1]
624
+ ).metadata_from_built(tmp_path, target)[0]
625
+
626
+ assert {entry.name for entry in metadata_path.iterdir()} == {"top_level.txt", "WHEEL", "RECORD", "METADATA"}
627
+ assert (tmp_path / "unrelated.txt").read_text() == "keep"
628
+
629
+
630
+ @pytest.mark.skipif(sys.platform == "win32", reason="Creating symlinks requires privileges")
631
+ def test_metadata_from_built_replaces_directory_symlink(
632
+ demo_pkg_inline: Path, tmp_path: Path
633
+ ) -> None: # pragma: win32 no cover
634
+ external: Final[Path] = tmp_path / "external"
635
+ external.mkdir()
636
+ (external / "keep.txt").write_text("keep")
637
+ output: Final[Path] = tmp_path / "metadata"
638
+ output.mkdir()
639
+ (output / "demo_pkg_inline-1.0.0.dist-info").symlink_to(external, target_is_directory=True)
640
+
641
+ metadata_path: Final[Path] = SubprocessFrontend(
642
+ *SubprocessFrontend.create_args_from_folder(demo_pkg_inline)[:-1]
643
+ ).metadata_from_built(output, "wheel")[0]
644
+
645
+ assert not metadata_path.is_symlink()
646
+ assert (metadata_path / "METADATA").is_file()
647
+ assert {entry.name: entry.read_text() for entry in external.iterdir()} == {"keep.txt": "keep"}
648
+
649
+
613
650
  def test_bad_wheel_metadata_from_built_wheel(local_builder: Callable[[str], Path]) -> None:
614
651
  txt = """
615
652
  import sys
@@ -1,9 +0,0 @@
1
- # Security Policy
2
-
3
- ## Supported Versions
4
-
5
- Only the latest released version is supported with security updates. Older versions will not receive patches.
6
-
7
- ## Reporting a Vulnerability
8
-
9
- Please report security vulnerabilities via [GitHub's private vulnerability reporting](../../security/advisories/new).
File without changes
File without changes
File without changes