Skip to content

Add secret scanning alert update tool - #3889

Open
belaltaher8 wants to merge 3 commits into
belaltaher8-oss-code-scanning-alert-updatefrom
belaltaher8-oss-secret-scanning-alert-update
Open

belaltaher8 wants to merge 3 commits into
belaltaher8-oss-code-scanning-alert-updatefrom
belaltaher8-oss-secret-scanning-alert-update

Conversation

@belaltaher8

@belaltaher8 belaltaher8 commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

Add update_secret_scanning_alert to reopen or resolve alerts, change an assignee, and set or clear a custom-pattern validity override through GitHub's public REST API. Depends on #3888; this PR contains only the secret-scanning layer.

Why

Secret scanning alerts can currently be read but not updated through this server. This adds an opt-in write tool without changing the existing read helpers or the lower alert-update implementations.

What changed

  • Add authenticated PATCH requests inheriting the configured client's API defaults, base URL, headers, and transport, with exact positive int64 IDs, nullable PATCH fields, and strict validation for registered and direct/library calls. No per-request API-version override or cloud/enterprise split is introduced.
  • Register the tool in secret_protection, exclude it from read-only mode, require security_events, and attach the existing security-alert IFC label to successful results.
  • Return only the actual alert number as a decimal string, state, resolution, assignee login, and reported validity; add protocol, snapshot, CLI scope, generated documentation, and bundled skill coverage.
  • Explain uncertain outcomes when GitHub accepts a write but its response cannot be read or validated: inspect the alert before retrying. Do not retry automatically. Clarify that manual validity overrides apply only to custom-pattern alerts; GitHub-supported validity remains validator-managed.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

update_secret_scanning_alert requires separate owner, repo, and alertNumber, plus at least one of state, assignee, or validity. Resolving requires a non-null resolution. Omitted fields remain unchanged; explicit nulls retain their PATCH meaning. Unknown fields and invalid enums are rejected, including through direct/library calls. No confirmation Boolean or approval endpoint is added.

Prompts tested (tool changes only)

Prompt-equivalent registered MCP calls were tested against mocked HTTP responses in legacy and modern protocol eras; natural-language routing and live GitHub writes were not run.

  • "Resolve secret scanning alert 42 as revoked with a comment after external credential rotation."
  • "Reopen secret scanning alert 42 and clear its resolution fields."
  • "Assign secret scanning alert 42 to octocat," and "Unassign alert 42."
  • "Mark custom-pattern alert 42's validity inactive," and "Clear its manual validity override."

Security / limits

  • No security or limits impact
  • Auth / permissions considered

Uses the authenticated client and existing GitHub error handling. GitHub enforces repository permissions and delegated dismissal policy; there are no fallback writes, permission bypasses, licensing changes, or identity changes. Resolving as revoked does not revoke or rotate credentials, and a validity override does not validate a secret. The custom-pattern restriction is documentation, not a new client-side policy check or extra API request.

  • Data exposure, filtering, or token/size limits considered

The output projection excludes literal secrets, comments, metadata, and full user objects. Original JSON is validated before SDK numeric conversion and reread in the handler, preserving IDs above 2^53 through int64 maximum and rejecting fractional/overflowing targets. Responses must identify the requested alert. No invented comment-length limit or unsupported top-level schema combinators are introduced. A malformed or unexpected success response reports that the update may already have applied; inspect with get_secret_scanning_alert and hide_secret: true before retrying.

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Commands run and results:

  • go test ./pkg/github ./cmd/github-mcp-server ./pkg/skills/catalog -run 'Test(Update(SecretScanning|CodeScanning|Dependabot)Alert|.*UpdateListScopes|CatalogToolRequirementsAreRegistered|ToolsetInstructionsAreCoveredBySkills)' -count=1 — passed on the final rebased stack.
  • script/lint — passed, 0 issues, on the final rebased stack.
  • script/test — passed, full race suite (go test -race ./...), on the final rebased stack.
  • UPDATE_TOOLSNAPS=true go test ./... — passed during initial implementation.
  • UPDATE_TOOLSNAPS=true go test ./pkg/github -run TestUpdateSecretScanningAlert -count=1 — passed after the validity-description clarification; snapshot refreshed.
  • script/generate-docs — passed on the final rebased stack; generated files unchanged after regeneration.
  • go build ./cmd/github-mcp-server ./cmd/mcpcurl — passed on the final rebased stack.
  • go run ./cmd/github-mcp-server list-scopes --toolsets=all --output=json — passed during implementation; 150 tools, including all three alert-update tools with security_events.

