refactor(activate): split interactive activation from running a command in the env
`activate` doubled as the thing scripts sourced non-interactively, so it
carried `--` argument guards and every caller had to tolerate its prompt and
`hermes` function. Composition (setup sync, bootstrap Python, pm env) now
lives in scripts/_activation.sh, and there are two consumers:
- `activate`: interactive, reversible (`deactivate`).
- new `scripts/run-in-hermes-env CMD...`: applies the env to one process and
execs into it. Replaces `scripts/_hermes-python`; every Python script's
shebang and `scripts/run_tests.sh` (which re-executes itself under it,
however it was launched) use it.
`pm.environments --format sh` emits the env as shell exports, so the inline
JSON-to-export Python is gone from `activate`. An install that did not build
the test environment now reads as stale for every consumer.
Tests are split along the same seams: activation support fixtures, bash/ps1
activation, env-script quoting, and the runner's staleness.
2026-09-29 14:50:54 -04:00
|
|
|
#!/usr/bin/env -S bash -c 'exec "$BASH" "$(dirname "$0")/run-in-hermes-env" python3 "$0" "$@"'
|
2026-07-22 07:22:43 -07:00
|
|
|
"""Standalone structural validator for plugin-catalog entry files.
|
|
|
|
|
|
|
|
|
|
Validates ``plugin-catalog/*.yaml`` catalog entries and
|
|
|
|
|
``plugin-catalog/removed.yaml`` against the catalog contract schema, using
|
fix(pm): isolate bootstrap dependencies and unify YAML on ruamel
Activation reaches plugin discovery before the application dependencies
exist. Give PM its own locked Python project and runtime so it can install
or repair the application without importing that dependency tree.
Keep PM outside the application workspace. A shared uv workspace resolves
the application graph and cannot provide this isolation. Route mutations
through an isolated worker and preserve transaction callbacks, cancellation,
custom package registrations, and correlated receipts.
Use the same runtime builder for source installs and packaged payloads.
Keep offline wheelhouse support in that builder. Nix builds the independent
PM lock as a separate derivation. Refuse lazy-disabled bootstrap before
installing tools or dependencies.
Move first-party YAML readers and writers to ruamel. Keep the application
lock's transitive PyYAML requirements for third-party packages.
Verification:
- Focused canonical Python suite: 177 passed, 1 host-gated skip.
- Electron backend probes: 12 passed. Electron typecheck passed.
- Both uv locks, scoped lint, Bash syntax, and whitespace checks passed.
- Cold activation, corrupt-app repair, offline staging, and relocation ran.
- Built and exercised the Nix PM runtime and standalone YAML merge script.
Six broader caller test files retain the same 24 failing test IDs as an
archive of HEAD. The existing real-home guard blocks those tests before
they can exercise the affected paths. No full-suite pass is claimed.
Native Windows signing and full Bionic package execution remain unverified.
2026-09-11 12:23:51 -04:00
|
|
|
only stdlib + ruamel.yaml so the admission CI (and third-party repos) can run it
|
2026-07-22 07:22:43 -07:00
|
|
|
WITHOUT installing hermes-agent.
|
|
|
|
|
|
|
|
|
|
NOTE: this script intentionally duplicates the schema rules instead of
|
|
|
|
|
importing ``hermes_cli`` — the whole point is the no-install requirement for
|
|
|
|
|
cheap cross-repo CI use. The runtime twin of this schema lives in
|
|
|
|
|
``hermes_cli/plugin_catalog.py``; if the contract changes there, update the
|
|
|
|
|
rules here in lockstep.
|
|
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
python3 scripts/validate_plugin_catalog.py plugin-catalog/
|
|
|
|
|
python3 scripts/validate_plugin_catalog.py entry.yaml removed.yaml
|
|
|
|
|
python3 scripts/validate_plugin_catalog.py --json plugin-catalog/
|
|
|
|
|
|
|
|
|
|
Exit codes: 0 = all files valid (warnings allowed), 1 = at least one error.
|
|
|
|
|
Human output is one ``<file>: ERROR: ...`` / ``<file>: warning: ...`` line
|
|
|
|
|
per finding; ``--json`` emits a machine-readable report on stdout instead.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
import json
|
|
|
|
|
import re
|
|
|
|
|
import sys
|
|
|
|
|
from pathlib import Path
|
feat: plugin catalog entries carry an optional version label and card image
The 40-hex sha stays the release, but nobody reads one. Entries may now add
`version: "1.4.0"` (free-form, <=32 chars, never parsed) and `image:` (an https
URL on raw.githubusercontent.com / github.com / *.githubusercontent.com).
Why GitHub-only: the Desktop catalog browser deliberately never fetches from
third-party hosts, and a raw URL pinned to the entry commit is as immutable as
the sha it decorates.
Readers updated together: PluginCatalogEntry + entry_from_mapping (drop with a
warning, entry survives), validate_plugin_catalog.py (admission error), the
site extractor (drop, never fatal), the /docs/plugins card (banner + version
pill + "1.4.0 @ abcd1234" pin), the CLI table/info (pin_label), the TUI-gateway
plugin row (catalog_version -> Desktop "Update to 1.4.0"), and the Desktop
catalog detail header (image).
2026-09-16 12:39:05 -07:00
|
|
|
from urllib.parse import urlsplit
|
2026-07-22 07:22:43 -07:00
|
|
|
|
|
|
|
|
try:
|
fix(pm): isolate bootstrap dependencies and unify YAML on ruamel
Activation reaches plugin discovery before the application dependencies
exist. Give PM its own locked Python project and runtime so it can install
or repair the application without importing that dependency tree.
Keep PM outside the application workspace. A shared uv workspace resolves
the application graph and cannot provide this isolation. Route mutations
through an isolated worker and preserve transaction callbacks, cancellation,
custom package registrations, and correlated receipts.
Use the same runtime builder for source installs and packaged payloads.
Keep offline wheelhouse support in that builder. Nix builds the independent
PM lock as a separate derivation. Refuse lazy-disabled bootstrap before
installing tools or dependencies.
Move first-party YAML readers and writers to ruamel. Keep the application
lock's transitive PyYAML requirements for third-party packages.
Verification:
- Focused canonical Python suite: 177 passed, 1 host-gated skip.
- Electron backend probes: 12 passed. Electron typecheck passed.
- Both uv locks, scoped lint, Bash syntax, and whitespace checks passed.
- Cold activation, corrupt-app repair, offline staging, and relocation ran.
- Built and exercised the Nix PM runtime and standalone YAML merge script.
Six broader caller test files retain the same 24 failing test IDs as an
archive of HEAD. The existing real-home guard blocks those tests before
they can exercise the affected paths. No full-suite pass is claimed.
Native Windows signing and full Bionic package execution remain unverified.
2026-09-11 12:23:51 -04:00
|
|
|
from ruamel.yaml import YAML, YAMLError
|
2026-07-22 07:22:43 -07:00
|
|
|
except ImportError: # pragma: no cover - dependency guidance only
|
|
|
|
|
print(
|
fix(pm): isolate bootstrap dependencies and unify YAML on ruamel
Activation reaches plugin discovery before the application dependencies
exist. Give PM its own locked Python project and runtime so it can install
or repair the application without importing that dependency tree.
Keep PM outside the application workspace. A shared uv workspace resolves
the application graph and cannot provide this isolation. Route mutations
through an isolated worker and preserve transaction callbacks, cancellation,
custom package registrations, and correlated receipts.
Use the same runtime builder for source installs and packaged payloads.
Keep offline wheelhouse support in that builder. Nix builds the independent
PM lock as a separate derivation. Refuse lazy-disabled bootstrap before
installing tools or dependencies.
Move first-party YAML readers and writers to ruamel. Keep the application
lock's transitive PyYAML requirements for third-party packages.
Verification:
- Focused canonical Python suite: 177 passed, 1 host-gated skip.
- Electron backend probes: 12 passed. Electron typecheck passed.
- Both uv locks, scoped lint, Bash syntax, and whitespace checks passed.
- Cold activation, corrupt-app repair, offline staging, and relocation ran.
- Built and exercised the Nix PM runtime and standalone YAML merge script.
Six broader caller test files retain the same 24 failing test IDs as an
archive of HEAD. The existing real-home guard blocks those tests before
they can exercise the affected paths. No full-suite pass is claimed.
Native Windows signing and full Bionic package execution remain unverified.
2026-09-11 12:23:51 -04:00
|
|
|
"ERROR: ruamel.yaml is required (pip install ruamel.yaml==0.18.17)",
|
2026-07-22 07:22:43 -07:00
|
|
|
file=sys.stderr,
|
|
|
|
|
)
|
|
|
|
|
sys.exit(2)
|
|
|
|
|
|
fix(ci): confine plugin-catalog admission gate to the pinned clone
The pinned-source job joined a PR-controlled subdir onto the clone root
with no validation, accepted file:// repos and ref names as the "pin",
and followed committed symlinks out of the clone, so the gate could
validate attacker-planted files instead of the declared commit's
contents. Harden the step end to end:
- validate repo (https://, whitespace-free), sha (40-hex, commit object),
and subdir (plain relative path) in the parser before any use
- run the parser under python3 -I against installed ruamel.yaml so the
PR checkout cannot shadow its imports, capture parser output, and
reset shell variables per entry so a dead parser cannot replay the
previous entry's fields
- confine PLUGIN_DIR and every symlink beneath it to the clone root
- include renamed and typechanged entry files in the changed set
- feed entries over fd 3 and keep plugin-executed commands off stdin so
validate cannot drain the remaining list
- NUL-delimit both self-updater grep stages and sanitize the echoed
filename list so crafted names cannot forge workflow commands
- mirror the same repo/subdir rules in the runtime catalog loader and
the site extractor, and use \Z anchors so a trailing newline cannot
split the verdict between gates
2026-09-27 18:56:31 -05:00
|
|
|
# \Z, not $: $ also matches just before a trailing newline, so a block scalar's
|
|
|
|
|
# "abc123\n" would sneak past a $-anchored check while the workflow's fullmatch
|
|
|
|
|
# rejects it. The two gates must see the same strings identically.
|
|
|
|
|
NAME_RE = re.compile(r"^[a-z0-9_-]{1,64}\Z")
|
|
|
|
|
SHA_RE = re.compile(r"^[0-9a-f]{40}\Z")
|
2026-10-16 08:43:46 -07:00
|
|
|
TIERS = ("official", "verified", "community")
|
2026-09-14 20:48:33 -07:00
|
|
|
CATEGORIES = ("desktop", "memory", "platform", "web", "tools", "voice", "automation", "models", "general")
|
2026-07-22 07:22:43 -07:00
|
|
|
PLATFORMS = ("linux", "macos", "windows")
|
|
|
|
|
CAPABILITY_KEYS = (
|
|
|
|
|
"provides_tools",
|
|
|
|
|
"provides_hooks",
|
|
|
|
|
"provides_middleware",
|
|
|
|
|
"requires_env",
|
|
|
|
|
)
|
|
|
|
|
# Top-level keys the contract knows about. Unknown keys WARN (forward
|
|
|
|
|
# compatibility: newer catalogs must stay valid under older validators).
|
|
|
|
|
KNOWN_KEYS = {
|
|
|
|
|
"name",
|
|
|
|
|
"repo",
|
|
|
|
|
"sha",
|
|
|
|
|
"subdir",
|
|
|
|
|
"description",
|
|
|
|
|
"maintainer",
|
|
|
|
|
"tier",
|
feat(plugin-catalog): shelve the catalog by category (Memory, Desktop, Platforms, …)
The catalog page was one undifferentiated grid filtered only by tier, so a
memory provider sat between two Desktop panes. Entries now carry an optional
``category`` (memory | desktop | platform | web | tools | voice | automation |
models | other, default other) that the loader, the admission validator and
the site extractor all understand.
/docs/plugins renders one shelf per category in browse mode, a category pill
row under the tier pills, a clickable category chip on every card, and a
results bar (active category, count, clear) when a filter or search flattens
the view. ``hermes plugins catalog`` gains a Category column and groups by it.
All 18 shipped entries are categorised. Unknown categories fail admission
(same contract as tier) so a typo cannot create a phantom shelf.
2026-09-14 18:41:29 -07:00
|
|
|
"category",
|
2026-07-22 07:22:43 -07:00
|
|
|
"requires_hermes",
|
|
|
|
|
"docs_url",
|
feat: plugin catalog entries carry an optional version label and card image
The 40-hex sha stays the release, but nobody reads one. Entries may now add
`version: "1.4.0"` (free-form, <=32 chars, never parsed) and `image:` (an https
URL on raw.githubusercontent.com / github.com / *.githubusercontent.com).
Why GitHub-only: the Desktop catalog browser deliberately never fetches from
third-party hosts, and a raw URL pinned to the entry commit is as immutable as
the sha it decorates.
Readers updated together: PluginCatalogEntry + entry_from_mapping (drop with a
warning, entry survives), validate_plugin_catalog.py (admission error), the
site extractor (drop, never fatal), the /docs/plugins card (banner + version
pill + "1.4.0 @ abcd1234" pin), the CLI table/info (pin_label), the TUI-gateway
plugin row (catalog_version -> Desktop "Update to 1.4.0"), and the Desktop
catalog detail header (image).
2026-09-16 12:39:05 -07:00
|
|
|
"version",
|
|
|
|
|
"image",
|
2026-09-20 19:13:44 -07:00
|
|
|
"screenshots",
|
|
|
|
|
"readme",
|
2026-07-22 07:22:43 -07:00
|
|
|
"platforms",
|
|
|
|
|
"capabilities",
|
2026-09-23 08:19:21 +05:30
|
|
|
"title",
|
|
|
|
|
"onboarding",
|
2026-09-27 19:05:56 +08:00
|
|
|
"known_issues",
|
plugin-catalog CI: enforce rule 17 — scan pinned entries for unscannable payloads
The admission gate ran the install scanner (dangerous fails) but nothing refused
a compiled binary, committed bytecode, or an archive hiding either — the shapes
the scanner cannot read. This adds that enforcement to pinned-source-validate.
- scripts/scan_plugin_payloads.py (stdlib-only, so the no-install validator and
third-party CI can run it): flags compiled binaries by magic header (ELF,
Mach-O, PE/MZ, WebAssembly — not by extension, which a rename defeats),
.pyc/.pyo bytecode (incl. sourceless/hash-forged caches that run instead of
the .py beside them), and archives whose members are not reviewable source.
Plain-text source bundles and inert assets (fonts, images) pass.
- plugin-catalog-ci.yml: after `hermes plugins validate`, each changed entry is
scanned; a finding fails it. An entry may list `attested_binaries:` paths,
each verified with `gh attestation verify --repo <repo> --source-digest <sha>`
against the pinned commit; verified paths are dropped before the scan, any
other binary still fails. Repo-controlled filenames are newline-stripped in
the log so none can forge a workflow command.
- validate_plugin_catalog.py: `attested_binaries` is a known key, shape-checked
as a list of relative paths.
- Tests: unit tests for the detector and two new workflow-driven bypass cases
(bundled .exe, committed .pyc) in the confinement harness, which runs the real
`run:` block.
Full-content re-sweep of all 543 pins: only tabro carries a native binary (it is
delisted in the companion PR). Three entries (crawl4ai, hermes-vision-inline,
mermail) commit __pycache__/*.pyc build litter and would fail rule 17 on their
next pin bump — pre-existing, not touched here.
2026-10-11 02:34:57 -07:00
|
|
|
"attested_binaries",
|
2026-07-22 07:22:43 -07:00
|
|
|
}
|
2026-09-20 19:13:44 -07:00
|
|
|
# Cosmetic labels attached to the pin. ``version`` is never parsed; ``image`` and ``screenshots``
|
|
|
|
|
# may only point at GitHub so the Desktop catalog browser and the docs site never fetch from
|
|
|
|
|
# third-party hosts and a raw URL pinned to the entry's commit stays as immutable as the sha.
|
fix(ci): confine plugin-catalog admission gate to the pinned clone
The pinned-source job joined a PR-controlled subdir onto the clone root
with no validation, accepted file:// repos and ref names as the "pin",
and followed committed symlinks out of the clone, so the gate could
validate attacker-planted files instead of the declared commit's
contents. Harden the step end to end:
- validate repo (https://, whitespace-free), sha (40-hex, commit object),
and subdir (plain relative path) in the parser before any use
- run the parser under python3 -I against installed ruamel.yaml so the
PR checkout cannot shadow its imports, capture parser output, and
reset shell variables per entry so a dead parser cannot replay the
previous entry's fields
- confine PLUGIN_DIR and every symlink beneath it to the clone root
- include renamed and typechanged entry files in the changed set
- feed entries over fd 3 and keep plugin-executed commands off stdin so
validate cannot drain the remaining list
- NUL-delimit both self-updater grep stages and sanitize the echoed
filename list so crafted names cannot forge workflow commands
- mirror the same repo/subdir rules in the runtime catalog loader and
the site extractor, and use \Z anchors so a trailing newline cannot
split the verdict between gates
2026-09-27 18:56:31 -05:00
|
|
|
VERSION_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9._+-]{0,31}\Z")
|
feat: plugin catalog entries carry an optional version label and card image
The 40-hex sha stays the release, but nobody reads one. Entries may now add
`version: "1.4.0"` (free-form, <=32 chars, never parsed) and `image:` (an https
URL on raw.githubusercontent.com / github.com / *.githubusercontent.com).
Why GitHub-only: the Desktop catalog browser deliberately never fetches from
third-party hosts, and a raw URL pinned to the entry commit is as immutable as
the sha it decorates.
Readers updated together: PluginCatalogEntry + entry_from_mapping (drop with a
warning, entry survives), validate_plugin_catalog.py (admission error), the
site extractor (drop, never fatal), the /docs/plugins card (banner + version
pill + "1.4.0 @ abcd1234" pin), the CLI table/info (pin_label), the TUI-gateway
plugin row (catalog_version -> Desktop "Update to 1.4.0"), and the Desktop
catalog detail header (image).
2026-09-16 12:39:05 -07:00
|
|
|
IMAGE_HOSTS = ("raw.githubusercontent.com", "github.com")
|
|
|
|
|
IMAGE_HOST_SUFFIX = ".githubusercontent.com"
|
2026-09-20 19:13:44 -07:00
|
|
|
MAX_SCREENSHOTS = 6
|
|
|
|
|
# ``readme: true`` makes the docs site render the README from the pinned commit; the build knows
|
|
|
|
|
# the raw-file URL scheme of these forges only.
|
|
|
|
|
README_REPO_HOSTS = ("github.com", "gitlab.com")
|
2026-07-22 07:22:43 -07:00
|
|
|
REQUIRED_KEYS = ("name", "repo", "sha", "description", "maintainer")
|
|
|
|
|
|
|
|
|
|
# One comparator clause of a requires_hermes spec, e.g. ">=0.19" or "!=1.2.3".
|
fix(ci): confine plugin-catalog admission gate to the pinned clone
The pinned-source job joined a PR-controlled subdir onto the clone root
with no validation, accepted file:// repos and ref names as the "pin",
and followed committed symlinks out of the clone, so the gate could
validate attacker-planted files instead of the declared commit's
contents. Harden the step end to end:
- validate repo (https://, whitespace-free), sha (40-hex, commit object),
and subdir (plain relative path) in the parser before any use
- run the parser under python3 -I against installed ruamel.yaml so the
PR checkout cannot shadow its imports, capture parser output, and
reset shell variables per entry so a dead parser cannot replay the
previous entry's fields
- confine PLUGIN_DIR and every symlink beneath it to the clone root
- include renamed and typechanged entry files in the changed set
- feed entries over fd 3 and keep plugin-executed commands off stdin so
validate cannot drain the remaining list
- NUL-delimit both self-updater grep stages and sanitize the echoed
filename list so crafted names cannot forge workflow commands
- mirror the same repo/subdir rules in the runtime catalog loader and
the site extractor, and use \Z anchors so a trailing newline cannot
split the verdict between gates
2026-09-27 18:56:31 -05:00
|
|
|
_COMPARATOR_RE = re.compile(r"^(>=|<=|==|!=|>|<)\s*\d+(\.\d+)*\Z")
|
2026-07-22 07:22:43 -07:00
|
|
|
|
|
|
|
|
|
feat: plugin catalog entries carry an optional version label and card image
The 40-hex sha stays the release, but nobody reads one. Entries may now add
`version: "1.4.0"` (free-form, <=32 chars, never parsed) and `image:` (an https
URL on raw.githubusercontent.com / github.com / *.githubusercontent.com).
Why GitHub-only: the Desktop catalog browser deliberately never fetches from
third-party hosts, and a raw URL pinned to the entry commit is as immutable as
the sha it decorates.
Readers updated together: PluginCatalogEntry + entry_from_mapping (drop with a
warning, entry survives), validate_plugin_catalog.py (admission error), the
site extractor (drop, never fatal), the /docs/plugins card (banner + version
pill + "1.4.0 @ abcd1234" pin), the CLI table/info (pin_label), the TUI-gateway
plugin row (catalog_version -> Desktop "Update to 1.4.0"), and the Desktop
catalog detail header (image).
2026-09-16 12:39:05 -07:00
|
|
|
def _is_allowed_image_url(url: str) -> bool:
|
|
|
|
|
parts = urlsplit(url)
|
|
|
|
|
host = (parts.hostname or "").lower()
|
|
|
|
|
return parts.scheme == "https" and bool(host) and (host in IMAGE_HOSTS or host.endswith(IMAGE_HOST_SUFFIX))
|
|
|
|
|
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
def _is_nonempty_str(value: object) -> bool:
|
|
|
|
|
return isinstance(value, str) and value.strip() != ""
|
|
|
|
|
|
|
|
|
|
|
2026-09-20 19:13:44 -07:00
|
|
|
def _repo_host(repo: object) -> str:
|
|
|
|
|
return (urlsplit(repo).hostname or "").lower() if isinstance(repo, str) else ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _check_page_fields(data: dict, errors: list[str]) -> None:
|
2026-09-21 01:04:26 -07:00
|
|
|
"""``screenshots`` and ``readme`` feed the entry's page at /docs/plugins/<name>; both optional (README on by default)."""
|
2026-09-20 19:13:44 -07:00
|
|
|
shots = data.get("screenshots")
|
|
|
|
|
if shots is not None:
|
|
|
|
|
if not isinstance(shots, list) or not all(isinstance(s, str) and _is_allowed_image_url(s) for s in shots):
|
|
|
|
|
errors.append(
|
|
|
|
|
f"screenshots must be a list of https URLs on {list(IMAGE_HOSTS)} or *{IMAGE_HOST_SUFFIX}"
|
|
|
|
|
)
|
|
|
|
|
elif len(shots) > MAX_SCREENSHOTS:
|
|
|
|
|
errors.append(f"screenshots lists {len(shots)} URLs; at most {MAX_SCREENSHOTS} are shown")
|
|
|
|
|
readme = data.get("readme")
|
|
|
|
|
if readme is not None:
|
|
|
|
|
if not isinstance(readme, bool):
|
|
|
|
|
errors.append(f"readme must be true or false, got {readme!r}")
|
|
|
|
|
elif readme and _repo_host(data.get("repo")) not in README_REPO_HOSTS:
|
2026-09-21 01:04:26 -07:00
|
|
|
errors.append(f"readme: true needs a repo on {list(README_REPO_HOSTS)} (the site fetches it from the pinned commit); omit it for other forges")
|
2026-09-20 19:13:44 -07:00
|
|
|
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
def _check_requires_hermes(spec: object, errors: list[str]) -> None:
|
|
|
|
|
if not isinstance(spec, str):
|
|
|
|
|
errors.append(f"requires_hermes must be a string, got {type(spec).__name__}")
|
|
|
|
|
return
|
|
|
|
|
if spec.strip() == "":
|
|
|
|
|
return # empty = no constraint
|
|
|
|
|
for clause in spec.split(","):
|
|
|
|
|
if not _COMPARATOR_RE.match(clause.strip()):
|
|
|
|
|
errors.append(
|
|
|
|
|
f"requires_hermes clause {clause.strip()!r} is not a valid "
|
|
|
|
|
"comparator spec (expected e.g. '>=0.19')"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_entry(data: object) -> tuple[list[str], list[str]]:
|
|
|
|
|
"""Validate one catalog entry document. Returns (errors, warnings)."""
|
|
|
|
|
errors: list[str] = []
|
|
|
|
|
warnings: list[str] = []
|
|
|
|
|
|
|
|
|
|
if not isinstance(data, dict):
|
|
|
|
|
return ["top-level document must be a YAML mapping"], warnings
|
|
|
|
|
|
|
|
|
|
for key in REQUIRED_KEYS:
|
|
|
|
|
if key not in data:
|
|
|
|
|
errors.append(f"missing required key: {key}")
|
|
|
|
|
|
|
|
|
|
for key in sorted(set(data) - KNOWN_KEYS):
|
|
|
|
|
warnings.append(f"unknown top-level key {key!r} (ignored by this validator)")
|
|
|
|
|
|
|
|
|
|
name = data.get("name")
|
|
|
|
|
if "name" in data and (not isinstance(name, str) or not NAME_RE.match(name)):
|
|
|
|
|
errors.append(f"name {name!r} must match [a-z0-9_-]{{1,64}}")
|
|
|
|
|
|
|
|
|
|
repo = data.get("repo")
|
|
|
|
|
if "repo" in data and (
|
fix(ci): confine plugin-catalog admission gate to the pinned clone
The pinned-source job joined a PR-controlled subdir onto the clone root
with no validation, accepted file:// repos and ref names as the "pin",
and followed committed symlinks out of the clone, so the gate could
validate attacker-planted files instead of the declared commit's
contents. Harden the step end to end:
- validate repo (https://, whitespace-free), sha (40-hex, commit object),
and subdir (plain relative path) in the parser before any use
- run the parser under python3 -I against installed ruamel.yaml so the
PR checkout cannot shadow its imports, capture parser output, and
reset shell variables per entry so a dead parser cannot replay the
previous entry's fields
- confine PLUGIN_DIR and every symlink beneath it to the clone root
- include renamed and typechanged entry files in the changed set
- feed entries over fd 3 and keep plugin-executed commands off stdin so
validate cannot drain the remaining list
- NUL-delimit both self-updater grep stages and sanitize the echoed
filename list so crafted names cannot forge workflow commands
- mirror the same repo/subdir rules in the runtime catalog loader and
the site extractor, and use \Z anchors so a trailing newline cannot
split the verdict between gates
2026-09-27 18:56:31 -05:00
|
|
|
not isinstance(repo, str) or not re.fullmatch(r"https://\S+", repo)
|
2026-07-22 07:22:43 -07:00
|
|
|
):
|
|
|
|
|
errors.append(f"repo {repo!r} must be an https:// URL")
|
|
|
|
|
|
fix(ci): confine plugin-catalog admission gate to the pinned clone
The pinned-source job joined a PR-controlled subdir onto the clone root
with no validation, accepted file:// repos and ref names as the "pin",
and followed committed symlinks out of the clone, so the gate could
validate attacker-planted files instead of the declared commit's
contents. Harden the step end to end:
- validate repo (https://, whitespace-free), sha (40-hex, commit object),
and subdir (plain relative path) in the parser before any use
- run the parser under python3 -I against installed ruamel.yaml so the
PR checkout cannot shadow its imports, capture parser output, and
reset shell variables per entry so a dead parser cannot replay the
previous entry's fields
- confine PLUGIN_DIR and every symlink beneath it to the clone root
- include renamed and typechanged entry files in the changed set
- feed entries over fd 3 and keep plugin-executed commands off stdin so
validate cannot drain the remaining list
- NUL-delimit both self-updater grep stages and sanitize the echoed
filename list so crafted names cannot forge workflow commands
- mirror the same repo/subdir rules in the runtime catalog loader and
the site extractor, and use \Z anchors so a trailing newline cannot
split the verdict between gates
2026-09-27 18:56:31 -05:00
|
|
|
# The admission CI joins subdir onto a pinned clone before validating its
|
|
|
|
|
# manifest: it must be a plain relative path or it can point the gate at
|
|
|
|
|
# files outside the pinned commit.
|
|
|
|
|
subdir = data.get("subdir")
|
2026-10-01 10:01:56 -07:00
|
|
|
# `subdir:` with no value is the repo root, as the runtime loader reads it.
|
|
|
|
|
if subdir is not None:
|
fix(ci): confine plugin-catalog admission gate to the pinned clone
The pinned-source job joined a PR-controlled subdir onto the clone root
with no validation, accepted file:// repos and ref names as the "pin",
and followed committed symlinks out of the clone, so the gate could
validate attacker-planted files instead of the declared commit's
contents. Harden the step end to end:
- validate repo (https://, whitespace-free), sha (40-hex, commit object),
and subdir (plain relative path) in the parser before any use
- run the parser under python3 -I against installed ruamel.yaml so the
PR checkout cannot shadow its imports, capture parser output, and
reset shell variables per entry so a dead parser cannot replay the
previous entry's fields
- confine PLUGIN_DIR and every symlink beneath it to the clone root
- include renamed and typechanged entry files in the changed set
- feed entries over fd 3 and keep plugin-executed commands off stdin so
validate cannot drain the remaining list
- NUL-delimit both self-updater grep stages and sanitize the echoed
filename list so crafted names cannot forge workflow commands
- mirror the same repo/subdir rules in the runtime catalog loader and
the site extractor, and use \Z anchors so a trailing newline cannot
split the verdict between gates
2026-09-27 18:56:31 -05:00
|
|
|
if not isinstance(subdir, str):
|
|
|
|
|
errors.append("subdir must be a string")
|
|
|
|
|
elif subdir and (
|
|
|
|
|
not re.fullmatch(r"[A-Za-z0-9._/-]+", subdir)
|
|
|
|
|
or any(seg in ("", ".", "..") for seg in subdir.split("/"))
|
|
|
|
|
):
|
|
|
|
|
errors.append(
|
|
|
|
|
f"subdir {subdir!r} must be a relative path without '.' or '..' segments"
|
|
|
|
|
)
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
sha = data.get("sha")
|
|
|
|
|
if "sha" in data and (not isinstance(sha, str) or not SHA_RE.match(sha)):
|
|
|
|
|
errors.append(f"sha {sha!r} must be exactly 40 lowercase hex characters")
|
|
|
|
|
|
|
|
|
|
for key in ("description", "maintainer"):
|
|
|
|
|
if key in data and not _is_nonempty_str(data[key]):
|
|
|
|
|
errors.append(f"{key} must be a non-empty string")
|
|
|
|
|
|
|
|
|
|
tier = data.get("tier", "community")
|
|
|
|
|
if tier not in TIERS:
|
|
|
|
|
errors.append(f"tier {tier!r} must be one of {list(TIERS)}")
|
|
|
|
|
|
2026-09-14 20:48:33 -07:00
|
|
|
category = data.get("category", "desktop")
|
feat(plugin-catalog): shelve the catalog by category (Memory, Desktop, Platforms, …)
The catalog page was one undifferentiated grid filtered only by tier, so a
memory provider sat between two Desktop panes. Entries now carry an optional
``category`` (memory | desktop | platform | web | tools | voice | automation |
models | other, default other) that the loader, the admission validator and
the site extractor all understand.
/docs/plugins renders one shelf per category in browse mode, a category pill
row under the tier pills, a clickable category chip on every card, and a
results bar (active category, count, clear) when a filter or search flattens
the view. ``hermes plugins catalog`` gains a Category column and groups by it.
All 18 shipped entries are categorised. Unknown categories fail admission
(same contract as tier) so a typo cannot create a phantom shelf.
2026-09-14 18:41:29 -07:00
|
|
|
if category not in CATEGORIES:
|
|
|
|
|
errors.append(f"category {category!r} must be one of {list(CATEGORIES)}")
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
if "requires_hermes" in data:
|
|
|
|
|
_check_requires_hermes(data["requires_hermes"], errors)
|
|
|
|
|
|
feat: plugin catalog entries carry an optional version label and card image
The 40-hex sha stays the release, but nobody reads one. Entries may now add
`version: "1.4.0"` (free-form, <=32 chars, never parsed) and `image:` (an https
URL on raw.githubusercontent.com / github.com / *.githubusercontent.com).
Why GitHub-only: the Desktop catalog browser deliberately never fetches from
third-party hosts, and a raw URL pinned to the entry commit is as immutable as
the sha it decorates.
Readers updated together: PluginCatalogEntry + entry_from_mapping (drop with a
warning, entry survives), validate_plugin_catalog.py (admission error), the
site extractor (drop, never fatal), the /docs/plugins card (banner + version
pill + "1.4.0 @ abcd1234" pin), the CLI table/info (pin_label), the TUI-gateway
plugin row (catalog_version -> Desktop "Update to 1.4.0"), and the Desktop
catalog detail header (image).
2026-09-16 12:39:05 -07:00
|
|
|
version = data.get("version")
|
|
|
|
|
if version is not None and (not isinstance(version, str) or not VERSION_RE.match(version)):
|
|
|
|
|
errors.append(f"version {version!r} must be 1-32 chars of [A-Za-z0-9._+-] (quote it in YAML)")
|
|
|
|
|
|
|
|
|
|
image = data.get("image")
|
|
|
|
|
if image is not None and (not isinstance(image, str) or not _is_allowed_image_url(image)):
|
|
|
|
|
errors.append(f"image {image!r} must be an https URL on {list(IMAGE_HOSTS)} or *{IMAGE_HOST_SUFFIX}")
|
|
|
|
|
|
2026-09-20 19:13:44 -07:00
|
|
|
_check_page_fields(data, errors)
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
platforms = data.get("platforms", [])
|
|
|
|
|
if platforms is None:
|
|
|
|
|
platforms = []
|
|
|
|
|
if not isinstance(platforms, list):
|
|
|
|
|
errors.append("platforms must be a list")
|
|
|
|
|
else:
|
|
|
|
|
bad = [p for p in platforms if p not in PLATFORMS]
|
|
|
|
|
if bad:
|
|
|
|
|
errors.append(f"platforms {bad!r} not in allowed set {list(PLATFORMS)}")
|
|
|
|
|
|
|
|
|
|
caps = data.get("capabilities", {})
|
|
|
|
|
if caps is None:
|
|
|
|
|
caps = {}
|
|
|
|
|
if not isinstance(caps, dict):
|
|
|
|
|
errors.append("capabilities must be a mapping")
|
|
|
|
|
else:
|
|
|
|
|
for key in sorted(set(caps) - set(CAPABILITY_KEYS)):
|
|
|
|
|
warnings.append(f"unknown capabilities key {key!r}")
|
|
|
|
|
for key in CAPABILITY_KEYS:
|
|
|
|
|
if key not in caps:
|
|
|
|
|
continue
|
|
|
|
|
value = caps[key]
|
|
|
|
|
if not isinstance(value, list) or not all(
|
|
|
|
|
isinstance(item, str) for item in value
|
|
|
|
|
):
|
|
|
|
|
errors.append(f"capabilities.{key} must be a list of strings")
|
|
|
|
|
|
plugin-catalog CI: enforce rule 17 — scan pinned entries for unscannable payloads
The admission gate ran the install scanner (dangerous fails) but nothing refused
a compiled binary, committed bytecode, or an archive hiding either — the shapes
the scanner cannot read. This adds that enforcement to pinned-source-validate.
- scripts/scan_plugin_payloads.py (stdlib-only, so the no-install validator and
third-party CI can run it): flags compiled binaries by magic header (ELF,
Mach-O, PE/MZ, WebAssembly — not by extension, which a rename defeats),
.pyc/.pyo bytecode (incl. sourceless/hash-forged caches that run instead of
the .py beside them), and archives whose members are not reviewable source.
Plain-text source bundles and inert assets (fonts, images) pass.
- plugin-catalog-ci.yml: after `hermes plugins validate`, each changed entry is
scanned; a finding fails it. An entry may list `attested_binaries:` paths,
each verified with `gh attestation verify --repo <repo> --source-digest <sha>`
against the pinned commit; verified paths are dropped before the scan, any
other binary still fails. Repo-controlled filenames are newline-stripped in
the log so none can forge a workflow command.
- validate_plugin_catalog.py: `attested_binaries` is a known key, shape-checked
as a list of relative paths.
- Tests: unit tests for the detector and two new workflow-driven bypass cases
(bundled .exe, committed .pyc) in the confinement harness, which runs the real
`run:` block.
Full-content re-sweep of all 543 pins: only tabro carries a native binary (it is
delisted in the companion PR). Three entries (crawl4ai, hermes-vision-inline,
mermail) commit __pycache__/*.pyc build litter and would fail rule 17 on their
next pin bump — pre-existing, not touched here.
2026-10-11 02:34:57 -07:00
|
|
|
# attested_binaries: relative paths to compiled files that carry a GitHub
|
|
|
|
|
# build-provenance attestation (README rule 17). The CI gate verifies the
|
|
|
|
|
# attestation; here we only shape-check the paths.
|
|
|
|
|
_check_attested_binaries(data.get("attested_binaries"), errors)
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
return errors, warnings
|
|
|
|
|
|
|
|
|
|
|
plugin-catalog CI: enforce rule 17 — scan pinned entries for unscannable payloads
The admission gate ran the install scanner (dangerous fails) but nothing refused
a compiled binary, committed bytecode, or an archive hiding either — the shapes
the scanner cannot read. This adds that enforcement to pinned-source-validate.
- scripts/scan_plugin_payloads.py (stdlib-only, so the no-install validator and
third-party CI can run it): flags compiled binaries by magic header (ELF,
Mach-O, PE/MZ, WebAssembly — not by extension, which a rename defeats),
.pyc/.pyo bytecode (incl. sourceless/hash-forged caches that run instead of
the .py beside them), and archives whose members are not reviewable source.
Plain-text source bundles and inert assets (fonts, images) pass.
- plugin-catalog-ci.yml: after `hermes plugins validate`, each changed entry is
scanned; a finding fails it. An entry may list `attested_binaries:` paths,
each verified with `gh attestation verify --repo <repo> --source-digest <sha>`
against the pinned commit; verified paths are dropped before the scan, any
other binary still fails. Repo-controlled filenames are newline-stripped in
the log so none can forge a workflow command.
- validate_plugin_catalog.py: `attested_binaries` is a known key, shape-checked
as a list of relative paths.
- Tests: unit tests for the detector and two new workflow-driven bypass cases
(bundled .exe, committed .pyc) in the confinement harness, which runs the real
`run:` block.
Full-content re-sweep of all 543 pins: only tabro carries a native binary (it is
delisted in the companion PR). Three entries (crawl4ai, hermes-vision-inline,
mermail) commit __pycache__/*.pyc build litter and would fail rule 17 on their
next pin bump — pre-existing, not touched here.
2026-10-11 02:34:57 -07:00
|
|
|
def _check_attested_binaries(attested: object, errors: list[str]) -> None:
|
|
|
|
|
"""Shape-check the optional ``attested_binaries`` list of relative paths."""
|
|
|
|
|
if attested is None:
|
|
|
|
|
return
|
|
|
|
|
if not isinstance(attested, list) or not all(isinstance(p, str) for p in attested):
|
|
|
|
|
errors.append("attested_binaries must be a list of strings")
|
|
|
|
|
return
|
|
|
|
|
for p in attested:
|
|
|
|
|
if not re.fullmatch(r"[A-Za-z0-9._/-]+", p) or any(
|
|
|
|
|
seg in ("", ".", "..") for seg in p.split("/")
|
|
|
|
|
):
|
|
|
|
|
errors.append(
|
|
|
|
|
f"attested_binaries path {p!r} must be a relative path without '.' or '..' segments"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-07-22 07:22:43 -07:00
|
|
|
def validate_removed(data: object) -> tuple[list[str], list[str]]:
|
|
|
|
|
"""Validate the removed.yaml document. Returns (errors, warnings)."""
|
|
|
|
|
errors: list[str] = []
|
|
|
|
|
warnings: list[str] = []
|
|
|
|
|
|
|
|
|
|
if not isinstance(data, dict):
|
|
|
|
|
return ["top-level document must be a YAML mapping"], warnings
|
|
|
|
|
|
|
|
|
|
removed = data.get("removed")
|
|
|
|
|
if removed is None:
|
|
|
|
|
errors.append("missing required key: removed")
|
|
|
|
|
return errors, warnings
|
|
|
|
|
if not isinstance(removed, list):
|
|
|
|
|
errors.append("removed must be a list")
|
|
|
|
|
return errors, warnings
|
|
|
|
|
|
|
|
|
|
for i, item in enumerate(removed):
|
|
|
|
|
if not isinstance(item, dict):
|
|
|
|
|
errors.append(f"removed[{i}] must be a mapping")
|
|
|
|
|
continue
|
|
|
|
|
if not _is_nonempty_str(item.get("name")):
|
|
|
|
|
errors.append(f"removed[{i}] missing non-empty 'name'")
|
|
|
|
|
for key in ("repo", "reason", "date"):
|
|
|
|
|
if key in item and not isinstance(item[key], str):
|
|
|
|
|
errors.append(f"removed[{i}].{key} must be a string")
|
|
|
|
|
|
|
|
|
|
return errors, warnings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def validate_file(path: Path) -> tuple[list[str], list[str]]:
|
|
|
|
|
"""Validate one YAML file (dispatching on filename). Returns (errors, warnings)."""
|
|
|
|
|
try:
|
fix(pm): isolate bootstrap dependencies and unify YAML on ruamel
Activation reaches plugin discovery before the application dependencies
exist. Give PM its own locked Python project and runtime so it can install
or repair the application without importing that dependency tree.
Keep PM outside the application workspace. A shared uv workspace resolves
the application graph and cannot provide this isolation. Route mutations
through an isolated worker and preserve transaction callbacks, cancellation,
custom package registrations, and correlated receipts.
Use the same runtime builder for source installs and packaged payloads.
Keep offline wheelhouse support in that builder. Nix builds the independent
PM lock as a separate derivation. Refuse lazy-disabled bootstrap before
installing tools or dependencies.
Move first-party YAML readers and writers to ruamel. Keep the application
lock's transitive PyYAML requirements for third-party packages.
Verification:
- Focused canonical Python suite: 177 passed, 1 host-gated skip.
- Electron backend probes: 12 passed. Electron typecheck passed.
- Both uv locks, scoped lint, Bash syntax, and whitespace checks passed.
- Cold activation, corrupt-app repair, offline staging, and relocation ran.
- Built and exercised the Nix PM runtime and standalone YAML merge script.
Six broader caller test files retain the same 24 failing test IDs as an
archive of HEAD. The existing real-home guard blocks those tests before
they can exercise the affected paths. No full-suite pass is claimed.
Native Windows signing and full Bionic package execution remain unverified.
2026-09-11 12:23:51 -04:00
|
|
|
reader = YAML(typ="safe")
|
|
|
|
|
reader.version = (1, 1)
|
2026-09-13 18:21:59 -04:00
|
|
|
with open(path, encoding="utf-8-sig") as fh:
|
fix(pm): isolate bootstrap dependencies and unify YAML on ruamel
Activation reaches plugin discovery before the application dependencies
exist. Give PM its own locked Python project and runtime so it can install
or repair the application without importing that dependency tree.
Keep PM outside the application workspace. A shared uv workspace resolves
the application graph and cannot provide this isolation. Route mutations
through an isolated worker and preserve transaction callbacks, cancellation,
custom package registrations, and correlated receipts.
Use the same runtime builder for source installs and packaged payloads.
Keep offline wheelhouse support in that builder. Nix builds the independent
PM lock as a separate derivation. Refuse lazy-disabled bootstrap before
installing tools or dependencies.
Move first-party YAML readers and writers to ruamel. Keep the application
lock's transitive PyYAML requirements for third-party packages.
Verification:
- Focused canonical Python suite: 177 passed, 1 host-gated skip.
- Electron backend probes: 12 passed. Electron typecheck passed.
- Both uv locks, scoped lint, Bash syntax, and whitespace checks passed.
- Cold activation, corrupt-app repair, offline staging, and relocation ran.
- Built and exercised the Nix PM runtime and standalone YAML merge script.
Six broader caller test files retain the same 24 failing test IDs as an
archive of HEAD. The existing real-home guard blocks those tests before
they can exercise the affected paths. No full-suite pass is claimed.
Native Windows signing and full Bionic package execution remain unverified.
2026-09-11 12:23:51 -04:00
|
|
|
data = reader.load(fh)
|
2026-07-22 07:22:43 -07:00
|
|
|
except OSError as exc:
|
|
|
|
|
return [f"cannot read file: {exc}"], []
|
fix(pm): isolate bootstrap dependencies and unify YAML on ruamel
Activation reaches plugin discovery before the application dependencies
exist. Give PM its own locked Python project and runtime so it can install
or repair the application without importing that dependency tree.
Keep PM outside the application workspace. A shared uv workspace resolves
the application graph and cannot provide this isolation. Route mutations
through an isolated worker and preserve transaction callbacks, cancellation,
custom package registrations, and correlated receipts.
Use the same runtime builder for source installs and packaged payloads.
Keep offline wheelhouse support in that builder. Nix builds the independent
PM lock as a separate derivation. Refuse lazy-disabled bootstrap before
installing tools or dependencies.
Move first-party YAML readers and writers to ruamel. Keep the application
lock's transitive PyYAML requirements for third-party packages.
Verification:
- Focused canonical Python suite: 177 passed, 1 host-gated skip.
- Electron backend probes: 12 passed. Electron typecheck passed.
- Both uv locks, scoped lint, Bash syntax, and whitespace checks passed.
- Cold activation, corrupt-app repair, offline staging, and relocation ran.
- Built and exercised the Nix PM runtime and standalone YAML merge script.
Six broader caller test files retain the same 24 failing test IDs as an
archive of HEAD. The existing real-home guard blocks those tests before
they can exercise the affected paths. No full-suite pass is claimed.
Native Windows signing and full Bionic package execution remain unverified.
2026-09-11 12:23:51 -04:00
|
|
|
except YAMLError as exc:
|
2026-07-22 07:22:43 -07:00
|
|
|
return [f"invalid YAML: {exc}"], []
|
|
|
|
|
|
|
|
|
|
if path.name == "removed.yaml":
|
|
|
|
|
return validate_removed(data)
|
|
|
|
|
return validate_entry(data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def collect_paths(args: list[str]) -> list[Path]:
|
|
|
|
|
paths: list[Path] = []
|
|
|
|
|
for arg in args:
|
|
|
|
|
p = Path(arg)
|
|
|
|
|
if p.is_dir():
|
|
|
|
|
paths.extend(sorted(p.glob("*.yaml")))
|
|
|
|
|
paths.extend(sorted(p.glob("*.yml")))
|
|
|
|
|
else:
|
|
|
|
|
paths.append(p)
|
|
|
|
|
return paths
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(argv: list[str] | None = None) -> int:
|
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
|
description="Standalone structural validator for plugin-catalog entry files."
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"paths",
|
|
|
|
|
nargs="+",
|
|
|
|
|
help="catalog entry files, removed.yaml, or a directory of them",
|
|
|
|
|
)
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
"--json",
|
|
|
|
|
action="store_true",
|
|
|
|
|
help="emit a machine-readable JSON report on stdout",
|
|
|
|
|
)
|
|
|
|
|
opts = parser.parse_args(argv)
|
|
|
|
|
|
|
|
|
|
files = collect_paths(opts.paths)
|
|
|
|
|
if not files:
|
|
|
|
|
print("ERROR: no YAML files found", file=sys.stderr)
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
|
|
report = []
|
|
|
|
|
any_errors = False
|
|
|
|
|
for path in files:
|
|
|
|
|
errors, warnings = validate_file(path)
|
|
|
|
|
any_errors = any_errors or bool(errors)
|
|
|
|
|
report.append(
|
|
|
|
|
{
|
|
|
|
|
"path": str(path),
|
|
|
|
|
"ok": not errors,
|
|
|
|
|
"errors": errors,
|
|
|
|
|
"warnings": warnings,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if opts.json:
|
|
|
|
|
print(json.dumps({"ok": not any_errors, "files": report}, indent=2))
|
|
|
|
|
else:
|
|
|
|
|
for entry in report:
|
|
|
|
|
for err in entry["errors"]:
|
|
|
|
|
print(f"{entry['path']}: ERROR: {err}")
|
|
|
|
|
for warn in entry["warnings"]:
|
|
|
|
|
print(f"{entry['path']}: warning: {warn}")
|
|
|
|
|
checked = len(report)
|
|
|
|
|
bad = sum(1 for e in report if not e["ok"])
|
|
|
|
|
if any_errors:
|
|
|
|
|
print(f"FAIL: {bad}/{checked} file(s) invalid")
|
|
|
|
|
else:
|
|
|
|
|
print(f"OK: {checked} file(s) valid")
|
|
|
|
|
|
|
|
|
|
return 1 if any_errors else 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
sys.exit(main())
|