Skip to content

Restrict runtime-import to .github folder with automatic prefix trimming#9316

Merged
pelikhan merged 4 commits intomainfrom
copilot/restrict-runtime-import-paths
Jan 8, 2026
Merged

Restrict runtime-import to .github folder with automatic prefix trimming#9316
pelikhan merged 4 commits intomainfrom
copilot/restrict-runtime-import-paths

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 8, 2026

The runtime-import macro now only imports files from the .github folder to prevent access to arbitrary repository files. Paths are automatically normalized: both file.md and .github/file.md resolve to .github/file.md.

Changes

  • Path Resolution: All file paths resolve within .github folder relative to git root
  • Prefix Normalization: Automatic trimming of .github/, ./, and .\\ prefixes
  • Security Validation: Path traversal attempts (../../../etc/passwd) rejected with clear error messages
  • URL Behavior: HTTP/HTTPS URLs remain unrestricted

Usage

# All equivalent - resolve to .github/coding-standards.md
{{#runtime-import coding-standards.md}}
{{#runtime-import .github/coding-standards.md}}
@./coding-standards.md

# Subdirectories work within .github
{{#runtime-import workflows/shared/template.md}}

# URLs unrestricted
{{#runtime-import https://example.com/external.md}}

# Outside .github rejected
{{#runtime-import ../src/config.go}}  # Error: must be within .github folder

Test Coverage

  • 88 runtime import tests updated for .github folder structure
  • Added tests for prefix trimming, security validation, subdirectory navigation
  • All 2,531 JavaScript tests passing
Original prompt

Restrict the runtime-import macro to only import files from the .github folder (from the git root). When resolving files, trim .github/ folder if needed.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 8, 2026 05:24
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Restrict runtime-import macro to .github folder Restrict runtime-import to .github folder with automatic prefix trimming Jan 8, 2026
Copilot AI requested a review from pelikhan January 8, 2026 05:46
@pelikhan pelikhan marked this pull request as ready for review January 8, 2026 05:48
@pelikhan pelikhan merged commit a678e69 into main Jan 8, 2026
149 of 150 checks passed
@pelikhan pelikhan deleted the copilot/restrict-runtime-import-paths branch January 8, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants