History
feat: initial forge backend plugin for mise
- Jean Humann
- Not verified
- 068ebffbdab9
- Browse the files
.gitignore+4−0
| @@ -0,0 +1,4 @@ | |||
| 1 | + | .DS_Store | |
| 2 | + | __pycache__/ | |
| 3 | + | *.pyc | |
| 4 | + | .pytest_cache/ |
CONTRIBUTING.md+24−0
| @@ -0,0 +1,24 @@ | |||
| 1 | + | # Contributing | |
| 2 | + | ||
| 3 | + | Thank you for your interest in the Cleyrop Forge `mise` backend plugin! | |
| 4 | + | ||
| 5 | + | This repository is developed on Cleyrop's forge and published as a read-only open-source repository at `https://code.cleyrop.tech/mise`. | |
| 6 | + | ||
| 7 | + | ## Local Development | |
| 8 | + | ||
| 9 | + | Link the local repository into `mise` and run the end-to-end test suite (which spins up a local mock server implementing the public forge release API and drives the real `mise` binary): | |
| 10 | + | ||
| 11 | + | ```bash | |
| 12 | + | python3 tests/e2e.py | |
| 13 | + | ``` | |
| 14 | + | ||
| 15 | + | ## Submitting Patches or Issues | |
| 16 | + | ||
| 17 | + | External patches (`git format-patch`) and bug reports can be sent to `opensource@cleyrop.com`. | |
| 18 | + | ||
| 19 | + | Please ensure your changes: | |
| 20 | + | ||
| 21 | + | - Pass `python3 tests/e2e.py` | |
| 22 | + | - Keep Lua code compatible with Lua 5.1 (embedded in `mise`) | |
| 23 | + | - Use `mise`'s built-in Lua modules (`http`, `json`, `file`, `archiver`, `checksum`) rather than external shell tools whenever possible | |
| 24 | + | - Never bypass SHA-256 verification |
LICENSE+201−0
| @@ -0,0 +1,201 @@ | |||
| 1 | + | Apache License | |
| 2 | + | Version 2.0, January 2004 | |
| 3 | + | http://www.apache.org/licenses/ | |
| 4 | + | ||
| 5 | + | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION | |
| 6 | + | ||
| 7 | + | 1. Definitions. | |
| 8 | + | ||
| 9 | + | "License" shall mean the terms and conditions for use, reproduction, | |
| 10 | + | and distribution as defined by Sections 1 through 9 of this document. | |
| 11 | + | ||
| 12 | + | "Licensor" shall mean the copyright owner or entity authorized by | |
| 13 | + | the copyright owner that is granting the License. | |
| 14 | + | ||
| 15 | + | "Legal Entity" shall mean the union of the acting entity and all | |
| 16 | + | other entities that control, are controlled by, or are under common | |
| 17 | + | control with that entity. For the purposes of this definition, | |
| 18 | + | "control" means (i) the power, direct or indirect, to cause the | |
| 19 | + | direction or management of such entity, whether by contract or | |
| 20 | + | otherwise, or (ii) ownership of fifty percent (50%) or more of the | |
| 21 | + | outstanding shares, or (iii) beneficial ownership of such entity. | |
| 22 | + | ||
| 23 | + | "You" (or "Your") shall mean an individual or Legal Entity | |
| 24 | + | exercising permissions granted by this License. | |
| 25 | + | ||
| 26 | + | "Source" form shall mean the preferred form for making modifications, | |
| 27 | + | including but not limited to software source code, documentation | |
| 28 | + | source, and configuration files. | |
| 29 | + | ||
| 30 | + | "Object" form shall mean any form resulting from mechanical | |
| 31 | + | transformation or translation of a Source form, including but | |
| 32 | + | not limited to compiled object code, generated documentation, | |
| 33 | + | and conversions to other media types. | |
| 34 | + | ||
| 35 | + | "Work" shall mean the work of authorship, whether in Source or | |
| 36 | + | Object form, made available under the License, as indicated by a | |
| 37 | + | copyright notice that is included in or attached to the work | |
| 38 | + | (an example is provided in the Appendix below). | |
| 39 | + | ||
| 40 | + | "Derivative Works" shall mean any work, whether in Source or Object | |
| 41 | + | form, that is based on (or derived from) the Work and for which the | |
| 42 | + | editorial revisions, annotations, elaborations, or other modifications | |
| 43 | + | represent, as a whole, an original work of authorship. For the purposes | |
| 44 | + | of this License, Derivative Works shall not include works that remain | |
| 45 | + | separable from, or merely link (or bind by name) to the interfaces of, | |
| 46 | + | the Work and Derivative Works thereof. | |
| 47 | + | ||
| 48 | + | "Contribution" shall mean any work of authorship, including | |
| 49 | + | the original version of the Work and any modifications or additions | |
| 50 | + | to that Work or Derivative Works thereof, that is intentionally | |
| 51 | + | submitted to Licensor for inclusion in the Work by the copyright owner | |
| 52 | + | or by an individual or Legal Entity authorized to submit on behalf of | |
| 53 | + | the copyright owner. For the purposes of this definition, "submitted" | |
| 54 | + | means any form of electronic, verbal, or written communication sent | |
| 55 | + | to the Licensor or its representatives, including but not limited to | |
| 56 | + | communication on electronic mailing lists, source code control systems, | |
| 57 | + | and issue tracking systems that are managed by, or on behalf of, the | |
| 58 | + | Licensor for the purpose of discussing and improving the Work, but | |
| 59 | + | excluding communication that is conspicuously marked or otherwise | |
| 60 | + | designated in writing by the copyright owner as "Not a Contribution." | |
| 61 | + | ||
| 62 | + | "Contributor" shall mean Licensor and any individual or Legal Entity | |
| 63 | + | on behalf of whom a Contribution has been received by Licensor and | |
| 64 | + | subsequently incorporated within the Work. | |
| 65 | + | ||
| 66 | + | 2. Grant of Copyright License. Subject to the terms and conditions of | |
| 67 | + | this License, each Contributor hereby grants to You a perpetual, | |
| 68 | + | worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |
| 69 | + | copyright license to reproduce, prepare Derivative Works of, | |
| 70 | + | publicly display, publicly perform, sublicense, and distribute the | |
| 71 | + | Work and such Derivative Works in Source or Object form. | |
| 72 | + | ||
| 73 | + | 3. Grant of Patent License. Subject to the terms and conditions of | |
| 74 | + | this License, each Contributor hereby grants to You a perpetual, | |
| 75 | + | worldwide, non-exclusive, no-charge, royalty-free, irrevocable | |
| 76 | + | (except as stated in this section) patent license to make, have made, | |
| 77 | + | use, offer to sell, sell, import, and otherwise transfer the Work, | |
| 78 | + | where such license applies only to those patent claims licensable | |
| 79 | + | by such Contributor that are necessarily infringed by their | |
| 80 | + | Contribution(s) alone or by combination of their Contribution(s) | |
| 81 | + | with the Work to which such Contribution(s) was submitted. If You | |
| 82 | + | institute patent litigation against any entity (including a | |
| 83 | + | cross-claim or counterclaim in a lawsuit) alleging that the Work | |
| 84 | + | or a Contribution incorporated within the Work constitutes direct | |
| 85 | + | or contributory patent infringement, then any patent licenses | |
| 86 | + | granted to You under this License for that Work shall terminate | |
| 87 | + | as of the date such litigation is filed. | |
| 88 | + | ||
| 89 | + | 4. Redistribution. You may reproduce and distribute copies of the | |
| 90 | + | Work or Derivative Works thereof in any medium, with or without | |
| 91 | + | modifications, and in Source or Object form, provided that You | |
| 92 | + | meet the following conditions: | |
| 93 | + | ||
| 94 | + | (a) You must give any other recipients of the Work or | |
| 95 | + | Derivative Works a copy of this License; and | |
| 96 | + | ||
| 97 | + | (b) You must cause any modified files to carry prominent notices | |
| 98 | + | stating that You changed the files; and | |
| 99 | + | ||
| 100 | + | (c) You must retain, in the Source form of any Derivative Works | |
| 101 | + | that You distribute, all copyright, patent, trademark, and | |
| 102 | + | attribution notices from the Source form of the Work, | |
| 103 | + | excluding those notices that do not pertain to any part of | |
| 104 | + | the Derivative Works; and | |
| 105 | + | ||
| 106 | + | (d) If the Work includes a "NOTICE" text file as part of its | |
| 107 | + | distribution, then any Derivative Works that You distribute must | |
| 108 | + | include a readable copy of the NOTICE text file within such | |
| 109 | + | Derivative Works, excluding those notices that do not pertain | |
| 110 | + | to any part of the Derivative Works, in at least one of the | |
| 111 | + | following places: within a NOTICE text file distributed | |
| 112 | + | as part of the Derivative Works; within the Source form or | |
| 113 | + | documentation, if provided along with the Derivative Works; or, | |
| 114 | + | within a display generated by the Derivative Works, if and | |
| 115 | + | wherever such third-party notices normally appear. The contents | |
| 116 | + | of the NOTICE text file are for informational purposes only and | |
| 117 | + | do not modify the License. You may add Your own attribution | |
| 118 | + | notices within Derivative Works that You distribute, alongside | |
| 119 | + | or as an addendum to the NOTICE text file from the Work, | |
| 120 | + | provided that such additional attribution notices cannot be | |
| 121 | + | construed as modifying the License. | |
| 122 | + | ||
| 123 | + | You may add Your own copyright notice to Your modifications and | |
| 124 | + | may provide additional or different license terms and conditions | |
| 125 | + | for use, reproduction, or distribution of Your modifications, or | |
| 126 | + | for any such Derivative Works as a whole, provided Your use, | |
| 127 | + | reproduction, and distribution of the Work otherwise complies with | |
| 128 | + | the conditions stated in this License. | |
| 129 | + | ||
| 130 | + | 5. Submission of Contributions. Unless You explicitly state otherwise, | |
| 131 | + | any Contribution intentionally submitted for inclusion in the Work | |
| 132 | + | by You to the Licensor shall be under the terms and conditions of | |
| 133 | + | this License, without any additional terms or conditions. | |
| 134 | + | Notwithstanding the above, nothing herein shall supersede or modify | |
| 135 | + | the terms of any separate license agreement you may have executed | |
| 136 | + | with Licensor regarding such Contributions. | |
| 137 | + | ||
| 138 | + | 6. Trademarks. This License does not grant permission to use the trade | |
| 139 | + | names, trademarks, service marks, or product names of the Licensor, | |
| 140 | + | except as required for reasonable and customary use in describing the | |
| 141 | + | origin of the Work and reproducing the content of the NOTICE text | |
| 142 | + | file. | |
| 143 | + | ||
| 144 | + | 7. Disclaimer of Warranty. Unless required by applicable law or | |
| 145 | + | agreed to in writing, Licensor provides the Work (and each | |
| 146 | + | Contributor provides its Contribution) on an "AS IS" BASIS, | |
| 147 | + | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | |
| 148 | + | implied, including, without limitation, any warranties or conditions | |
| 149 | + | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A | |
| 150 | + | PARTICULAR PURPOSE. You are solely responsible for determining the | |
| 151 | + | appropriateness of using or redistributing the Work and assume any | |
| 152 | + | risks associated with Your exercise of permissions under this License. | |
| 153 | + | ||
| 154 | + | 8. Limitation of Liability. In no event and under no theory of | |
| 155 | + | liability, whether in contract, tort (including negligence), | |
| 156 | + | strict liability, or otherwise, unless required by applicable law | |
| 157 | + | (such as deliberate and grossly negligent acts) or agreed to in | |
| 158 | + | writing, shall any Contributor be liable to You for damages, | |
| 159 | + | including any direct, indirect, special, incidental, or | |
| 160 | + | consequential damages of any character arising as a result of this | |
| 161 | + | License or out of the use or inability to use the Work (including | |
| 162 | + | but not limited to damages for loss of goodwill, work stoppage, | |
| 163 | + | computer failure or malfunction, or any and all other commercial | |
| 164 | + | damages or losses), even if such Contributor has been advised of the | |
| 165 | + | possibility of such damages. | |
| 166 | + | ||
| 167 | + | 9. Accepting Warranty or Additional Liability. While redistributing | |
| 168 | + | the Work or Derivative Works thereof, You may accept support, | |
| 169 | + | warranty, or additional liability obligations and/or rights consistent | |
| 170 | + | with this License. However, in accepting such obligations, You may | |
| 171 | + | act only on Your own behalf and on Your sole responsibility, and not | |
| 172 | + | on behalf of any other Contributor, and only if You agree to indemnify, | |
| 173 | + | defend, and hold each Contributor harmless for any liability | |
| 174 | + | incurred by, or claims asserted against, such Contributor by reason | |
| 175 | + | of your accepting any such warranty or additional liability. | |
| 176 | + | ||
| 177 | + | END OF TERMS AND CONDITIONS | |
| 178 | + | ||
| 179 | + | APPENDIX: How to apply the Apache License to your work. | |
| 180 | + | ||
| 181 | + | To apply the Apache License to your work, attach the following | |
| 182 | + | boilerplate notice, with the fields enclosed by brackets "[]" | |
| 183 | + | represented by your own identifying information. (Don't include | |
| 184 | + | the brackets!) The text must be enclosed in the appropriate | |
| 185 | + | comment fields for the file format. We also recommend that you | |
| 186 | + | include a file or short line indicating the name of the file and | |
| 187 | + | representation of your own identifying information. | |
| 188 | + | ||
| 189 | + | Copyright 2026 Cleyrop | |
| 190 | + | ||
| 191 | + | Licensed under the Apache License, Version 2.0 (the "License"); | |
| 192 | + | you may not use this file except in compliance with the License. | |
| 193 | + | You may obtain a copy of the License at | |
| 194 | + | ||
| 195 | + | http://www.apache.org/licenses/LICENSE-2.0 | |
| 196 | + | ||
| 197 | + | Unless required by applicable law or agreed to in writing, software | |
| 198 | + | distributed under the License is distributed on an "AS IS" BASIS, | |
| 199 | + | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 200 | + | See the License for the specific language governing permissions and | |
| 201 | + | limitations under the License. |
README.md+92−0
| @@ -0,0 +1,92 @@ | |||
| 1 | + | # mise (Cleyrop Forge backend) | |
| 2 | + | ||
| 3 | + | A [`mise`](https://mise.jdx.dev) backend plugin for installing and upgrading CLI tools published on Cleyrop's public forge ([`code.cleyrop.tech`](https://code.cleyrop.tech)). | |
| 4 | + | ||
| 5 | + | ## Quick Start | |
| 6 | + | ||
| 7 | + | ### In a project (`mise.toml`) | |
| 8 | + | ||
| 9 | + | ```toml | |
| 10 | + | [plugins] | |
| 11 | + | forge = "https://code.cleyrop.tech/mise.git" | |
| 12 | + | ||
| 13 | + | [tools] | |
| 14 | + | "forge:roneo" = "latest" | |
| 15 | + | ``` | |
| 16 | + | ||
| 17 | + | Then run: | |
| 18 | + | ||
| 19 | + | ```sh | |
| 20 | + | mise install | |
| 21 | + | mise upgrade | |
| 22 | + | ``` | |
| 23 | + | ||
| 24 | + | ### Globally via CLI | |
| 25 | + | ||
| 26 | + | Install the plugin under the `forge` backend prefix: | |
| 27 | + | ||
| 28 | + | ```sh | |
| 29 | + | mise plugins install forge https://code.cleyrop.tech/mise.git | |
| 30 | + | mise use -g forge:roneo@latest | |
| 31 | + | ``` | |
| 32 | + | ||
| 33 | + | Check available versions or upgrade later: | |
| 34 | + | ||
| 35 | + | ```sh | |
| 36 | + | mise ls-remote forge:roneo | |
| 37 | + | mise outdated | |
| 38 | + | mise upgrade forge:roneo | |
| 39 | + | ``` | |
| 40 | + | ||
| 41 | + | ## Multi-Binary Repositories | |
| 42 | + | ||
| 43 | + | A single plugin handles every tool published on the forge. When a repository ships multiple binaries in the same release, select a specific binary using `forge:<repo>/<bin>`: | |
| 44 | + | ||
| 45 | + | ```toml | |
| 46 | + | [tools] | |
| 47 | + | "forge:my-suite" = "1.2.0" # default binary ("my-suite") | |
| 48 | + | "forge:my-suite/helper" = "1.2.0" # specific binary ("helper") from "my-suite" | |
| 49 | + | ``` | |
| 50 | + | ||
| 51 | + | ## Options & Environment Variables | |
| 52 | + | ||
| 53 | + | | Option (`mise.toml`) | Environment Variable | Default | Description | | |
| 54 | + | | --- | --- | --- | --- | | |
| 55 | + | | `url` | `MISE_FORGE_URL` | `https://code.cleyrop.tech` | Base URL of the forge instance | | |
| 56 | + | | `bin` | — | `<repo>` | Explicit binary name (alternative to `forge:<repo>/<bin>`) | | |
| 57 | + | | `tag_prefix` | — | `v` | Tag prefix for fast-path lookup (falls back to full listing if not found) | | |
| 58 | + | | `verify_cosign` | `MISE_FORGE_VERIFY_COSIGN` | `false` | Require and verify Cosign blob signatures against `key_url` | | |
| 59 | + | | — | `MISE_FORGE_TOKEN` | — | Optional Bearer token for authenticated forge instances | | |
| 60 | + | ||
| 61 | + | Example with options: | |
| 62 | + | ||
| 63 | + | ```toml | |
| 64 | + | [tools] | |
| 65 | + | "forge:roneo" = { version = "0.1.0", verify_cosign = "true" } | |
| 66 | + | ``` | |
| 67 | + | ||
| 68 | + | For repositories that only publish prereleases (such as `-alpha.*` tags), enable `mise`'s prerelease matching (`MISE_PRERELEASES=1` or `prereleases = true`) when using `@latest`, or pin the exact prerelease version. | |
| 69 | + | ||
| 70 | + | ## Release API Contract | |
| 71 | + | ||
| 72 | + | This plugin consumes the read-only public forge release API (`docs/PUBLIC-FORGE-API.md`): | |
| 73 | + | ||
| 74 | + | - `GET /api/v1/repos` — published repositories (`mise search`) | |
| 75 | + | - `GET /api/v1/repos/<repo>/releases` — releases newest-first, paginated via `Link: <…>; rel="next"` | |
| 76 | + | - `GET /api/v1/repos/<repo>/releases/<tag>` and `…/releases/latest` — single release metadata | |
| 77 | + | - `GET /<repo>/releases/download/<tag>/<asset>` — immutable release binaries/archives and signatures | |
| 78 | + | - `GET /api/v1/keys/<name>.pub` — Cosign public key | |
| 79 | + | ||
| 80 | + | Platform selection uses the declared `os` (`linux`, `darwin`, `windows`), `arch` (`amd64`, `arm64`), and `bin` fields from the release manifest rather than filename heuristics. Every download is verified against its declared `sha256` digest before installation. | |
| 81 | + | ||
| 82 | + | ## Running Tests | |
| 83 | + | ||
| 84 | + | The end-to-end test suite starts a local mock server implementing the release API and runs the real `mise` binary inside an isolated temporary data/cache/config directory: | |
| 85 | + | ||
| 86 | + | ```sh | |
| 87 | + | python3 tests/e2e.py | |
| 88 | + | ``` | |
| 89 | + | ||
| 90 | + | ## License | |
| 91 | + | ||
| 92 | + | Apache-2.0 — see [LICENSE](LICENSE). |
SECURITY.md+17−0
| @@ -0,0 +1,17 @@ | |||
| 1 | + | # Security Policy | |
| 2 | + | ||
| 3 | + | ## Reporting a Vulnerability | |
| 4 | + | ||
| 5 | + | If you discover a security vulnerability in this plugin, please report it responsibly instead of opening a public issue: | |
| 6 | + | ||
| 7 | + | - Contact: `security@cleyrop.com` | |
| 8 | + | - Include a clear description of the issue, reproduction steps, and affected version or commit. | |
| 9 | + | ||
| 10 | + | We will acknowledge receipt promptly and coordinate a fix and disclosure timeline. | |
| 11 | + | ||
| 12 | + | ## Security Model | |
| 13 | + | ||
| 14 | + | - **Mandatory integrity checks**: Every downloaded release artefact must declare a 64-character hex `sha256` digest in the release API response and is verified with `mise`'s built-in `checksum` module before extraction or installation. Missing or mismatched digests fail closed. | |
| 15 | + | - **Optional Cosign verification**: When `verify_cosign = true` (or `MISE_FORGE_VERIFY_COSIGN=1`) is enabled, the plugin requires both `asset.signature_url` and `release.key_url`, downloads them, and runs `cosign verify-blob` before installing. | |
| 16 | + | - **Strict input validation**: Repository and binary names are restricted to `[A-Za-z0-9._-]+`, reject path traversal (`..`), and reject the reserved `api` repository name. Download URLs are restricted to `http://` and `https://`. | |
| 17 | + | - **No scraping or guessing**: Platform selection (`os`, `arch`, `bin`) is read strictly from declared release manifest metadata. Unplaced assets (`os`/`arch`/`bin` set to `null`) are skipped. |
ci/jobs.toml+12−0
| @@ -0,0 +1,12 @@ | |||
| 1 | + | # Native Forge CI for the mise backend plugin (schema 2) | |
| 2 | + | # Secret scanning (gitleaks) is required for public repositories (PUBLIC-FORGE.md §6). | |
| 3 | + | # Once a digest-pinned public image carrying `mise` and `python3` is available under | |
| 4 | + | # `registry.cleyrop.tech/external/...`, add a `[jobs.e2e]` running `python3 tests/e2e.py`. | |
| 5 | + | schema = 2 | |
| 6 | + | ||
| 7 | + | [jobs.gitleaks] | |
| 8 | + | inputs = ["**"] | |
| 9 | + | image = "registry.cleyrop.tech/external/zricethezav/gitleaks:v8.24.2@sha256:b5918eb91b8d2473cec722f066abb4352e4ffdc4ec9f4283ec143aba9ec9ebc4" | |
| 10 | + | script = [ | |
| 11 | + | "gitleaks detect --source . --no-banner --redact", | |
| 12 | + | ] |
forge.toml+7−0
| @@ -0,0 +1,7 @@ | |||
| 1 | + | # Forge repository profile (PUBLIC-FORGE.md) | |
| 2 | + | schema = 1 | |
| 3 | + | ||
| 4 | + | [repository] | |
| 5 | + | default_branch = "main" | |
| 6 | + | description = "Mise backend plugin for Cleyrop's public forge (code.cleyrop.tech)." | |
| 7 | + | release_tag = "v" |
| @@ -0,0 +1,12 @@ | |||
| 1 | + | local file = require("file") | |
| 2 | + | ||
| 3 | + | function PLUGIN:BackendExecEnv(ctx) | |
| 4 | + | return { | |
| 5 | + | env_vars = { | |
| 6 | + | { | |
| 7 | + | key = "PATH", | |
| 8 | + | value = file.join_path(ctx.install_path, "bin"), | |
| 9 | + | }, | |
| 10 | + | }, | |
| 11 | + | } | |
| 12 | + | end |
| @@ -0,0 +1,41 @@ | |||
| 1 | + | local file = require("file") | |
| 2 | + | local forge = require("forge") | |
| 3 | + | local http = require("http") | |
| 4 | + | ||
| 5 | + | function PLUGIN:BackendInstall(ctx) | |
| 6 | + | local base_url = forge.base_url(ctx.options) | |
| 7 | + | local spec = forge.parse_tool(ctx.tool, ctx.options) | |
| 8 | + | local os_name, arch_name = forge.runtime_platform() | |
| 9 | + | ||
| 10 | + | local release = forge.find_release(base_url, spec.repo, ctx.version, ctx.options) | |
| 11 | + | local asset = forge.select_asset(release, spec, os_name, arch_name) | |
| 12 | + | local asset_url = forge.resolve_url(base_url, asset.url) | |
| 13 | + | ||
| 14 | + | local created_fallback_dir = false | |
| 15 | + | local download_dir = ctx.download_path or ctx.temp_dir | |
| 16 | + | if type(download_dir) ~= "string" or download_dir == "" then | |
| 17 | + | download_dir = file.join_path(ctx.install_path, ".download") | |
| 18 | + | created_fallback_dir = true | |
| 19 | + | end | |
| 20 | + | forge.mkdir_p(download_dir, os_name) | |
| 21 | + | ||
| 22 | + | local asset_name = asset.name or asset.bin | |
| 23 | + | -- Strip any directory separators defensively before joining with download_dir. | |
| 24 | + | local safe_name = asset_name:match("([^/\\]+)$") or asset.bin | |
| 25 | + | local downloaded_path = file.join_path(download_dir, safe_name) | |
| 26 | + | ||
| 27 | + | http.download_file({ | |
| 28 | + | url = asset_url, | |
| 29 | + | headers = forge.http_headers(), | |
| 30 | + | }, downloaded_path) | |
| 31 | + | ||
| 32 | + | forge.verify_sha256(downloaded_path, asset.sha256, os_name) | |
| 33 | + | forge.maybe_verify_cosign(base_url, release, asset, downloaded_path, download_dir, ctx.options) | |
| 34 | + | forge.install_asset(downloaded_path, asset, ctx.install_path, download_dir, os_name) | |
| 35 | + | ||
| 36 | + | if created_fallback_dir then | |
| 37 | + | forge.remove_rf(download_dir, os_name) | |
| 38 | + | end | |
| 39 | + | ||
| 40 | + | return {} | |
| 41 | + | end |
| @@ -0,0 +1,20 @@ | |||
| 1 | + | local forge = require("forge") | |
| 2 | + | ||
| 3 | + | function PLUGIN:BackendListTools(_ctx) | |
| 4 | + | local base_url = forge.base_url(nil) | |
| 5 | + | local repos = forge.list_repos(base_url) | |
| 6 | + | ||
| 7 | + | local tools = {} | |
| 8 | + | for _, repo in ipairs(repos) do | |
| 9 | + | if type(repo) == "table" and type(repo.name) == "string" and repo.name ~= "" then | |
| 10 | + | if type(repo.latest_release) == "string" and repo.latest_release ~= "" then | |
| 11 | + | table.insert(tools, { | |
| 12 | + | name = repo.name, | |
| 13 | + | description = type(repo.description) == "string" and repo.description or "", | |
| 14 | + | }) | |
| 15 | + | end | |
| 16 | + | end | |
| 17 | + | end | |
| 18 | + | ||
| 19 | + | return { tools = tools } | |
| 20 | + | end |
| @@ -0,0 +1,33 @@ | |||
| 1 | + | local forge = require("forge") | |
| 2 | + | ||
| 3 | + | function PLUGIN:BackendListVersions(ctx) | |
| 4 | + | local base_url = forge.base_url(ctx.options) | |
| 5 | + | local spec = forge.parse_tool(ctx.tool, ctx.options) | |
| 6 | + | local releases = forge.list_releases(base_url, spec.repo) | |
| 7 | + | ||
| 8 | + | -- PUBLIC-FORGE-API returns releases newest first (semver descending). | |
| 9 | + | -- mise BackendListVersions expects versions ordered oldest first. | |
| 10 | + | local filtered = {} | |
| 11 | + | for _, rel in ipairs(releases) do | |
| 12 | + | if type(rel) == "table" and type(rel.version) == "string" and rel.version ~= "" then | |
| 13 | + | if forge.release_has_bin(rel, spec) then | |
| 14 | + | table.insert(filtered, rel) | |
| 15 | + | end | |
| 16 | + | end | |
| 17 | + | end | |
| 18 | + | ||
| 19 | + | local versions = {} | |
| 20 | + | for i = #filtered, 1, -1 do | |
| 21 | + | local rel = filtered[i] | |
| 22 | + | if type(rel.published_at) == "string" and rel.published_at ~= "" then | |
| 23 | + | table.insert(versions, { | |
| 24 | + | version = rel.version, | |
| 25 | + | created_at = rel.published_at, | |
| 26 | + | }) | |
| 27 | + | else | |
| 28 | + | table.insert(versions, rel.version) | |
| 29 | + | end | |
| 30 | + | end | |
| 31 | + | ||
| 32 | + | return { versions = versions } | |
| 33 | + | end |
| @@ -0,0 +1,38 @@ | |||
| 1 | + | local forge = require("forge") | |
| 2 | + | ||
| 3 | + | function PLUGIN:BackendSearchTools(ctx) | |
| 4 | + | local base_url = forge.base_url(nil) | |
| 5 | + | local repos = forge.list_repos(base_url) | |
| 6 | + | local query = string.lower(tostring((ctx and ctx.query) or "")) | |
| 7 | + | ||
| 8 | + | local tools = {} | |
| 9 | + | for _, repo in ipairs(repos) do | |
| 10 | + | if type(repo) == "table" and type(repo.name) == "string" and repo.name ~= "" then | |
| 11 | + | if type(repo.latest_release) == "string" and repo.latest_release ~= "" then | |
| 12 | + | local name = repo.name | |
| 13 | + | local desc = type(repo.description) == "string" and repo.description or "" | |
| 14 | + | local match = (query == "") | |
| 15 | + | or (string.lower(name):find(query, 1, true) ~= nil) | |
| 16 | + | or (string.lower(desc):find(query, 1, true) ~= nil) | |
| 17 | + | ||
| 18 | + | if not match and type(repo.topics) == "table" then | |
| 19 | + | for _, topic in ipairs(repo.topics) do | |
| 20 | + | if type(topic) == "string" and string.lower(topic):find(query, 1, true) ~= nil then | |
| 21 | + | match = true | |
| 22 | + | break | |
| 23 | + | end | |
| 24 | + | end | |
| 25 | + | end | |
| 26 | + | ||
| 27 | + | if match then | |
| 28 | + | table.insert(tools, { | |
| 29 | + | name = name, | |
| 30 | + | description = desc, | |
| 31 | + | }) | |
| 32 | + | end | |
| 33 | + | end | |
| 34 | + | end | |
| 35 | + | end | |
| 36 | + | ||
| 37 | + | return { tools = tools } | |
| 38 | + | end |
lib/forge.lua+666−0
| @@ -0,0 +1,666 @@ | |||
| 1 | + | local archiver = require("archiver") | |
| 2 | + | local cmd = require("cmd") | |
| 3 | + | local file = require("file") | |
| 4 | + | local http = require("http") | |
| 5 | + | local json = require("json") | |
| 6 | + | ||
| 7 | + | local has_checksum, checksum = pcall(require, "checksum") | |
| 8 | + | ||
| 9 | + | local M = {} | |
| 10 | + | ||
| 11 | + | M.DEFAULT_URL = "https://code.cleyrop.tech" | |
| 12 | + | M.USER_AGENT = "mise-forge/0.1.0" | |
| 13 | + | M.MAX_PAGES = 100 | |
| 14 | + | ||
| 15 | + | local ARCHIVE_EXTENSIONS = { | |
| 16 | + | ".tar.gz", | |
| 17 | + | ".tgz", | |
| 18 | + | ".tar.xz", | |
| 19 | + | ".txz", | |
| 20 | + | ".tar.bz2", | |
| 21 | + | ".tbz2", | |
| 22 | + | ".tar.zst", | |
| 23 | + | ".tar", | |
| 24 | + | ".zip", | |
| 25 | + | } | |
| 26 | + | ||
| 27 | + | local function trim(s) | |
| 28 | + | if type(s) ~= "string" then | |
| 29 | + | return "" | |
| 30 | + | end | |
| 31 | + | return (s:gsub("^%s+", ""):gsub("%s+$", "")) | |
| 32 | + | end | |
| 33 | + | ||
| 34 | + | local function ends_with(str, suffix) | |
| 35 | + | return suffix == "" or str:sub(-#suffix) == suffix | |
| 36 | + | end | |
| 37 | + | ||
| 38 | + | local function starts_with(str, prefix) | |
| 39 | + | return str:sub(1, #prefix) == prefix | |
| 40 | + | end | |
| 41 | + | ||
| 42 | + | function M.shell_quote(str) | |
| 43 | + | return "'" .. tostring(str):gsub("'", "'\\''") .. "'" | |
| 44 | + | end | |
| 45 | + | ||
| 46 | + | function M.base_url(options) | |
| 47 | + | local raw = nil | |
| 48 | + | if type(options) == "table" and type(options.url) == "string" and trim(options.url) ~= "" then | |
| 49 | + | raw = trim(options.url) | |
| 50 | + | else | |
| 51 | + | local env_url = os.getenv("MISE_FORGE_URL") | |
| 52 | + | if type(env_url) == "string" and trim(env_url) ~= "" then | |
| 53 | + | raw = trim(env_url) | |
| 54 | + | else | |
| 55 | + | raw = M.DEFAULT_URL | |
| 56 | + | end | |
| 57 | + | end | |
| 58 | + | ||
| 59 | + | raw = raw:gsub("/+$", "") | |
| 60 | + | if not (starts_with(raw, "https://") or starts_with(raw, "http://")) then | |
| 61 | + | error("Invalid forge URL (must start with https:// or http://): " .. raw) | |
| 62 | + | end | |
| 63 | + | return raw | |
| 64 | + | end | |
| 65 | + | ||
| 66 | + | local function validate_segment(seg, label) | |
| 67 | + | if type(seg) ~= "string" or seg == "" then | |
| 68 | + | error("Invalid " .. label .. ": empty value") | |
| 69 | + | end | |
| 70 | + | if seg == "." or seg == ".." or seg:find("%.%.") then | |
| 71 | + | error("Invalid " .. label .. ": path traversal is not allowed (" .. seg .. ")") | |
| 72 | + | end | |
| 73 | + | if not seg:match("^[A-Za-z0-9._-]+$") then | |
| 74 | + | error("Invalid " .. label .. ": unsupported characters (" .. seg .. ")") | |
| 75 | + | end | |
| 76 | + | end | |
| 77 | + | ||
| 78 | + | function M.parse_tool(tool, options) | |
| 79 | + | if type(tool) ~= "string" or trim(tool) == "" then | |
| 80 | + | error("Tool name is required (expected forge:<repo> or forge:<repo>/<bin>)") | |
| 81 | + | end | |
| 82 | + | ||
| 83 | + | local parts = {} | |
| 84 | + | for part in tool:gmatch("[^/]+") do | |
| 85 | + | table.insert(parts, part) | |
| 86 | + | end | |
| 87 | + | ||
| 88 | + | if #parts == 0 or #parts > 2 or tool:find("//") or starts_with(tool, "/") or ends_with(tool, "/") then | |
| 89 | + | error("Invalid tool identifier '" .. tool .. "' (expected <repo> or <repo>/<bin>)") | |
| 90 | + | end | |
| 91 | + | ||
| 92 | + | local repo = parts[1] | |
| 93 | + | validate_segment(repo, "repository name") | |
| 94 | + | if repo == "api" then | |
| 95 | + | error("Repository name 'api' is reserved on the public forge") | |
| 96 | + | end | |
| 97 | + | ||
| 98 | + | local explicit_bin = false | |
| 99 | + | local bin = repo | |
| 100 | + | if #parts == 2 then | |
| 101 | + | bin = parts[2] | |
| 102 | + | explicit_bin = true | |
| 103 | + | elseif type(options) == "table" and type(options.bin) == "string" and trim(options.bin) ~= "" then | |
| 104 | + | bin = trim(options.bin) | |
| 105 | + | explicit_bin = true | |
| 106 | + | end | |
| 107 | + | validate_segment(bin, "binary name") | |
| 108 | + | ||
| 109 | + | return { | |
| 110 | + | repo = repo, | |
| 111 | + | bin = bin, | |
| 112 | + | explicit_bin = explicit_bin, | |
| 113 | + | } | |
| 114 | + | end | |
| 115 | + | ||
| 116 | + | function M.runtime_platform() | |
| 117 | + | local raw_os = string.lower(tostring((RUNTIME and RUNTIME.osType) or "")) | |
| 118 | + | local raw_arch = string.lower(tostring((RUNTIME and RUNTIME.archType) or "")) | |
| 119 | + | ||
| 120 | + | local os_map = { | |
| 121 | + | darwin = "darwin", | |
| 122 | + | macos = "darwin", | |
| 123 | + | osx = "darwin", | |
| 124 | + | linux = "linux", | |
| 125 | + | windows = "windows", | |
| 126 | + | win32 = "windows", | |
| 127 | + | } | |
| 128 | + | ||
| 129 | + | local arch_map = { | |
| 130 | + | amd64 = "amd64", | |
| 131 | + | x86_64 = "amd64", | |
| 132 | + | x64 = "amd64", | |
| 133 | + | arm64 = "arm64", | |
| 134 | + | aarch64 = "arm64", | |
| 135 | + | } | |
| 136 | + | ||
| 137 | + | local os_name = os_map[raw_os] | |
| 138 | + | if not os_name then | |
| 139 | + | error("Unsupported operating system: " .. tostring(RUNTIME and RUNTIME.osType)) | |
| 140 | + | end | |
| 141 | + | ||
| 142 | + | local arch_name = arch_map[raw_arch] | |
| 143 | + | if not arch_name then | |
| 144 | + | error("Unsupported CPU architecture: " .. tostring(RUNTIME and RUNTIME.archType)) | |
| 145 | + | end | |
| 146 | + | ||
| 147 | + | return os_name, arch_name | |
| 148 | + | end | |
| 149 | + | ||
| 150 | + | function M.http_headers(accept) | |
| 151 | + | local headers = { | |
| 152 | + | ["User-Agent"] = M.USER_AGENT, | |
| 153 | + | } | |
| 154 | + | if accept then | |
| 155 | + | headers["Accept"] = accept | |
| 156 | + | end | |
| 157 | + | local token = os.getenv("MISE_FORGE_TOKEN") | |
| 158 | + | if type(token) == "string" and trim(token) ~= "" then | |
| 159 | + | headers["Authorization"] = "Bearer " .. trim(token) | |
| 160 | + | end | |
| 161 | + | return headers | |
| 162 | + | end | |
| 163 | + | ||
| 164 | + | function M.resolve_url(base_url, target) | |
| 165 | + | if type(target) ~= "string" or trim(target) == "" then | |
| 166 | + | error("Missing URL in release metadata") | |
| 167 | + | end | |
| 168 | + | local url = trim(target) | |
| 169 | + | if starts_with(url, "/") then | |
| 170 | + | url = base_url .. url | |
| 171 | + | end | |
| 172 | + | if not (starts_with(url, "https://") or starts_with(url, "http://")) then | |
| 173 | + | error("Refusing non-HTTP(S) URL: " .. url) | |
| 174 | + | end | |
| 175 | + | return url | |
| 176 | + | end | |
| 177 | + | ||
| 178 | + | local function get_header_ci(headers, target_name) | |
| 179 | + | if type(headers) ~= "table" then | |
| 180 | + | return nil | |
| 181 | + | end | |
| 182 | + | local lower_target = string.lower(target_name) | |
| 183 | + | for k, v in pairs(headers) do | |
| 184 | + | if string.lower(tostring(k)) == lower_target then | |
| 185 | + | return v | |
| 186 | + | end | |
| 187 | + | end | |
| 188 | + | return nil | |
| 189 | + | end | |
| 190 | + | ||
| 191 | + | function M.parse_next_link(headers, base_url) | |
| 192 | + | local link = get_header_ci(headers, "link") | |
| 193 | + | if type(link) ~= "string" or link == "" then | |
| 194 | + | return nil | |
| 195 | + | end | |
| 196 | + | for entry in link:gmatch("[^,]+") do | |
| 197 | + | local url, params = entry:match("^%s*<([^>]+)>%s*;(.*)$") | |
| 198 | + | if url and params and params:match('rel%s*=%s*"?next"?') then | |
| 199 | + | return M.resolve_url(base_url, url) | |
| 200 | + | end | |
| 201 | + | end | |
| 202 | + | return nil | |
| 203 | + | end | |
| 204 | + | ||
| 205 | + | function M.fetch_json(url, allow_404) | |
| 206 | + | local resp, err = http.get({ | |
| 207 | + | url = url, | |
| 208 | + | headers = M.http_headers("application/json"), | |
| 209 | + | }) | |
| 210 | + | if err ~= nil then | |
| 211 | + | error("HTTP request failed for " .. url .. ": " .. tostring(err)) | |
| 212 | + | end | |
| 213 | + | if resp == nil then | |
| 214 | + | error("Empty HTTP response for " .. url) | |
| 215 | + | end | |
| 216 | + | if allow_404 and resp.status_code == 404 then | |
| 217 | + | return nil, resp.headers, 404 | |
| 218 | + | end | |
| 219 | + | if resp.status_code ~= 200 then | |
| 220 | + | error("HTTP " .. tostring(resp.status_code) .. " while fetching " .. url) | |
| 221 | + | end | |
| 222 | + | local ok, decoded = pcall(json.decode, resp.body) | |
| 223 | + | if not ok then | |
| 224 | + | error("Failed to decode JSON from " .. url .. ": " .. tostring(decoded)) | |
| 225 | + | end | |
| 226 | + | return decoded, resp.headers, resp.status_code | |
| 227 | + | end | |
| 228 | + | ||
| 229 | + | local function unwrap_list(decoded, key) | |
| 230 | + | if type(decoded) ~= "table" then | |
| 231 | + | return {} | |
| 232 | + | end | |
| 233 | + | if type(decoded[key]) == "table" then | |
| 234 | + | return decoded[key] | |
| 235 | + | end | |
| 236 | + | return decoded | |
| 237 | + | end | |
| 238 | + | ||
| 239 | + | function M.list_repos(base_url) | |
| 240 | + | local decoded = M.fetch_json(base_url .. "/api/v1/repos", false) | |
| 241 | + | return unwrap_list(decoded, "repos") | |
| 242 | + | end | |
| 243 | + | ||
| 244 | + | function M.list_releases(base_url, repo) | |
| 245 | + | local url = base_url .. "/api/v1/repos/" .. repo .. "/releases" | |
| 246 | + | local all = {} | |
| 247 | + | local seen_urls = {} | |
| 248 | + | local page = 0 | |
| 249 | + | ||
| 250 | + | while url do | |
| 251 | + | page = page + 1 | |
| 252 | + | if page > M.MAX_PAGES then | |
| 253 | + | error("Pagination limit exceeded while listing releases for " .. repo) | |
| 254 | + | end | |
| 255 | + | if seen_urls[url] then | |
| 256 | + | break | |
| 257 | + | end | |
| 258 | + | seen_urls[url] = true | |
| 259 | + | ||
| 260 | + | local decoded, headers, status = M.fetch_json(url, page == 1) | |
| 261 | + | if status == 404 then | |
| 262 | + | error("Repository '" .. repo .. "' was not found on " .. base_url) | |
| 263 | + | end | |
| 264 | + | ||
| 265 | + | local items = unwrap_list(decoded, "releases") | |
| 266 | + | for _, rel in ipairs(items) do | |
| 267 | + | table.insert(all, rel) | |
| 268 | + | end | |
| 269 | + | ||
| 270 | + | url = M.parse_next_link(headers, base_url) | |
| 271 | + | end | |
| 272 | + | ||
| 273 | + | return all | |
| 274 | + | end | |
| 275 | + | ||
| 276 | + | function M.is_placed_asset(asset) | |
| 277 | + | return type(asset) == "table" | |
| 278 | + | and type(asset.os) == "string" and asset.os ~= "" | |
| 279 | + | and type(asset.arch) == "string" and asset.arch ~= "" | |
| 280 | + | and type(asset.bin) == "string" and asset.bin ~= "" | |
| 281 | + | and type(asset.url) == "string" and asset.url ~= "" | |
| 282 | + | end | |
| 283 | + | ||
| 284 | + | function M.release_has_bin(release, spec) | |
| 285 | + | if type(release) ~= "table" or type(release.assets) ~= "table" then | |
| 286 | + | return false | |
| 287 | + | end | |
| 288 | + | local any_placed = false | |
| 289 | + | for _, asset in ipairs(release.assets) do | |
| 290 | + | if M.is_placed_asset(asset) then | |
| 291 | + | any_placed = true | |
| 292 | + | if asset.bin == spec.bin then | |
| 293 | + | return true | |
| 294 | + | end | |
| 295 | + | end | |
| 296 | + | end | |
| 297 | + | -- When the user did not specify an explicit /<bin>, keep releases with placed assets | |
| 298 | + | -- so repos whose binary name differs from the repo name still list versions. | |
| 299 | + | return (not spec.explicit_bin) and any_placed | |
| 300 | + | end | |
| 301 | + | ||
| 302 | + | function M.find_release(base_url, repo, version, options) | |
| 303 | + | if version == "latest" then | |
| 304 | + | local rel, _, status = M.fetch_json(base_url .. "/api/v1/repos/" .. repo .. "/releases/latest", true) | |
| 305 | + | if status == 404 or rel == nil then | |
| 306 | + | error("No published release found for repository '" .. repo .. "' on " .. base_url) | |
| 307 | + | end | |
| 308 | + | return rel | |
| 309 | + | end | |
| 310 | + | ||
| 311 | + | -- Fast path: direct immutable tag lookup (<tag_prefix><version> or v<version>). | |
| 312 | + | local candidates = {} | |
| 313 | + | if type(options) == "table" and type(options.tag_prefix) == "string" and options.tag_prefix ~= "" then | |
| 314 | + | table.insert(candidates, options.tag_prefix .. version) | |
| 315 | + | end | |
| 316 | + | if starts_with(version, "v") then | |
| 317 | + | table.insert(candidates, version) | |
| 318 | + | else | |
| 319 | + | table.insert(candidates, "v" .. version) | |
| 320 | + | table.insert(candidates, version) | |
| 321 | + | end | |
| 322 | + | ||
| 323 | + | local tried = {} | |
| 324 | + | for _, tag in ipairs(candidates) do | |
| 325 | + | if not tried[tag] then | |
| 326 | + | tried[tag] = true | |
| 327 | + | local rel, _, status = M.fetch_json(base_url .. "/api/v1/repos/" .. repo .. "/releases/" .. tag, true) | |
| 328 | + | if status == 200 and type(rel) == "table" then | |
| 329 | + | return rel | |
| 330 | + | end | |
| 331 | + | end | |
| 332 | + | end | |
| 333 | + | ||
| 334 | + | -- Fallback: scan paginated releases to handle prefixed tags (e.g. forge-v1.4.0). | |
| 335 | + | local releases = M.list_releases(base_url, repo) | |
| 336 | + | for _, rel in ipairs(releases) do | |
| 337 | + | if type(rel) == "table" and (rel.version == version or rel.tag == version) then | |
| 338 | + | return rel | |
| 339 | + | end | |
| 340 | + | end | |
| 341 | + | ||
| 342 | + | error("Release '" .. version .. "' not found for repository '" .. repo .. "' on " .. base_url) | |
| 343 | + | end | |
| 344 | + | ||
| 345 | + | function M.select_asset(release, spec, os_name, arch_name) | |
| 346 | + | if type(release.assets) ~= "table" then | |
| 347 | + | error("Release '" .. tostring(release.tag or release.version) .. "' has no assets") | |
| 348 | + | end | |
| 349 | + | ||
| 350 | + | local platform_matches = {} | |
| 351 | + | for _, asset in ipairs(release.assets) do | |
| 352 | + | if M.is_placed_asset(asset) and asset.os == os_name and asset.arch == arch_name then | |
| 353 | + | if asset.bin == spec.bin then | |
| 354 | + | return asset | |
| 355 | + | end | |
| 356 | + | table.insert(platform_matches, asset) | |
| 357 | + | end | |
| 358 | + | end | |
| 359 | + | ||
| 360 | + | if (not spec.explicit_bin) and #platform_matches == 1 then | |
| 361 | + | return platform_matches[1] | |
| 362 | + | end | |
| 363 | + | ||
| 364 | + | if #platform_matches > 1 then | |
| 365 | + | local names = {} | |
| 366 | + | for _, asset in ipairs(platform_matches) do | |
| 367 | + | table.insert(names, spec.repo .. "/" .. asset.bin) | |
| 368 | + | end | |
| 369 | + | table.sort(names) | |
| 370 | + | error( | |
| 371 | + | "Multiple binaries available in '" | |
| 372 | + | .. spec.repo | |
| 373 | + | .. "' for " | |
| 374 | + | .. os_name | |
| 375 | + | .. "/" | |
| 376 | + | .. arch_name | |
| 377 | + | .. ": " | |
| 378 | + | .. table.concat(names, ", ") | |
| 379 | + | .. ". Select one explicitly with forge:<repo>/<bin>." | |
| 380 | + | ) | |
| 381 | + | end | |
| 382 | + | ||
| 383 | + | error( | |
| 384 | + | "No asset found for '" | |
| 385 | + | .. spec.repo | |
| 386 | + | .. "' (bin=" | |
| 387 | + | .. spec.bin | |
| 388 | + | .. ") on " | |
| 389 | + | .. os_name | |
| 390 | + | .. "/" | |
| 391 | + | .. arch_name | |
| 392 | + | .. " in release " | |
| 393 | + | .. tostring(release.tag or release.version) | |
| 394 | + | ) | |
| 395 | + | end | |
| 396 | + | ||
| 397 | + | function M.is_archive(name) | |
| 398 | + | local lower = string.lower(tostring(name or "")) | |
| 399 | + | for _, ext in ipairs(ARCHIVE_EXTENSIONS) do | |
| 400 | + | if ends_with(lower, ext) then | |
| 401 | + | return true | |
| 402 | + | end | |
| 403 | + | end | |
| 404 | + | return false | |
| 405 | + | end | |
| 406 | + | ||
| 407 | + | local function compute_sha256_fallback(file_path, os_name) | |
| 408 | + | local quoted = M.shell_quote(file_path) | |
| 409 | + | if os_name == "windows" then | |
| 410 | + | local ok, out = pcall( | |
| 411 | + | cmd.exec, | |
| 412 | + | 'powershell -NoProfile -Command "(Get-FileHash -Algorithm SHA256 -Path ' | |
| 413 | + | .. quoted | |
| 414 | + | .. ').Hash.ToLower()"' | |
| 415 | + | ) | |
| 416 | + | if ok and type(out) == "string" then | |
| 417 | + | local digest = out:match("([0-9a-fA-F]+)") | |
| 418 | + | if digest and #digest == 64 then | |
| 419 | + | return string.lower(digest) | |
| 420 | + | end | |
| 421 | + | end | |
| 422 | + | error("Unable to compute SHA-256 checksum on Windows (PowerShell Get-FileHash failed)") | |
| 423 | + | end | |
| 424 | + | ||
| 425 | + | local probes = { | |
| 426 | + | "sha256sum " .. quoted, | |
| 427 | + | "shasum -a 256 " .. quoted, | |
| 428 | + | "openssl dgst -sha256 -r " .. quoted, | |
| 429 | + | } | |
| 430 | + | for _, probe in ipairs(probes) do | |
| 431 | + | local ok, out = pcall(cmd.exec, probe) | |
| 432 | + | if ok and type(out) == "string" then | |
| 433 | + | local digest = out:match("^%s*([0-9a-fA-F]+)") | |
| 434 | + | if digest and #digest == 64 then | |
| 435 | + | return string.lower(digest) | |
| 436 | + | end | |
| 437 | + | end | |
| 438 | + | end | |
| 439 | + | ||
| 440 | + | error("Unable to verify SHA-256 checksum: built-in checksum module unavailable and neither sha256sum, shasum, nor openssl was found") | |
| 441 | + | end | |
| 442 | + | ||
| 443 | + | function M.verify_sha256(file_path, expected_sha256, os_name) | |
| 444 | + | if type(expected_sha256) ~= "string" or not expected_sha256:match("^[0-9a-fA-F]+$") or #expected_sha256 ~= 64 then | |
| 445 | + | error("Refusing to install asset without a valid 64-hex sha256 digest in release metadata") | |
| 446 | + | end | |
| 447 | + | local expected = string.lower(expected_sha256) | |
| 448 | + | if has_checksum and type(checksum) == "table" and type(checksum.verify) == "function" then | |
| 449 | + | checksum.verify(file_path, "sha256:" .. expected) | |
| 450 | + | return | |
| 451 | + | end | |
| 452 | + | local actual = compute_sha256_fallback(file_path, os_name) | |
| 453 | + | if actual ~= expected then | |
| 454 | + | error("SHA-256 checksum mismatch for " .. file_path .. ": expected " .. expected .. ", got " .. actual) | |
| 455 | + | end | |
| 456 | + | end | |
| 457 | + | ||
| 458 | + | local function is_truthy(val) | |
| 459 | + | if val == true then | |
| 460 | + | return true | |
| 461 | + | end | |
| 462 | + | if type(val) ~= "string" then | |
| 463 | + | return false | |
| 464 | + | end | |
| 465 | + | local lower = string.lower(trim(val)) | |
| 466 | + | return lower == "1" or lower == "true" or lower == "yes" | |
| 467 | + | end | |
| 468 | + | ||
| 469 | + | function M.maybe_verify_cosign(base_url, release, asset, file_path, temp_dir, options) | |
| 470 | + | local enabled = (type(options) == "table" and is_truthy(options.verify_cosign)) | |
| 471 | + | or is_truthy(os.getenv("MISE_FORGE_VERIFY_COSIGN")) | |
| 472 | + | if not enabled then | |
| 473 | + | return | |
| 474 | + | end | |
| 475 | + | ||
| 476 | + | if type(asset.signature_url) ~= "string" or trim(asset.signature_url) == "" then | |
| 477 | + | error("Cosign verification requested, but asset has no signature_url") | |
| 478 | + | end | |
| 479 | + | if type(release.key_url) ~= "string" or trim(release.key_url) == "" then | |
| 480 | + | error("Cosign verification requested, but release has no key_url") | |
| 481 | + | end | |
| 482 | + | ||
| 483 | + | local sig_url = M.resolve_url(base_url, asset.signature_url) | |
| 484 | + | local key_url = M.resolve_url(base_url, release.key_url) | |
| 485 | + | local sig_path = file.join_path(temp_dir, "asset.sig") | |
| 486 | + | local key_path = file.join_path(temp_dir, "release.pub") | |
| 487 | + | ||
| 488 | + | http.download_file({ url = sig_url, headers = M.http_headers() }, sig_path) | |
| 489 | + | http.download_file({ url = key_url, headers = M.http_headers() }, key_path) | |
| 490 | + | ||
| 491 | + | local command | |
| 492 | + | if ends_with(string.lower(sig_url), ".bundle") then | |
| 493 | + | command = "cosign verify-blob --key " | |
| 494 | + | .. M.shell_quote(key_path) | |
| 495 | + | .. " --bundle " | |
| 496 | + | .. M.shell_quote(sig_path) | |
| 497 | + | .. " --insecure-ignore-tlog " | |
| 498 | + | .. M.shell_quote(file_path) | |
| 499 | + | else | |
| 500 | + | command = "cosign verify-blob --key " | |
| 501 | + | .. M.shell_quote(key_path) | |
| 502 | + | .. " --signature " | |
| 503 | + | .. M.shell_quote(sig_path) | |
| 504 | + | .. " --insecure-ignore-tlog " | |
| 505 | + | .. M.shell_quote(file_path) | |
| 506 | + | end | |
| 507 | + | ||
| 508 | + | local ok, out = pcall(cmd.exec, command) | |
| 509 | + | if not ok then | |
| 510 | + | error("Cosign verification failed: " .. tostring(out)) | |
| 511 | + | end | |
| 512 | + | end | |
| 513 | + | ||
| 514 | + | local function make_executable(path, os_name) | |
| 515 | + | if os_name == "windows" then | |
| 516 | + | return | |
| 517 | + | end | |
| 518 | + | if type(file.chmod) == "function" then | |
| 519 | + | local ok = pcall(file.chmod, path, 493) -- 0755 | |
| 520 | + | if ok then | |
| 521 | + | return | |
| 522 | + | end | |
| 523 | + | end | |
| 524 | + | cmd.exec("chmod +x " .. M.shell_quote(path)) | |
| 525 | + | end | |
| 526 | + | ||
| 527 | + | local function find_extracted_binary(extract_dir, target_bin, os_name) | |
| 528 | + | local direct = file.join_path(extract_dir, target_bin) | |
| 529 | + | if file.exists(direct) then | |
| 530 | + | return direct, "root" | |
| 531 | + | end | |
| 532 | + | ||
| 533 | + | local in_bin = file.join_path(extract_dir, "bin", target_bin) | |
| 534 | + | if file.exists(in_bin) then | |
| 535 | + | return in_bin, "bin" | |
| 536 | + | end | |
| 537 | + | ||
| 538 | + | -- Search nested directories (e.g. single top-level folder inside tarball) | |
| 539 | + | if os_name == "windows" then | |
| 540 | + | local ok, out = pcall( | |
| 541 | + | cmd.exec, | |
| 542 | + | 'powershell -NoProfile -Command "Get-ChildItem -Path ' | |
| 543 | + | .. M.shell_quote(extract_dir) | |
| 544 | + | .. " -Recurse -File -Filter " | |
| 545 | + | .. M.shell_quote(target_bin) | |
| 546 | + | .. ' | Select-Object -First 1 -ExpandProperty FullName"' | |
| 547 | + | ) | |
| 548 | + | if ok and type(out) == "string" and trim(out) ~= "" then | |
| 549 | + | return trim(out), "nested" | |
| 550 | + | end | |
| 551 | + | else | |
| 552 | + | local ok, out = pcall( | |
| 553 | + | cmd.exec, | |
| 554 | + | "find " | |
| 555 | + | .. M.shell_quote(extract_dir) | |
| 556 | + | .. " -maxdepth 4 -type f -name " | |
| 557 | + | .. M.shell_quote(target_bin) | |
| 558 | + | .. " | head -n 1" | |
| 559 | + | ) | |
| 560 | + | if ok and type(out) == "string" and trim(out) ~= "" then | |
| 561 | + | return trim(out), "nested" | |
| 562 | + | end | |
| 563 | + | end | |
| 564 | + | ||
| 565 | + | return nil, nil | |
| 566 | + | end | |
| 567 | + | ||
| 568 | + | function M.mkdir_p(path, os_name) | |
| 569 | + | if type(file.mkdir) == "function" then | |
| 570 | + | file.mkdir(path) | |
| 571 | + | return | |
| 572 | + | end | |
| 573 | + | if os_name == "windows" then | |
| 574 | + | cmd.exec( | |
| 575 | + | 'powershell -NoProfile -Command "New-Item -ItemType Directory -Force -Path ' | |
| 576 | + | .. M.shell_quote(path) | |
| 577 | + | .. ' | Out-Null"' | |
| 578 | + | ) | |
| 579 | + | else | |
| 580 | + | cmd.exec("mkdir -p " .. M.shell_quote(path)) | |
| 581 | + | end | |
| 582 | + | end | |
| 583 | + | ||
| 584 | + | function M.remove_rf(path, os_name) | |
| 585 | + | if not file.exists(path) then | |
| 586 | + | return | |
| 587 | + | end | |
| 588 | + | if type(file.remove) == "function" then | |
| 589 | + | file.remove(path) | |
| 590 | + | return | |
| 591 | + | end | |
| 592 | + | if os_name == "windows" then | |
| 593 | + | cmd.exec( | |
| 594 | + | 'powershell -NoProfile -Command "Remove-Item -Recurse -Force -Path ' | |
| 595 | + | .. M.shell_quote(path) | |
| 596 | + | .. '"' | |
| 597 | + | ) | |
| 598 | + | else | |
| 599 | + | cmd.exec("rm -rf " .. M.shell_quote(path)) | |
| 600 | + | end | |
| 601 | + | end | |
| 602 | + | ||
| 603 | + | function M.move_path(src, dest, os_name) | |
| 604 | + | if type(file.move) == "function" then | |
| 605 | + | file.move(src, dest) | |
| 606 | + | return | |
| 607 | + | end | |
| 608 | + | local ok = os.rename(src, dest) | |
| 609 | + | if ok then | |
| 610 | + | return | |
| 611 | + | end | |
| 612 | + | if os_name == "windows" then | |
| 613 | + | cmd.exec( | |
| 614 | + | 'powershell -NoProfile -Command "Move-Item -Force -Path ' | |
| 615 | + | .. M.shell_quote(src) | |
| 616 | + | .. " -Destination " | |
| 617 | + | .. M.shell_quote(dest) | |
| 618 | + | .. '"' | |
| 619 | + | ) | |
| 620 | + | else | |
| 621 | + | cmd.exec("mv -f " .. M.shell_quote(src) .. " " .. M.shell_quote(dest)) | |
| 622 | + | end | |
| 623 | + | end | |
| 624 | + | ||
| 625 | + | function M.install_asset(downloaded_path, asset, install_path, download_path, os_name) | |
| 626 | + | local bin_dir = file.join_path(install_path, "bin") | |
| 627 | + | M.mkdir_p(bin_dir, os_name) | |
| 628 | + | ||
| 629 | + | local target_bin = asset.bin | |
| 630 | + | if os_name == "windows" and not ends_with(string.lower(target_bin), ".exe") then | |
| 631 | + | target_bin = target_bin .. ".exe" | |
| 632 | + | end | |
| 633 | + | local dest_bin = file.join_path(bin_dir, target_bin) | |
| 634 | + | ||
| 635 | + | local asset_name = asset.name or asset.bin | |
| 636 | + | if M.is_archive(asset_name) then | |
| 637 | + | local extract_dir = file.join_path(download_path, "extract") | |
| 638 | + | M.remove_rf(extract_dir, os_name) | |
| 639 | + | archiver.decompress(downloaded_path, extract_dir) | |
| 640 | + | ||
| 641 | + | local found_path, layout = find_extracted_binary(extract_dir, target_bin, os_name) | |
| 642 | + | if not found_path then | |
| 643 | + | error("Archive '" .. asset_name .. "' did not contain expected binary '" .. target_bin .. "'") | |
| 644 | + | end | |
| 645 | + | ||
| 646 | + | if layout == "bin" then | |
| 647 | + | -- Preserve sibling binaries shipped inside the archive's bin/ directory. | |
| 648 | + | local src_bin_dir = file.join_path(extract_dir, "bin") | |
| 649 | + | M.remove_rf(bin_dir, os_name) | |
| 650 | + | M.move_path(src_bin_dir, bin_dir, os_name) | |
| 651 | + | make_executable(dest_bin, os_name) | |
| 652 | + | else | |
| 653 | + | M.move_path(found_path, dest_bin, os_name) | |
| 654 | + | make_executable(dest_bin, os_name) | |
| 655 | + | end | |
| 656 | + | ||
| 657 | + | M.remove_rf(extract_dir, os_name) | |
| 658 | + | else | |
| 659 | + | M.move_path(downloaded_path, dest_bin, os_name) | |
| 660 | + | make_executable(dest_bin, os_name) | |
| 661 | + | end | |
| 662 | + | ||
| 663 | + | return dest_bin | |
| 664 | + | end | |
| 665 | + | ||
| 666 | + | return M |
metadata.lua+7−0
| @@ -0,0 +1,7 @@ | |||
| 1 | + | PLUGIN = { | |
| 2 | + | name = "forge", | |
| 3 | + | version = "0.1.0", | |
| 4 | + | description = "Mise backend plugin for Cleyrop's public forge (code.cleyrop.tech)", | |
| 5 | + | homepage = "https://code.cleyrop.tech/mise", | |
| 6 | + | license = "Apache-2.0", | |
| 7 | + | } |
tests/e2e.py+615−0
| @@ -0,0 +1,615 @@ | |||
| 1 | + | #!/usr/bin/env python3 | |
| 2 | + | """End-to-end test suite for the Cleyrop Forge mise backend plugin. | |
| 3 | + | ||
| 4 | + | Starts a local HTTP server implementing docs/PUBLIC-FORGE-API.md and drives the | |
| 5 | + | real `mise` binary inside an isolated temporary data/cache/config environment. | |
| 6 | + | """ | |
| 7 | + | ||
| 8 | + | from __future__ import annotations | |
| 9 | + | ||
| 10 | + | import hashlib | |
| 11 | + | import http.server | |
| 12 | + | import io | |
| 13 | + | import json | |
| 14 | + | import os | |
| 15 | + | import platform | |
| 16 | + | import shutil | |
| 17 | + | import socketserver | |
| 18 | + | import stat | |
| 19 | + | import subprocess | |
| 20 | + | import sys | |
| 21 | + | import tarfile | |
| 22 | + | import tempfile | |
| 23 | + | import threading | |
| 24 | + | import urllib.parse | |
| 25 | + | from pathlib import Path | |
| 26 | + | ||
| 27 | + | REPO_ROOT = Path(__file__).resolve().parent.parent | |
| 28 | + | ||
| 29 | + | ||
| 30 | + | def host_platform() -> tuple[str, str]: | |
| 31 | + | sys_name = platform.system().lower() | |
| 32 | + | if sys_name == "darwin": | |
| 33 | + | os_name = "darwin" | |
| 34 | + | elif sys_name == "linux": | |
| 35 | + | os_name = "linux" | |
| 36 | + | elif sys_name.startswith("win"): | |
| 37 | + | os_name = "windows" | |
| 38 | + | else: | |
| 39 | + | raise RuntimeError(f"Unsupported OS: {sys_name}") | |
| 40 | + | ||
| 41 | + | machine = platform.machine().lower() | |
| 42 | + | if machine in ("arm64", "aarch64"): | |
| 43 | + | arch_name = "arm64" | |
| 44 | + | elif machine in ("x86_64", "amd64"): | |
| 45 | + | arch_name = "amd64" | |
| 46 | + | else: | |
| 47 | + | raise RuntimeError(f"Unsupported arch: {machine}") | |
| 48 | + | ||
| 49 | + | return os_name, arch_name | |
| 50 | + | ||
| 51 | + | ||
| 52 | + | def make_script_bytes(name: str, version: str) -> bytes: | |
| 53 | + | return f"#!/bin/sh\necho '{name} {version}'\n".encode("utf-8") | |
| 54 | + | ||
| 55 | + | ||
| 56 | + | def make_tar_gz(entries: dict[str, bytes]) -> bytes: | |
| 57 | + | buf = io.BytesIO() | |
| 58 | + | with tarfile.open(fileobj=buf, mode="w:gz") as tf: | |
| 59 | + | for arcname, payload in entries.items(): | |
| 60 | + | info = tarfile.TarInfo(name=arcname) | |
| 61 | + | info.size = len(payload) | |
| 62 | + | info.mode = 0o755 | |
| 63 | + | tf.addfile(info, io.BytesIO(payload)) | |
| 64 | + | return buf.getvalue() | |
| 65 | + | ||
| 66 | + | ||
| 67 | + | def sha256_hex(data: bytes) -> str: | |
| 68 | + | return hashlib.sha256(data).hexdigest() | |
| 69 | + | ||
| 70 | + | ||
| 71 | + | class MockForgeState: | |
| 72 | + | def __init__(self, base_url: str, os_name: str, arch_name: str) -> None: | |
| 73 | + | self.base_url = base_url | |
| 74 | + | self.downloads: dict[tuple[str, str, str], bytes] = {} | |
| 75 | + | self.repos_list: list[dict] = [] | |
| 76 | + | self.releases_by_repo: dict[str, list[dict]] = {} | |
| 77 | + | self.page_size_by_repo: dict[str, int] = {} | |
| 78 | + | ||
| 79 | + | def add_asset( | |
| 80 | + | repo: str, | |
| 81 | + | tag: str, | |
| 82 | + | filename: str, | |
| 83 | + | payload: bytes, | |
| 84 | + | bin_name: str | None, | |
| 85 | + | asset_os: str | None, | |
| 86 | + | asset_arch: str | None, | |
| 87 | + | override_sha: str | None = None, | |
| 88 | + | ) -> dict: | |
| 89 | + | self.downloads[(repo, tag, filename)] = payload | |
| 90 | + | return { | |
| 91 | + | "name": filename, | |
| 92 | + | "bin": bin_name, | |
| 93 | + | "os": asset_os, | |
| 94 | + | "arch": asset_arch, | |
| 95 | + | "sha256": override_sha or sha256_hex(payload), | |
| 96 | + | "size": len(payload), | |
| 97 | + | "url": f"{base_url}/{repo}/releases/download/{tag}/{filename}", | |
| 98 | + | "signature_url": None, | |
| 99 | + | } | |
| 100 | + | ||
| 101 | + | # 1. roneo: 3 releases across 2 pages (tests pagination + oldest-first reversal + nested tarball + unplaced asset) | |
| 102 | + | roneo_010_tgz = make_tar_gz( | |
| 103 | + | {f"roneo-0.1.0-{os_name}-{arch_name}/roneo": make_script_bytes("roneo", "0.1.0")} | |
| 104 | + | ) | |
| 105 | + | roneo_020rc_tgz = make_tar_gz({"bin/roneo": make_script_bytes("roneo", "0.2.0-rc.1")}) | |
| 106 | + | roneo_020_tgz = make_tar_gz({"roneo": make_script_bytes("roneo", "0.2.0")}) | |
| 107 | + | source_tgz = make_tar_gz({"README.md": b"source archive\n"}) | |
| 108 | + | ||
| 109 | + | self.releases_by_repo["roneo"] = [ | |
| 110 | + | { | |
| 111 | + | "version": "0.2.0", | |
| 112 | + | "tag": "v0.2.0", | |
| 113 | + | "commit": "2" * 40, | |
| 114 | + | "published_at": "2026-11-03T10:00:00Z", | |
| 115 | + | "prerelease": False, | |
| 116 | + | "checksums_url": f"{base_url}/roneo/releases/download/v0.2.0/SHA256SUMS", | |
| 117 | + | "key_url": f"{base_url}/api/v1/keys/release.pub", | |
| 118 | + | "assets": [ | |
| 119 | + | add_asset("roneo", "v0.2.0", "roneo-0.2.0-src.tar.gz", source_tgz, None, None, None), | |
| 120 | + | add_asset( | |
| 121 | + | "roneo", | |
| 122 | + | "v0.2.0", | |
| 123 | + | f"roneo-0.2.0-{os_name}-{arch_name}.tar.gz", | |
| 124 | + | roneo_020_tgz, | |
| 125 | + | "roneo", | |
| 126 | + | os_name, | |
| 127 | + | arch_name, | |
| 128 | + | ), | |
| 129 | + | ], | |
| 130 | + | }, | |
| 131 | + | { | |
| 132 | + | "version": "0.2.0-rc.1", | |
| 133 | + | "tag": "v0.2.0-rc.1", | |
| 134 | + | "commit": "b" * 40, | |
| 135 | + | "published_at": "2026-11-02T10:00:00Z", | |
| 136 | + | "prerelease": True, | |
| 137 | + | "checksums_url": f"{base_url}/roneo/releases/download/v0.2.0-rc.1/SHA256SUMS", | |
| 138 | + | "key_url": f"{base_url}/api/v1/keys/release.pub", | |
| 139 | + | "assets": [ | |
| 140 | + | add_asset( | |
| 141 | + | "roneo", | |
| 142 | + | "v0.2.0-rc.1", | |
| 143 | + | f"roneo-0.2.0-rc.1-{os_name}-{arch_name}.tar.gz", | |
| 144 | + | roneo_020rc_tgz, | |
| 145 | + | "roneo", | |
| 146 | + | os_name, | |
| 147 | + | arch_name, | |
| 148 | + | ), | |
| 149 | + | ], | |
| 150 | + | }, | |
| 151 | + | { | |
| 152 | + | "version": "0.1.0", | |
| 153 | + | "tag": "v0.1.0", | |
| 154 | + | "commit": "1" * 40, | |
| 155 | + | "published_at": "2026-11-01T10:00:00Z", | |
| 156 | + | "prerelease": False, | |
| 157 | + | "checksums_url": f"{base_url}/roneo/releases/download/v0.1.0/SHA256SUMS", | |
| 158 | + | "key_url": f"{base_url}/api/v1/keys/release.pub", | |
| 159 | + | "assets": [ | |
| 160 | + | add_asset( | |
| 161 | + | "roneo", | |
| 162 | + | "v0.1.0", | |
| 163 | + | f"roneo-0.1.0-{os_name}-{arch_name}.tar.gz", | |
| 164 | + | roneo_010_tgz, | |
| 165 | + | "roneo", | |
| 166 | + | os_name, | |
| 167 | + | arch_name, | |
| 168 | + | ), | |
| 169 | + | ], | |
| 170 | + | }, | |
| 171 | + | ] | |
| 172 | + | self.page_size_by_repo["roneo"] = 2 # Forces Link rel="next" pagination | |
| 173 | + | ||
| 174 | + | # 2. suite: multi-binary repo (alpha in 1.0.0 & 1.1.0, beta only in 1.1.0) | |
| 175 | + | alpha_100 = make_tar_gz({"alpha": make_script_bytes("alpha", "1.0.0")}) | |
| 176 | + | alpha_110 = make_tar_gz({"alpha": make_script_bytes("alpha", "1.1.0")}) | |
| 177 | + | beta_110 = make_tar_gz({"beta": make_script_bytes("beta", "1.1.0")}) | |
| 178 | + | self.releases_by_repo["suite"] = [ | |
| 179 | + | { | |
| 180 | + | "version": "1.1.0", | |
| 181 | + | "tag": "v1.1.0", | |
| 182 | + | "commit": "3" * 40, | |
| 183 | + | "published_at": "2026-11-04T10:00:00Z", | |
| 184 | + | "prerelease": False, | |
| 185 | + | "checksums_url": f"{base_url}/suite/releases/download/v1.1.0/SHA256SUMS", | |
| 186 | + | "key_url": None, | |
| 187 | + | "assets": [ | |
| 188 | + | add_asset( | |
| 189 | + | "suite", | |
| 190 | + | "v1.1.0", | |
| 191 | + | f"alpha-1.1.0-{os_name}-{arch_name}.tar.gz", | |
| 192 | + | alpha_110, | |
| 193 | + | "alpha", | |
| 194 | + | os_name, | |
| 195 | + | arch_name, | |
| 196 | + | ), | |
| 197 | + | add_asset( | |
| 198 | + | "suite", | |
| 199 | + | "v1.1.0", | |
| 200 | + | f"beta-1.1.0-{os_name}-{arch_name}.tar.gz", | |
| 201 | + | beta_110, | |
| 202 | + | "beta", | |
| 203 | + | os_name, | |
| 204 | + | arch_name, | |
| 205 | + | ), | |
| 206 | + | ], | |
| 207 | + | }, | |
| 208 | + | { | |
| 209 | + | "version": "1.0.0", | |
| 210 | + | "tag": "v1.0.0", | |
| 211 | + | "commit": "4" * 40, | |
| 212 | + | "published_at": "2026-11-01T10:00:00Z", | |
| 213 | + | "prerelease": False, | |
| 214 | + | "checksums_url": f"{base_url}/suite/releases/download/v1.0.0/SHA256SUMS", | |
| 215 | + | "key_url": None, | |
| 216 | + | "assets": [ | |
| 217 | + | add_asset( | |
| 218 | + | "suite", | |
| 219 | + | "v1.0.0", | |
| 220 | + | f"alpha-1.0.0-{os_name}-{arch_name}.tar.gz", | |
| 221 | + | alpha_100, | |
| 222 | + | "alpha", | |
| 223 | + | os_name, | |
| 224 | + | arch_name, | |
| 225 | + | ), | |
| 226 | + | ], | |
| 227 | + | }, | |
| 228 | + | ] | |
| 229 | + | ||
| 230 | + | # 3. prefixed: tag uses `<prefix>-v<semver>` format (prefixed-v2.0.0) | |
| 231 | + | prefixed_200 = make_tar_gz({"prefixed": make_script_bytes("prefixed", "2.0.0")}) | |
| 232 | + | self.releases_by_repo["prefixed"] = [ | |
| 233 | + | { | |
| 234 | + | "version": "2.0.0", | |
| 235 | + | "tag": "prefixed-v2.0.0", | |
| 236 | + | "commit": "5" * 40, | |
| 237 | + | "published_at": "2026-11-04T11:00:00Z", | |
| 238 | + | "prerelease": False, | |
| 239 | + | "checksums_url": f"{base_url}/prefixed/releases/download/prefixed-v2.0.0/SHA256SUMS", | |
| 240 | + | "key_url": None, | |
| 241 | + | "assets": [ | |
| 242 | + | add_asset( | |
| 243 | + | "prefixed", | |
| 244 | + | "prefixed-v2.0.0", | |
| 245 | + | f"prefixed-2.0.0-{os_name}-{arch_name}.tar.gz", | |
| 246 | + | prefixed_200, | |
| 247 | + | "prefixed", | |
| 248 | + | os_name, | |
| 249 | + | arch_name, | |
| 250 | + | ), | |
| 251 | + | ], | |
| 252 | + | } | |
| 253 | + | ] | |
| 254 | + | ||
| 255 | + | # 4. rawtool: standalone raw binary (no archive) | |
| 256 | + | raw_bin = make_script_bytes("rawtool", "1.0.0") | |
| 257 | + | self.releases_by_repo["rawtool"] = [ | |
| 258 | + | { | |
| 259 | + | "version": "1.0.0", | |
| 260 | + | "tag": "v1.0.0", | |
| 261 | + | "commit": "6" * 40, | |
| 262 | + | "published_at": "2026-11-04T12:00:00Z", | |
| 263 | + | "prerelease": False, | |
| 264 | + | "checksums_url": f"{base_url}/rawtool/releases/download/v1.0.0/SHA256SUMS", | |
| 265 | + | "key_url": None, | |
| 266 | + | "assets": [ | |
| 267 | + | add_asset( | |
| 268 | + | "rawtool", | |
| 269 | + | "v1.0.0", | |
| 270 | + | f"rawtool-1.0.0-{os_name}-{arch_name}", | |
| 271 | + | raw_bin, | |
| 272 | + | "rawtool", | |
| 273 | + | os_name, | |
| 274 | + | arch_name, | |
| 275 | + | ), | |
| 276 | + | ], | |
| 277 | + | } | |
| 278 | + | ] | |
| 279 | + | ||
| 280 | + | # 5. badhash: deliberately mismatched sha256 (must fail closed) | |
| 281 | + | bad_tgz = make_tar_gz({"badhash": make_script_bytes("badhash", "1.0.0")}) | |
| 282 | + | self.releases_by_repo["badhash"] = [ | |
| 283 | + | { | |
| 284 | + | "version": "1.0.0", | |
| 285 | + | "tag": "v1.0.0", | |
| 286 | + | "commit": "7" * 40, | |
| 287 | + | "published_at": "2026-11-04T12:00:00Z", | |
| 288 | + | "prerelease": False, | |
| 289 | + | "checksums_url": f"{base_url}/badhash/releases/download/v1.0.0/SHA256SUMS", | |
| 290 | + | "key_url": None, | |
| 291 | + | "assets": [ | |
| 292 | + | add_asset( | |
| 293 | + | "badhash", | |
| 294 | + | "v1.0.0", | |
| 295 | + | f"badhash-1.0.0-{os_name}-{arch_name}.tar.gz", | |
| 296 | + | bad_tgz, | |
| 297 | + | "badhash", | |
| 298 | + | os_name, | |
| 299 | + | arch_name, | |
| 300 | + | override_sha="0" * 64, | |
| 301 | + | ), | |
| 302 | + | ], | |
| 303 | + | } | |
| 304 | + | ] | |
| 305 | + | ||
| 306 | + | self.repos_list = [ | |
| 307 | + | { | |
| 308 | + | "name": "roneo", | |
| 309 | + | "description": "Fast standalone Rust port of Copier", | |
| 310 | + | "licence": "Apache-2.0", | |
| 311 | + | "topics": ["rust", "templates"], | |
| 312 | + | "latest_release": "0.2.0", | |
| 313 | + | "latest_tag": "v0.2.0", | |
| 314 | + | }, | |
| 315 | + | { | |
| 316 | + | "name": "suite", | |
| 317 | + | "description": "Multi-binary CLI suite", | |
| 318 | + | "licence": "Apache-2.0", | |
| 319 | + | "topics": ["cli"], | |
| 320 | + | "latest_release": "1.1.0", | |
| 321 | + | "latest_tag": "v1.1.0", | |
| 322 | + | }, | |
| 323 | + | { | |
| 324 | + | "name": "unreleased", | |
| 325 | + | "description": "Library with no releases yet", | |
| 326 | + | "licence": "Apache-2.0", | |
| 327 | + | "topics": ["lib"], | |
| 328 | + | "latest_release": None, | |
| 329 | + | "latest_tag": None, | |
| 330 | + | }, | |
| 331 | + | ] | |
| 332 | + | ||
| 333 | + | ||
| 334 | + | def make_handler(state: MockForgeState): | |
| 335 | + | class Handler(http.server.BaseHTTPRequestHandler): | |
| 336 | + | def log_message(self, format: str, *args) -> None: | |
| 337 | + | return | |
| 338 | + | ||
| 339 | + | def send_json(self, code: int, payload, extra_headers: dict[str, str] | None = None) -> None: | |
| 340 | + | body = json.dumps(payload).encode("utf-8") | |
| 341 | + | self.send_response(code) | |
| 342 | + | self.send_header("Content-Type", "application/json") | |
| 343 | + | self.send_header("Content-Length", str(len(body))) | |
| 344 | + | if extra_headers: | |
| 345 | + | for k, v in extra_headers.items(): | |
| 346 | + | self.send_header(k, v) | |
| 347 | + | self.end_headers() | |
| 348 | + | self.wfile.write(body) | |
| 349 | + | ||
| 350 | + | def do_GET(self) -> None: | |
| 351 | + | parsed = urllib.parse.urlparse(self.path) | |
| 352 | + | path = parsed.path | |
| 353 | + | qs = urllib.parse.parse_qs(parsed.query) | |
| 354 | + | ||
| 355 | + | if path == "/api/v1/repos": | |
| 356 | + | self.send_json(200, self.server.state.repos_list) | |
| 357 | + | return | |
| 358 | + | ||
| 359 | + | parts = [p for p in path.split("/") if p] | |
| 360 | + | # /api/v1/repos/<repo>/releases[/<tag|latest>] | |
| 361 | + | if len(parts) in (5, 6) and parts[:3] == ["api", "v1", "repos"] and parts[4] == "releases": | |
| 362 | + | repo = parts[3] | |
| 363 | + | releases = self.server.state.releases_by_repo.get(repo) | |
| 364 | + | if releases is None: | |
| 365 | + | self.send_json(404, {"error": "not found"}) | |
| 366 | + | return | |
| 367 | + | ||
| 368 | + | if len(parts) == 5: | |
| 369 | + | page = int(qs.get("page", ["1"])[0]) | |
| 370 | + | page_size = self.server.state.page_size_by_repo.get(repo, 100) | |
| 371 | + | start = (page - 1) * page_size | |
| 372 | + | end = start + page_size | |
| 373 | + | chunk = releases[start:end] | |
| 374 | + | headers = {} | |
| 375 | + | if end < len(releases): | |
| 376 | + | next_url = f"{self.server.state.base_url}/api/v1/repos/{repo}/releases?page={page + 1}" | |
| 377 | + | headers["Link"] = f'<{next_url}>; rel="next"' | |
| 378 | + | self.send_json(200, chunk, headers) | |
| 379 | + | return | |
| 380 | + | ||
| 381 | + | tag = parts[5] | |
| 382 | + | if tag == "latest": | |
| 383 | + | stable = [r for r in releases if not r["prerelease"]] | |
| 384 | + | chosen = stable[0] if stable else releases[0] | |
| 385 | + | self.send_json(200, chosen) | |
| 386 | + | return | |
| 387 | + | ||
| 388 | + | for rel in releases: | |
| 389 | + | if rel["tag"] == tag: | |
| 390 | + | self.send_json(200, rel) | |
| 391 | + | return | |
| 392 | + | self.send_json(404, {"error": "tag not found"}) | |
| 393 | + | return | |
| 394 | + | ||
| 395 | + | # /<repo>/releases/download/<tag>/<asset> | |
| 396 | + | if len(parts) == 5 and parts[1] == "releases" and parts[2] == "download": | |
| 397 | + | key = (parts[0], parts[3], parts[4]) | |
| 398 | + | blob = self.server.state.downloads.get(key) | |
| 399 | + | if blob is None: | |
| 400 | + | self.send_json(404, {"error": "asset not found"}) | |
| 401 | + | return | |
| 402 | + | self.send_response(200) | |
| 403 | + | self.send_header("Content-Type", "application/octet-stream") | |
| 404 | + | self.send_header("Content-Length", str(len(blob))) | |
| 405 | + | self.end_headers() | |
| 406 | + | self.wfile.write(blob) | |
| 407 | + | return | |
| 408 | + | ||
| 409 | + | self.send_json(404, {"error": "unknown route"}) | |
| 410 | + | ||
| 411 | + | return Handler | |
| 412 | + | ||
| 413 | + | ||
| 414 | + | class ReusableThreadingHTTPServer(socketserver.ThreadingMixIn, http.server.HTTPServer): | |
| 415 | + | daemon_threads = True | |
| 416 | + | allow_reuse_address = True | |
| 417 | + | ||
| 418 | + | ||
| 419 | + | def run_mise(args: list[str], env: dict[str, str], cwd: Path, expect_ok: bool = True) -> subprocess.CompletedProcess: | |
| 420 | + | proc = subprocess.run( | |
| 421 | + | ["mise", *args], | |
| 422 | + | cwd=str(cwd), | |
| 423 | + | env=env, | |
| 424 | + | capture_output=True, | |
| 425 | + | text=True, | |
| 426 | + | check=False, | |
| 427 | + | ) | |
| 428 | + | if expect_ok and proc.returncode != 0: | |
| 429 | + | raise AssertionError( | |
| 430 | + | f"`mise {' '.join(args)}` failed (exit {proc.returncode}):\n" | |
| 431 | + | f"STDOUT:\n{proc.stdout}\nSTDERR:\n{proc.stderr}" | |
| 432 | + | ) | |
| 433 | + | if not expect_ok and proc.returncode == 0: | |
| 434 | + | raise AssertionError( | |
| 435 | + | f"`mise {' '.join(args)}` was expected to fail, but succeeded:\n" | |
| 436 | + | f"STDOUT:\n{proc.stdout}\nSTDERR:\n{proc.stderr}" | |
| 437 | + | ) | |
| 438 | + | return proc | |
| 439 | + | ||
| 440 | + | ||
| 441 | + | def main() -> None: | |
| 442 | + | if shutil.which("mise") is None: | |
| 443 | + | print("SKIP: `mise` binary not found in PATH", file=sys.stderr) | |
| 444 | + | sys.exit(1) | |
| 445 | + | ||
| 446 | + | os_name, arch_name = host_platform() | |
| 447 | + | server = ReusableThreadingHTTPServer(("127.0.0.1", 0), None) | |
| 448 | + | port = server.server_address[1] | |
| 449 | + | base_url = f"http://127.0.0.1:{port}" | |
| 450 | + | state = MockForgeState(base_url, os_name, arch_name) | |
| 451 | + | server.state = state | |
| 452 | + | server.RequestHandlerClass = make_handler(state) | |
| 453 | + | ||
| 454 | + | thread = threading.Thread(target=server.serve_forever, daemon=True) | |
| 455 | + | thread.start() | |
| 456 | + | ||
| 457 | + | try: | |
| 458 | + | with tempfile.TemporaryDirectory(prefix="mise-plugin-e2e-") as tmp: | |
| 459 | + | root = Path(tmp) | |
| 460 | + | workdir = root / "project" | |
| 461 | + | workdir.mkdir() | |
| 462 | + | ||
| 463 | + | env = os.environ.copy() | |
| 464 | + | env.update( | |
| 465 | + | { | |
| 466 | + | "MISE_DATA_DIR": str(root / "data"), | |
| 467 | + | "MISE_CACHE_DIR": str(root / "cache"), | |
| 468 | + | "MISE_CONFIG_DIR": str(root / "config"), | |
| 469 | + | "MISE_STATE_DIR": str(root / "state"), | |
| 470 | + | "MISE_GLOBAL_CONFIG_FILE": str(root / "config" / "config.toml"), | |
| 471 | + | "MISE_FORGE_URL": base_url, | |
| 472 | + | "MISE_YES": "1", | |
| 473 | + | "MISE_PARANOID": "0", | |
| 474 | + | "MISE_MINIMUM_RELEASE_AGE": "0", | |
| 475 | + | } | |
| 476 | + | ) | |
| 477 | + | ||
| 478 | + | # 1. Link local plugin under the `forge` backend prefix. | |
| 479 | + | run_mise(["plugins", "link", "forge", str(REPO_ROOT)], env, workdir) | |
| 480 | + | print("[OK] linked local plugin as `forge`") | |
| 481 | + | ||
| 482 | + | # 2. Paginated ls-remote (oldest-first order, prerelease filtering, created_at metadata). | |
| 483 | + | res = run_mise(["ls-remote", "forge:roneo"], env, workdir) | |
| 484 | + | versions = [line.strip() for line in res.stdout.splitlines() if line.strip()] | |
| 485 | + | assert versions == ["0.1.0", "0.2.0"], f"Unexpected stable versions: {versions}" | |
| 486 | + | ||
| 487 | + | res_pre = run_mise(["ls-remote", "--prerelease", "forge:roneo"], env, workdir) | |
| 488 | + | versions_pre = [line.strip() for line in res_pre.stdout.splitlines() if line.strip()] | |
| 489 | + | assert versions_pre == ["0.1.0", "0.2.0-rc.1", "0.2.0"], f"Unexpected prerelease versions: {versions_pre}" | |
| 490 | + | ||
| 491 | + | res_json = run_mise(["ls-remote", "--json", "forge:roneo"], env, workdir) | |
| 492 | + | json_versions = json.loads(res_json.stdout) | |
| 493 | + | assert json_versions[0]["version"] == "0.1.0" | |
| 494 | + | assert json_versions[0]["created_at"].startswith("2026-11-01") | |
| 495 | + | print(f"[OK] paginated ls-remote forge:roneo -> stable={versions}, all={versions_pre}") | |
| 496 | + | ||
| 497 | + | # 3. Install pinned version (nested tarball layout) & execute. | |
| 498 | + | run_mise(["install", "forge:roneo@0.1.0"], env, workdir) | |
| 499 | + | out = run_mise(["exec", "forge:roneo@0.1.0", "--", "roneo", "--version"], env, workdir) | |
| 500 | + | assert out.stdout.strip() == "roneo 0.1.0", f"Unexpected output: {out.stdout!r}" | |
| 501 | + | print("[OK] installed & ran forge:roneo@0.1.0 (nested tarball)") | |
| 502 | + | ||
| 503 | + | # 4. Install latest (skips unplaced source tarball & prerelease) & execute. | |
| 504 | + | run_mise(["install", "forge:roneo@latest"], env, workdir) | |
| 505 | + | out = run_mise(["exec", "forge:roneo@latest", "--", "roneo", "--version"], env, workdir) | |
| 506 | + | assert out.stdout.strip() == "roneo 0.2.0", f"Unexpected output: {out.stdout!r}" | |
| 507 | + | print("[OK] installed & ran forge:roneo@latest -> 0.2.0") | |
| 508 | + | ||
| 509 | + | # 5. Install prerelease with bin/ archive layout. | |
| 510 | + | run_mise(["install", "forge:roneo@0.2.0-rc.1"], env, workdir) | |
| 511 | + | out = run_mise(["exec", "forge:roneo@0.2.0-rc.1", "--", "roneo", "--version"], env, workdir) | |
| 512 | + | assert out.stdout.strip() == "roneo 0.2.0-rc.1", f"Unexpected output: {out.stdout!r}" | |
| 513 | + | print("[OK] installed & ran forge:roneo@0.2.0-rc.1 (bin/ tarball)") | |
| 514 | + | ||
| 515 | + | # 6. Multi-binary repo filtering (`forge:suite/beta` only exists in 1.1.0). | |
| 516 | + | res = run_mise(["ls-remote", "forge:suite/beta"], env, workdir) | |
| 517 | + | beta_versions = [line.strip() for line in res.stdout.splitlines() if line.strip()] | |
| 518 | + | assert beta_versions == ["1.1.0"], f"Unexpected beta versions: {beta_versions}" | |
| 519 | + | run_mise(["install", "forge:suite/alpha@1.1.0", "forge:suite/beta@1.1.0"], env, workdir) | |
| 520 | + | out_a = run_mise(["exec", "forge:suite/alpha@1.1.0", "--", "alpha"], env, workdir) | |
| 521 | + | out_b = run_mise(["exec", "forge:suite/beta@1.1.0", "--", "beta"], env, workdir) | |
| 522 | + | assert out_a.stdout.strip() == "alpha 1.1.0" | |
| 523 | + | assert out_b.stdout.strip() == "beta 1.1.0" | |
| 524 | + | print("[OK] multi-binary forge:suite/alpha & forge:suite/beta") | |
| 525 | + | ||
| 526 | + | # 7. Prefixed tag fallback (`prefixed-v2.0.0`). | |
| 527 | + | run_mise(["install", "forge:prefixed@2.0.0"], env, workdir) | |
| 528 | + | out = run_mise(["exec", "forge:prefixed@2.0.0", "--", "prefixed"], env, workdir) | |
| 529 | + | assert out.stdout.strip() == "prefixed 2.0.0" | |
| 530 | + | print("[OK] prefixed tag fallback (prefixed-v2.0.0)") | |
| 531 | + | ||
| 532 | + | # 8. Standalone raw binary (no archive). | |
| 533 | + | run_mise(["install", "forge:rawtool@1.0.0"], env, workdir) | |
| 534 | + | out = run_mise(["exec", "forge:rawtool@1.0.0", "--", "rawtool"], env, workdir) | |
| 535 | + | assert out.stdout.strip() == "rawtool 1.0.0" | |
| 536 | + | print("[OK] raw non-archive binary install & exec") | |
| 537 | + | ||
| 538 | + | # 9. SHA-256 mismatch must fail closed. | |
| 539 | + | res = run_mise(["install", "forge:badhash@1.0.0"], env, workdir, expect_ok=False) | |
| 540 | + | combined = (res.stdout + res.stderr).lower() | |
| 541 | + | assert "checksum" in combined or "sha256" in combined or "mismatch" in combined, ( | |
| 542 | + | f"Expected checksum error, got:\n{res.stdout}\n{res.stderr}" | |
| 543 | + | ) | |
| 544 | + | print("[OK] bad SHA-256 rejected (fail-closed)") | |
| 545 | + | ||
| 546 | + | # 10. Reserved repo name `api` rejected. | |
| 547 | + | res = run_mise(["ls-remote", "forge:api"], env, workdir, expect_ok=False) | |
| 548 | + | assert "reserved" in (res.stdout + res.stderr).lower() | |
| 549 | + | print("[OK] reserved repo name `api` rejected") | |
| 550 | + | ||
| 551 | + | # 11. Unknown/unpublished repo fails with 404. | |
| 552 | + | res = run_mise(["ls-remote", "forge:does-not-exist"], env, workdir, expect_ok=False) | |
| 553 | + | assert "not found" in (res.stdout + res.stderr).lower() | |
| 554 | + | print("[OK] unknown repo rejected with 404") | |
| 555 | + | ||
| 556 | + | # 12. Tool search via BackendListTools / BackendSearchTools. | |
| 557 | + | res = run_mise(["search", "forge:roneo"], env, workdir) | |
| 558 | + | assert "roneo" in res.stdout | |
| 559 | + | assert "unreleased" not in res.stdout | |
| 560 | + | print("[OK] mise search forge:roneo") | |
| 561 | + | ||
| 562 | + | # 13. Real mise.toml workflow: [plugins] + [tools] with `url` option (no MISE_FORGE_URL), | |
| 563 | + | # mise install -> mise outdated -> mise upgrade. | |
| 564 | + | proj2 = root / "mise_toml_project" | |
| 565 | + | proj2.mkdir() | |
| 566 | + | (proj2 / "mise.toml").write_text( | |
| 567 | + | f'[plugins]\nforge = "{REPO_ROOT}"\n\n' | |
| 568 | + | f'[tools]\n"forge:roneo" = {{ version = "0.1.0", url = "{base_url}" }}\n', | |
| 569 | + | encoding="utf-8", | |
| 570 | + | ) | |
| 571 | + | env_no_url = {k: v for k, v in env.items() if k != "MISE_FORGE_URL"} | |
| 572 | + | env_no_url["MISE_DATA_DIR"] = str(root / "data2") | |
| 573 | + | env_no_url["MISE_CACHE_DIR"] = str(root / "cache2") | |
| 574 | + | env_no_url["MISE_CONFIG_DIR"] = str(root / "config2") | |
| 575 | + | env_no_url["MISE_STATE_DIR"] = str(root / "state2") | |
| 576 | + | env_no_url["MISE_GLOBAL_CONFIG_FILE"] = str(root / "config2" / "config.toml") | |
| 577 | + | ||
| 578 | + | run_mise(["trust", str(proj2 / "mise.toml")], env_no_url, proj2) | |
| 579 | + | run_mise(["install"], env_no_url, proj2) | |
| 580 | + | out = run_mise(["exec", "--", "roneo", "--version"], env_no_url, proj2) | |
| 581 | + | assert out.stdout.strip() == "roneo 0.1.0", f"Unexpected mise.toml output: {out.stdout!r}" | |
| 582 | + | ||
| 583 | + | outdated = run_mise(["outdated", "--bump", "--json"], env_no_url, proj2) | |
| 584 | + | outdated_json = json.loads(outdated.stdout) | |
| 585 | + | assert "forge:roneo" in outdated_json, f"Expected forge:roneo in outdated: {outdated_json}" | |
| 586 | + | assert outdated_json["forge:roneo"]["latest"] == "0.2.0" | |
| 587 | + | ||
| 588 | + | run_mise(["upgrade", "--bump", "forge:roneo"], env_no_url, proj2) | |
| 589 | + | out_up = run_mise(["exec", "--", "roneo", "--version"], env_no_url, proj2) | |
| 590 | + | assert out_up.stdout.strip() == "roneo 0.2.0", f"Expected upgraded 0.2.0, got {out_up.stdout!r}" | |
| 591 | + | print("[OK] mise.toml [plugins] + url option + install + outdated + upgrade") | |
| 592 | + | ||
| 593 | + | # 14. Opt-in cosign verification fails closed when signature_url is null. | |
| 594 | + | res = run_mise( | |
| 595 | + | ["install", "--force", "forge:rawtool[verify_cosign=true]@1.0.0"], | |
| 596 | + | env, | |
| 597 | + | workdir, | |
| 598 | + | expect_ok=False, | |
| 599 | + | ) | |
| 600 | + | assert "signature_url" in (res.stdout + res.stderr).lower() | |
| 601 | + | print("[OK] verify_cosign=true fails closed when unsigned") | |
| 602 | + | ||
| 603 | + | # 15. Path traversal in tool name rejected. | |
| 604 | + | res = run_mise(["ls-remote", "forge:.."], env, workdir, expect_ok=False) | |
| 605 | + | assert "traversal" in (res.stdout + res.stderr).lower() or "invalid" in (res.stdout + res.stderr).lower() | |
| 606 | + | print("[OK] path traversal tool name rejected") | |
| 607 | + | ||
| 608 | + | print("\nAll 15 end-to-end tests passed!") | |
| 609 | + | finally: | |
| 610 | + | server.shutdown() | |
| 611 | + | server.server_close() | |
| 612 | + | ||
| 613 | + | ||
| 614 | + | if __name__ == "__main__": | |
| 615 | + | main() |