github / github/copilot-cli

Content exclusion incorrectly blocks commands when a child process loads .env

未关闭
#4,871 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

triage
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

Describe the bug

Our organization has the following content-exclusion policy:

"*":
  - "**/.env"

The policy should prevent Copilot from reading .env files or using their contents as model context.

However, Copilot CLI also blocks starting an application when the application itself loads .env during normal startup.

For example, our Python application uses load_dotenv() during startup. The application starts successfully when run directly in the terminal, but Copilot CLI refuses to continue when asked to run the same approved command.

The error shown is:

Access denied: "[REDACTED]/.env" is excluded by organization content policy. Do not attempt to access this file.

Copilot does not need to read .env, receive its contents, or include them in model context for the application to start.

Affected version

GitHub Copilot CLI 1.0.83

Steps to reproduce the behavior
  1. Configure an organization content-exclusion rule for **/.env.
  2. Create an application that loads .env internally during startup, for example using python-dotenv and load_dotenv().
  3. Verify that the application starts successfully when run directly in a terminal.
  4. Ask Copilot CLI to run the same startup command.
  5. Approve the command.
  6. Observe that Copilot CLI refuses to continue because .env is excluded.

Expected behavior

Copilot CLI should execute the approved command.

Content exclusion should prevent Copilot from reading or using .env contents as model context, but should not prevent an application from loading the file internally as runtime configuration.

Additional context
  • OS: macOS 26.6.2
  • Architecture: arm64
  • Shell: zsh

This began after content exclusions became generally available in Copilot App and CLI on September 2, 2026:
https://github.blog/changelog/2026-09-02-content-exclusions-generally-available-in-copilot-app-and-cli/

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用 issue 中描述的 Python 应用程序和 load_dotenv(),复现通过组织规则排除 **/.env 的已批准命令。跟踪对子进程的内容排除处理;当已批准的应用程序启动,同时 .env 内容仍无法作为模型上下文提供给 Copilot 时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
shell
领域
cli, security
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。