Add schema pattern validation for github-token fields#2468
Merged
Conversation
- Added JSON schema pattern validation for all github-token fields
- Created reusable $defs/github_token definition
- Pattern enforces secret expressions: ${{ secrets.* }}
- Supports fallback syntax: ${{ secrets.A || secrets.B }}
- Added comprehensive test suite (26 test cases)
- Tests cover valid and invalid tokens in all contexts
- All existing tests continue to pass
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Added caution callout in frontmatter reference - Added security tip in security guide - Documents valid and invalid token formats - Explains automatic validation during compilation Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
pelikhan
approved these changes
Oct 25, 2025
Contributor
|
Agentic Changeset Generator triggered by this pull request. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements JSON schema pattern validation for github-token fields to prevent accidental plaintext secret leakage. Per the issue discussion, Option B was chosen to add schema-level validation rather than runtime checks.
Key changes:
- Added regex pattern validation to reject plaintext tokens and non-secret expressions
- Created comprehensive test coverage with 26 test cases across all
github-tokenfield locations - Updated documentation to explain the validation behavior and requirements
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/parser/schemas/main_workflow_schema.json | Added github_token definition with regex pattern; updated 16 field locations to reference it |
| pkg/workflow/github_token_validation_test.go | Created comprehensive test suite covering valid/invalid tokens across all schema locations |
| docs/src/content/docs/reference/frontmatter.md | Added caution callout documenting valid/invalid token formats |
| docs/src/content/docs/guides/security.md | Added tip callout explaining automatic validation behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copilot
AI
changed the title
[WIP] Add github-token secret validation
Add schema pattern validation for github-token fields
Oct 25, 2025
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Contributor
Author
All formatting and linting checks pass successfully. No changes needed - the code is already properly formatted. |
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.
Prevents accidental secret leakage by enforcing GitHub Actions secret expressions for all
github-tokenfields via JSON schema pattern validation.Changes
$defs/github_tokenwith regex pattern^\$\{\{\s*secrets\.[A-Za-z_][A-Za-z0-9_]*(\s*\|\|\s*secrets\.[A-Za-z_][A-Za-z0-9_]*)*\s*\}\}$applied to 16 field locations (top-level, safe-outputs global/individual, tools.github)Validation Examples
✅ Valid
❌ Invalid (compilation fails)
Error Message
Resolves #2457 (Option B implementation as requested)
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.