Skip to content

Commit 66f91ad

Browse files
daniel-rdttgilon
andauthored
fix: 11 - add validation of Zenodo API URL and deposition_id (#780)
* feat: add validation of Zenodo API URL and deposition_id * improve wording * doc: add release note * fix: remove redundant validation of API_URL * Update doc/release_notes.md Co-authored-by: Thomas Gilon <thomas.gilon@openenergytransition.org> * doc: fix formatting of release note --------- Co-authored-by: Thomas Gilon <thomas.gilon@openenergytransition.org>
1 parent 5451caa commit 66f91ad

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

doc/release_notes.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@
3737

3838
* Update benchmarking documentation tables and figures for v0.7.1 ([#711](https://github.com/open-energy-transition/open-tyndp/pull/711)).
3939

40-
* Migrate the Sphinx/RST-based documentation to MkDocs/Markdown, as a follow-up to the [upstream migration](https://github.com/PyPSA/pypsa-eur/pull/2162) ([754](https://github.com/open-energy-transition/open-tyndp/pull/754)).
40+
* Migrate the Sphinx/RST-based documentation to MkDocs/Markdown, as a follow-up to the [upstream migration](https://github.com/PyPSA/pypsa-eur/pull/2162) ([#754](https://github.com/open-energy-transition/open-tyndp/pull/754)).
4141

4242
**Developers Note**
4343

4444
* Change GitHub issue templates to comply with ISO security checks ([#714](https://github.com/open-energy-transition/open-tyndp/pull/714), [#730](https://github.com/open-energy-transition/open-tyndp/pull/730)).
4545

46-
* Introduce SBOM/Grype vulnerability scanning workflow, as a follow-up to the [upstream addition](https://github.com/PyPSA/pypsa-eur/pull/2164) ([754](https://github.com/open-energy-transition/open-tyndp/pull/754)).
46+
* Introduce SBOM/Grype vulnerability scanning workflow, as a follow-up to the [upstream addition](https://github.com/PyPSA/pypsa-eur/pull/2164) ([#754](https://github.com/open-energy-transition/open-tyndp/pull/754)).
4747

48-
* Ensure `inflow_t` is always defined in `attach_hydro`, resolving a pylint use-before-assignment issue ([777](https://github.com/open-energy-transition/open-tyndp/pull/777)).
48+
* Ensure `inflow_t` is always defined in `attach_hydro`, resolving a pylint use-before-assignment issue ([#777](https://github.com/open-energy-transition/open-tyndp/pull/777)).
4949

50-
* Add missing regex anchors with `re.fullmatch` to `create_zenodo_deposition_cli` utils script ([778](https://github.com/open-energy-transition/open-tyndp/pull/778)).
50+
* Add missing regex anchors with `re.fullmatch` to `create_zenodo_deposition_cli` utils script ([#778](https://github.com/open-energy-transition/open-tyndp/pull/778)).
51+
52+
* Add validation of Zenodo deposition ID in `create_zenodo_deposition_cli` to close URL-manipulation finding ([#780](https://github.com/open-energy-transition/open-tyndp/pull/780)).
5153

5254

5355
## Upcoming PyPSA-Eur Release

utils/create_zenodo_deposition_cli.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,13 @@ def publish_zenodo_deposition(deposition_id: int) -> requests.Response:
310310
Response
311311
The response from the Zenodo API after publishing the deposition.
312312
"""
313+
# Validate id to be positive integer (rejecting bool, int-like strings and traversals)
314+
if (
315+
isinstance(deposition_id, bool)
316+
or not isinstance(deposition_id, int)
317+
or deposition_id <= 0
318+
):
319+
raise ValueError(f"Invalid Zenodo deposition ID: {deposition_id!r}")
313320
r = requests.post(
314321
f"{ZENODO_API_URL}/deposit/depositions/{deposition_id}/actions/publish",
315322
params={"access_token": ZENODO_API_KEY},

0 commit comments

Comments
 (0)