Focused coverage includes protocols 2025-11-25 and 2026-07-28, exact ID boundaries, direct/library input validation, null versus omission, all supported update reasons, assignment and validity changes, actual returned state, narrow output, upstream failures, IFC labels, opt-in/read-only/scope filtering, portable advertised schemas, cloud/enterprise configured-client inheritance, and unchanged shared-client defaults. Uncertain-success tests cover malformed/empty/type-invalid/mismatched responses and 202/204 with exactly one PATCH and no retry. Existing read helpers and both lower update implementations/tests/snapshots are unchanged relative to the updated base. Live PAT-dependent e2e tests were not run.

Docs

  • Not needed
  • Updated (README / docs / examples)

Regenerated README tool documentation and updated the security-alert source reference. Tool and field descriptions explain custom-pattern-only validity overrides, as documented in the public changelog. The versioned public REST schema includes all requested PATCH fields; no newer API version is required.

Skills

  • Updated relevant skills or confirmed no bundled skill applies

Updated security-alert-triage and its optional tool catalog entry. Guidance distinguishes alert disposition, secret values, custom-pattern-only manual validity overrides, actual credential revocation, and inspecting the alert before retrying an uncertain update.

@belaltaher8
belaltaher8 requested a review from a team as a code owner November 18, 2026 19:37
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 19:37
@belaltaher8
belaltaher8 added this pull request to stack #3890 November 18, 2026 19:38

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

The documentation omits that manual validity overrides are limited to custom-pattern alerts, potentially leading callers to request unsupported updates that return 422 errors.

1 open issue
What changed in this PR

Adds opt-in secret-scanning alert updates to GitHub MCP Server, extending the existing security-alert write tools.

Changes:

  • Support reopening or resolving alerts, changing assignees, and setting or clearing validity overrides.
  • Add strict input validation, scope enforcement, read-only exclusion, and minimal labeled responses.
  • Add protocol, schema, and CLI coverage, plus documentation and triage guidance.
File Description
README.md Documents the new tool and parameters.
pkg/​skills/​catalog/​tools.go Adds the tool to the security-triage catalog.
pkg/​skills/​catalog/​skills/​security-alert-triage/​SKILL.md Explains update usage and credential-revocation limits.
pkg/​skills/​catalog/​skills/​security-alert-triage/​references/​alert-sources.md Adds the tool and clarifies alert dispositions.
pkg/​github/​update_secret_scanning_alert.go Implements validation, authenticated updates, and narrow responses.
pkg/​github/​update_secret_scanning_alert_test.go Covers updates, validation, errors, precision, and registration.
pkg/​github/​typed_security_outputs_test.go Adds typed output-schema coverage.
pkg/​github/​tools.go Registers the new tool.
pkg/​github/​__toolsnaps__/​update_secret_scanning_alert.snap Records the tool’s schema and annotations.
cmd/​github-mcp-server/​main_test.go Checks CLI scopes and read-only exclusion.

Review effort: Max (adaptive)

belaltaher8 and others added 3 commits November 18, 2026 15:07
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@belaltaher8
belaltaher8 force-pushed the belaltaher8-oss-secret-scanning-alert-update branch from 29c566c to 1f9f286 Compare November 18, 2026 20:12
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.

3 participants