Add canvas schema validation to extension submission workflow#2161
Open
aaronpowell wants to merge 5 commits into
Open
Add canvas schema validation to extension submission workflow#2161aaronpowell wants to merge 5 commits into
aaronpowell wants to merge 5 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a dedicated JSON Schema for extensions/*/canvas.json and updates the canvas extension validation workflow to enforce required files, schema compliance, and referenced screenshot existence. It also expands the website build workflow’s path filters so extension and canvas schema updates trigger the website build.
Changes:
- Add
.schemas/canvas.schema.jsondefining the expected shape ofextensions/<name>/canvas.json. - Replace the canvas extension PR validation logic with a shell-based validator that checks required files, validates
canvas.jsonagainst the schema, and verifies referenced screenshot paths exist. - Update
build-website.ymlpath filters to include extension and canvas schema changes.
Show a summary per file
| File | Description |
|---|---|
.schemas/canvas.schema.json |
Adds a draft-07 JSON schema for canvas extension manifests. |
.github/workflows/validate-canvas-extensions.yml |
Updates PR validation to enforce required files, schema validation, and screenshot asset existence. |
.github/workflows/build-website.yml |
Expands watched paths so extension/schema changes trigger the website build. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Low
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
- Add ajv-cli@5 as a pinned devDependency; install via npm ci in CI instead of npx --yes - Fix screenshot path regex to prevent .. traversal segments - Validate canvas.schema.json is parseable JSON even on schema-only PRs Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
| errors+=("\`$ext_dir\`: missing required \`assets/preview.png\`.") | ||
| fi | ||
|
|
||
| if ! schema_output="$(npx ajv-cli validate --spec=draft7 --strict=false -s .schemas/canvas.schema.json -d "$ext_dir/canvas.json" 2>&1)"; then |
| <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg"> | ||
| <a href="https://all-contributors.js.org/docs/en/bot/usage">Add your contributions</a> | ||
| </img> | ||
| <img src="https://raw.githubusercontent.com/all-contributors/all-contributors-cli/1b8533af435da9854653492b1327a23a4dbd0a10/assets/logo-small.svg" /> |
| "author": "GitHub", | ||
| "license": "MIT", | ||
| "devDependencies": { | ||
| "ajv-cli": "^5.0.0", |
| errors+=("\`$ext_dir\`: missing required \`assets/preview.png\`.") | ||
| fi | ||
|
|
||
| if ! schema_output="$(npx ajv-cli validate --spec=draft7 --strict=false -s .schemas/canvas.schema.json -d "$ext_dir/canvas.json" 2>&1)"; then |
Comment on lines
11
to
+15
| - instructions | ||
| - hooks | ||
| - workflows | ||
| - extensions | ||
| - .schemas/canvas.schema.json |
Comment on lines
40
to
42
| "devDependencies": { | ||
| "ajv-cli": "^5.0.0", | ||
| "all-contributors-cli": "^6.26.1" |
Switch from newline to null-terminated git diff output (git diff -z) so filenames containing newlines are read atomically, matching the existing skill-check.yml pattern. Add an allowlist regex guard on the extracted extension directory name immediately after it is parsed from git diff output. Any name not matching ^[a-z0-9][a-z0-9-]*$ (e.g. names containing dollar signs, parentheses, spaces, or other shell metacharacters) is silently skipped before being used anywhere in the script. Add a matching allowlist guard on each screenshot path extracted from canvas.json before the file-existence check, so a crafted manifest cannot supply a path with shell metacharacters or traversal segments even after the schema check passes. Follows the same defence-in-depth pattern introduced after the injection PoCs in #1236 and #1240. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.mainbranch for this pull request.Description
Adds a dedicated JSON schema for
extensions/*/canvas.jsonand upgrades canvas extension PR validation to enforce required files, schema compliance, and referenced screenshot asset existence.To avoid duplicate website builds across workflows, website build triggering is centralized in
build-website.ymlby expanding its watched paths to include extension and canvas-schema changes.Type of Contribution
Additional Notes
N/A
By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.