Remove github.actor and github.workflow from allowed expressions#2642
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Agentic Changeset Generator triggered by this pull request. |
There was a problem hiding this comment.
Pull Request Overview
This PR removes github.actor and github.workflow from the list of allowed GitHub Actions context expressions in agentic workflows to prevent potential injection attacks. These user-controllable values have been replaced with safer alternatives like github.event.sender.id (system-generated) or static text placeholders.
Key Changes:
- Removed
github.actorandgithub.workflowfrom the allowed expressions list - Updated 33 test cases to expect rejection of these expressions instead of allowing them
- Migrated 22 workflow files to use safer alternatives
Reviewed Changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/constants/constants.go |
Removed github.actor and github.workflow from AllowedExpressions array |
pkg/workflow/expression_safety_test.go |
Updated 14 test cases to expect rejection of github.actor and github.workflow |
pkg/workflow/expression_parser_comprehensive_test.go |
Updated 13 test cases to expect rejection in complex expressions |
pkg/workflow/template_expression_integration_test.go |
Replaced github.actor with github.event.sender.id in template tests |
.github/workflows/*.md (22 files) |
Replaced ${{ github.actor }} with "the user" or "@user" and ${{ github.workflow }} with "this workflow" |
.github/workflows/*.lock.yml (22 files) |
Regenerated lock files reflecting the markdown changes |
.github/instructions/github-agentic-workflows.instructions.md |
Updated documentation to remove blocked expressions and show them as invalid examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| toolset: [default, discussions] | ||
| cache-memory: | ||
| key: schema-consistency-cache-${{ github.workflow }} | ||
| key: schema-consistency-cache-this workflow |
There was a problem hiding this comment.
The cache key contains a literal space in 'this workflow' which will be used as-is in the cache key. GitHub Actions cache keys should not contain spaces. Consider using a hyphenated form like 'this-workflow' or 'schema-consistency' instead.
| key: schema-consistency-cache-this workflow | |
| key: schema-consistency-cache-this-workflow |
| # Memory cache for persistent AI memory across runs | ||
| cache-memory: | ||
| key: poem-memory-${{ github.workflow }}-${{ github.run_id }} | ||
| key: poem-memory-this workflow-${{ github.run_id }} |
There was a problem hiding this comment.
The cache key contains a literal space in 'this workflow' which will be used as-is in the cache key. GitHub Actions cache keys should not contain spaces. Consider using a hyphenated form like 'this-workflow' or 'poem-memory' instead.
| key: poem-memory-this workflow-${{ github.run_id }} | |
| key: poem-memory-this-workflow-${{ github.run_id }} |
|
@copilot Keep |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…ines Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot review instructions.md and prompt.md files and make sure the experessions are not used there |
…m allowed list Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in commit 793253a. Reviewed both
|
| # Environment: ${{ env.MY_VAR }} | ||
| # Complex: ${{ toJson(github.workflow) }} | ||
| # Actor: ${{ github.actor }} | ||
| # Workflow: ${{ github.workflow }} |
There was a problem hiding this comment.
Done in commit 597b4e5. Removed the # Workflow: ${{ github.workflow }} line from the invalid expressions examples in both instruction files. This makes it clearer that github.workflow is context-dependent - invalid in markdown content but valid in cache keys.
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
github.actorandgithub.workflowfrom AllowedExpressions in pkg/constants/constants.gogithub.workflowin cache keys (frontmatter) - it's safe theregithub.workflowfrom invalid expressions examples (since it's valid in cache keys)Summary
Successfully removed
github.actorandgithub.workflowfrom the allowed expressions list for user-facing markdown content. These expressions are now properly rejected during workflow compilation as they can contain user-controllable content that could be used for injection attacks.Latest Changes
Removed
github.workflowfrom the invalid expressions examples section in both instruction files. This makes the documentation clearer sincegithub.workflowis actually allowed in specific contexts (cache keys in frontmatter), so it shouldn't be shown as completely invalid.Key points:
github.actor- Completely blocked (remains in invalid examples)github.workflow- Blocked in markdown content, allowed in cache keys (removed from invalid examples to avoid confusion)All tests pass and workflows compile successfully.
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.