Fetch a remote manifest JSON, validate structure, return (data, verified).
(url, public_key_text=None)
| 798 | |
| 799 | |
| 800 | def _fetch_manifest(url, public_key_text=None): |
| 801 | """Fetch a remote manifest JSON, validate structure, return (data, verified).""" |
| 802 | _validate_fetch_url(url) |
| 803 | with http_requests.get(url, timeout=MANIFEST_FETCH_TIMEOUT, stream=True) as resp: |
| 804 | resp.raise_for_status() |
| 805 | body = b"".join(resp.iter_content(8192)) |
| 806 | data = json.loads(body) |
| 807 | # Accept both top-level {manifest: {plugins: [...]}} and {plugins: [...]} |
| 808 | if "manifest" in data and "plugins" in data["manifest"]: |
| 809 | signature = data.get("signature") |
| 810 | verified = _verify_manifest_signature( |
| 811 | data["manifest"], signature, public_key_text |
| 812 | ) |
| 813 | return data, verified |
| 814 | if "plugins" in data: |
| 815 | return {"manifest": data}, None |
| 816 | raise ValueError("Manifest JSON missing 'manifest.plugins' list") |
| 817 | |
| 818 | |
| 819 | class PluginRepoListCreateAPIView(PluginAuthMixin, APIView): |
no test coverage detected