fix(hosted): prevent credential disclosure by gating mentions and redacting published results - #81
Open
BunsDev wants to merge 1 commit into
Open
fix(hosted): prevent credential disclosure by gating mentions and redacting published results#81BunsDev wants to merge 1 commit into
BunsDev wants to merge 1 commit into
Conversation
Signed-off-by: Codex <codex@openai.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the hosted GitHub adapter against credential disclosure by (1) preventing untrusted users’ mentions from queuing privileged work and (2) redacting secrets from runtime results before publishing them back to GitHub comments.
Changes:
- Add
comment_author_is_trusted()and gateissue_comment/pull_request_review_commentmention-triggered task creation toOWNER/MEMBER/COLLABORATOR. - Introduce
redact_secrets()and apply it to published comment bodies inpublish_result_if_configured(). - Add adapter unit tests covering the trust gate and publication redaction behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| deploy/coven-github/coven_github_adapter.py | Adds comment-author trust gating for mention triggers and redacts secrets before publishing results as GitHub comments. |
| deploy/coven-github/test_coven_github_adapter.py | Adds regression tests for rejecting untrusted comment authors, allowing trusted authors, and ensuring published comments redact credentials/token-like strings. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+1667
to
+1676
| def redact_secrets(text, secret_values=()): | ||
| redacted = str(text) | ||
| for secret in secret_values: | ||
| if secret: | ||
| redacted = redacted.replace(str(secret), "[redacted]") | ||
| redacted = redact_tokenish(redacted) | ||
| return re.sub( | ||
| r"(?<![A-Za-z0-9])sk-[A-Za-z0-9_-]{12,}", | ||
| "sk-[redacted]", | ||
| redacted, |
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.
Motivation
Description
comment_author_is_trusted()and refuse to queue tasks forissue_commentandpull_request_review_commentevents when the comment author association is notOWNER,MEMBER, orCOLLABORATOR.redact_secrets()and applying it to the rendered publication body to remove the installation token, the Codex/OpenAI token, recognized GitHub token markers, and OpenAI-stylesk-tokens before POSTing to GitHub.Testing
python -m unittest deploy/coven-github/test_coven_github_adapter.py, and the adapter unit tests passed (8 tests).python -m py_compileon the modified Python files and it succeeded.cargo check --all-targetsandcargo clippy --all-targets -- -D warnings, which completed successfully.cargo test --all; the Rust suites largely passed, but the worker integration suite reported 73 passing tests and 21 failures caused by environment-level HTTP 403 responses to mocked GitHub calls in this execution environment (failures are test-environment related and not caused by the Python adapter change).Codex Task