[toolchain] Upload published toolchains with --upload - #38688
[toolchain] Upload published toolchains with --upload#38688cdesouza-chromium wants to merge 1 commit into
--upload#38688Conversation
This change unifies the model of how the different toolchain scripts upload their toolchains, with all of them now providing a `--upload` option to upload the produced tarball. Additionally, this script further flattens the code under `tools/cr/toolchains`. Bug: brave/brave-browser#55812
|
[puLL-Merge] - brave/brave-core@38688 DescriptionRefactors toolchain publishing across three builders (Rust, Windows, Xcode). Extracts shared plumbing into new Replaces per-platform aggregating index (chronological list, one file per platform+upstream combo) with per-build sibling index (single mapping, one file per exact Rust builder gains Motivation: consistency across three near-identical publishing paths; simpler uniqueness model (bump subrevision vs. index collision matrix). Possible Issues
Changes
|
|
Warning You have got a presubmit warning. Please address it if possible. Items: |
📋 Code Owners Summary12 file(s) changed, 12 with assigned owners 1 team(s) affected: Owners and Their Files
|
| "absent". | ||
| """ | ||
| try: | ||
| with urllib.request.urlopen(url, timeout=timeout): |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] Detected a dynamic value being used with urllib. urllib supports 'file://' schemes, so a dynamic value controlled by a malicious actor may allow them to read arbitrary files. Audit uses of urllib calls to ensure user data cannot control the URLs, or consider using the 'requests' library instead.
Source: https://semgrep.dev/r/python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected
Cc @thypon
Please consider an alternative approach that avoids this security concern, or request a review from the sec-team on slack.
| "absent". | ||
| """ | ||
| try: | ||
| with urllib.request.urlopen(url, timeout=timeout): |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] The application was found passing in a non-literal value to the urllib methods which issue
requests. urllib supports the file:// scheme, which may allow an adversary who can control
the URL value to read arbitrary files on the file system.
To remediate this issue either hardcode the URLs being used in urllib or use the requests
module instead.
Example using the requests module to issue an HTTPS request:<br/>import requests<br/># Issue a GET request to https://example.com with a timeout of 10 seconds<br/>response = requests.get('https://example.com', timeout=10)<br/># Work with the response object<br/># ...<br/>
Source: https://semgrep.dev/r/gitlab.bandit.B310-1
Cc @thypon
Please consider an alternative approach that avoids this security concern, or request a review from the sec-team on slack.
| """ | ||
| logging.debug('Fetching %s index %s', description, index_url) | ||
| try: | ||
| with urllib.request.urlopen(index_url, timeout=timeout) as response: |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] Detected a dynamic value being used with urllib. urllib supports 'file://' schemes, so a dynamic value controlled by a malicious actor may allow them to read arbitrary files. Audit uses of urllib calls to ensure user data cannot control the URLs, or consider using the 'requests' library instead.
Source: https://semgrep.dev/r/python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected
Cc @thypon
Please consider an alternative approach that avoids this security concern, or request a review from the sec-team on slack.
| """ | ||
| logging.debug('Fetching %s index %s', description, index_url) | ||
| try: | ||
| with urllib.request.urlopen(index_url, timeout=timeout) as response: |
There was a problem hiding this comment.
reported by reviewdog 🐶
[opengrep] The application was found passing in a non-literal value to the urllib methods which issue
requests. urllib supports the file:// scheme, which may allow an adversary who can control
the URL value to read arbitrary files on the file system.
To remediate this issue either hardcode the URLs being used in urllib or use the requests
module instead.
Example using the requests module to issue an HTTPS request:<br/>import requests<br/># Issue a GET request to https://example.com with a timeout of 10 seconds<br/>response = requests.get('https://example.com', timeout=10)<br/># Work with the response object<br/># ...<br/>
Source: https://semgrep.dev/r/gitlab.bandit.B310-1
Cc @thypon
Please consider an alternative approach that avoids this security concern, or request a review from the sec-team on slack.
| """Write the sibling YAML index describing the just-built archive. | ||
|
|
||
| Each entry in the index has these fields: | ||
| Unlike a shared, ever-growing index, this writes one index per build, |
There was a problem hiding this comment.
nit: "Unlike a shared, ever-growing index... rather than an aggregated list" only makes sense if you know what this replaced — a first-time reader has no such context. Describing it positively ("Writes one index per build, holding a single mapping...") also fixes the dangling "Each has these fields", which reads as a leftover from "Each entry in the index". (✅ Comments Must Make Sense to Future Readers of the Codebase)
| f'{toolchain.build_rust_toolchain.TOOLCHAIN_BUCKET_URL}/' | ||
| f'{linux_name}') | ||
| # Every platform's object is read from its sibling index in one call. | ||
| self.fetch.assert_called_once_with(self.UPSTREAM_STEM, |
There was a problem hiding this comment.
nit: the old assert_any_call(f'{TOOLCHAIN_BUCKET_URL}/{linux_name}') was the only coverage of the per-platform object-name/URL derivation. That derivation now lives in rust_toolchain_extra_dep (plus the new -{brave_subrevision}.tar.xz suffix and toolchain_index_name), which has no test file, and _fake_extra_dep re-implements the naming rather than exercising it — so the check isn't relocated, just dropped. Consider a small test for rust_toolchain_extra_dep/toolchain_index_name in tools/cr/toolchains/. (✅ Relocate Test Checks When Refactoring)
| capture_output=True).stdout.strip() | ||
|
|
||
|
|
||
| def remote_url_exists(url: str, timeout: int = DEFAULT_TIMEOUT_SECS) -> bool: |
There was a problem hiding this comment.
nit: the other shared helper modules in tools/cr/toolchains/ (cherry_picks.py, gitiles.py, upload.py) each have a sibling *_test.py, but this new one doesn't. remote_url_exists's 403/404-vs-raise behaviour and fetch_index's URLError -> RuntimeError wrapping are easy to cover with a urlopen patch and would be worth a small toolchain_publish_test.py. (✅ PRs Should Include Reasonable Test Coverage)
This change unifies the model of how the different toolchain scripts
upload their toolchains, with all of them now providing a
--uploadoption to upload the produced tarball.
Additionally, this script further flattens the code under
tools/cr/toolchains.Bug: brave/brave-browser#55812