Skip to content

ci: keep AZURE_OPENAI_API_KEY out of pull request runs - #323

Merged
Krishnadheeraj (DheerajPannala) merged 3 commits into
mainfrom
users/DheerajPannala/glasswing-ci-secret
Oct 27, 2026
Merged

Krishnadheeraj (DheerajPannala) merged 3 commits into
mainfrom
users/DheerajPannala/glasswing-ci-secret

Conversation

@DheerajPannala

@DheerajPannala Krishnadheeraj (DheerajPannala) commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The integration-test step in .github/workflows/ci.yml ran in the pull_request job with AZURE_OPENAI_API_KEY. That step runs npm run test:integration, which executes the Jest config and test files from the PR itself. So code that hadn't been reviewed yet could read the key (CWE-522).

Change

  • Removed the integration-test step from the Node.js SDK job, which runs on every PR.
  • Added an Integration tests job that:
    • runs only on push (after merge)
    • is bound to the integration-tests environment
    • keeps the same Node 18/20 matrix and runs after the SDK job

Lint, unit tests, build and pack still run on every PR.

Why an environment

A pull_request run uses the workflow file from the PR, so an if: condition alone can be edited away by the PR author. An environment secret is only released to jobs whose ref passes the environment's deployment rules. With the environment limited to main, PR-authored workflows can't read the key, even if edited.

Admin step after merge

Until this step is done, the job falls back to the existing repository secret, so CI keeps working.

  1. Settings → Environments → create or open integration-tests → Deployment branches and tags → Selected branches → add main.
  2. Rotate the Azure OpenAI key, and add the new key as the environment secret AZURE_OPENAI_API_KEY.
  3. Delete the repository-level AZURE_OPENAI_API_KEY secret.

Run the integration-test step only on push. pull_request runs execute PR-authored Jest config and tests, so they must not receive repository secrets (CWE-522).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bde58a51-73ec-4b37-b60a-0b499ca60eb0
Copilot AI balanced review requested due to automatic review settings October 15, 2026 15:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Same-repository PRs can bypass the workflow condition, so secret access needs an independently enforced protection boundary.

1 open finding
What changed in this PR

Restricts secret-bearing integration tests to push runs while preserving other PR validation.

Changes:

  • Adds a push-only condition to the integration-test step.
  • Documents why unreviewed PR code should not receive repository secrets.
File Description
.github/​workflows/​ci.yml Gates integration tests on push events.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/ci.yml Resolved
@DheerajPannala Krishnadheeraj (DheerajPannala) changed the title ci: don't expose AZURE_OPENAI_API_KEY to pull request runs ci: don't expose data to pull request runs Oct 15, 2026
@dbezic

Copy link
Copy Markdown
Contributor

Do we want to disable integration tests for PRs? I feel like there should be another fix for this

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bde58a51-73ec-4b37-b60a-0b499ca60eb0
…ironment

A step-level if: is not a boundary: pull_request runs use the PR's own workflow file, so an author could drop the condition. Move the integration tests into a push-only job that uses the integration-tests environment, so the key can live in an environment secret limited to main.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: bde58a51-73ec-4b37-b60a-0b499ca60eb0
Copilot AI balanced review requested due to automatic review settings October 27, 2026 11:19
@DheerajPannala Krishnadheeraj (DheerajPannala) changed the title ci: don't expose data to pull request runs ci: keep AZURE_OPENAI_API_KEY out of pull request runs Oct 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Maintainers must verify environment branch restrictions and confirm the API key is unavailable through repository or organization secrets.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@DheerajPannala
Krishnadheeraj (DheerajPannala) merged commit 9719665 into main Oct 27, 2026
10 checks passed
@DheerajPannala
Krishnadheeraj (DheerajPannala) deleted the users/DheerajPannala/glasswing-ci-secret branch October 27, 2026 15:20
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.

4 participants