mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
fix: address Copilot PR review comments on agent-governance skill
- Use context manager and path validation for file reading example - Block directory traversal attacks with os.path.realpath check - Update terminology: whitelist/blacklist -> allowlist/blocklist Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -499,7 +499,12 @@ policy = GovernancePolicy(
|
|||||||
@govern(policy)
|
@govern(policy)
|
||||||
async def read_file(path: str) -> str:
|
async def read_file(path: str) -> str:
|
||||||
"""Read file contents — governed."""
|
"""Read file contents — governed."""
|
||||||
return open(path).read()
|
import os
|
||||||
|
safe_path = os.path.realpath(path)
|
||||||
|
if not safe_path.startswith(os.path.realpath(".")):
|
||||||
|
raise ValueError("Path traversal blocked by governance")
|
||||||
|
with open(safe_path) as f:
|
||||||
|
return f.read()
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
Reference in New Issue
Block a user