Skip to content

Add code scanning alert update tool - #3888

Open
belaltaher8 wants to merge 2 commits into
belaltaher8-oss-dependabot-alert-updatefrom
belaltaher8-oss-code-scanning-alert-update
Open

belaltaher8 wants to merge 2 commits into
belaltaher8-oss-dependabot-alert-updatefrom
belaltaher8-oss-code-scanning-alert-update

Conversation

@belaltaher8

@belaltaher8 belaltaher8 commented Nov 18, 2026 •

Copy link
Copy Markdown

Summary

Add update_code_scanning_alert for reopening, dismissing, requesting delegated dismissal, and replacing assignees through GitHub's public REST API. Depends on #3887; this PR contains only the code-scanning layer.

Why

Code scanning alerts can currently be read but not updated through this server. This adds an opt-in write tool without changing existing read tools.

What changed

  • Add authenticated PATCH requests using the configured client's base URL, transport, authentication and default API version, exact positive int64 IDs, nullable dismissal fields, and strict input validation for registered and direct/library calls. No per-request API-version override is needed: the public 2022-11-28 schema supports these fields.
  • Register the tool in code_security, 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 (decimal string), nullable state, HTML URL, dismissal reason, and reported assignees. Add schema snapshots, CLI scope coverage, generated documentation, and security-triage skill guidance.
  • Identify dismissal arguments in decoding errors and explain that an unreadable or invalid successful response may represent an applied update: verify with get_code_scanning_alert before retrying. No automatic retries or follow-up writes are added.

MCP impact

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

update_code_scanning_alert requires separate owner, repo, and alertNumber, plus state or assignees. Dismissal requires a non-null reason; create_request: true additionally requires dismissed state. Explicit null dismissal fields and empty assignee arrays retain their API meaning. Unknown fields, including agent configuration, are rejected.

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.

  • "Dismiss code scanning alert 42 as a false positive with a comment."
  • "Reopen alert 42 and clear its dismissal fields."
  • "Replace alert 42's assignees with octocat and copilot-swe-agent[bot]," and "Clear all assignees."
  • "Request delegated dismissal of alert 42 as mitigated," including responses that leave the alert open.

Security / limits

  • No security or limits impact
  • Auth / permissions considered

Uses the authenticated client and existing GitHub error handling for non-success responses. GitHub enforces repository permissions, delegated dismissal policy, and agentic Autofix eligibility; there are no fallback writes, identity bypasses, licensing changes, or agent-configuration inputs. Copilot assignment may consume Code Security AI Credits and Actions minutes and does not prove a session or pull request exists.

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

Results exclude code snippets and full alert payloads. Comments are limited to 280 characters. Original JSON is validated before numeric conversion and reread in the handler, preserving IDs through int64 maximum and rejecting fractional/overflowing targets. Tool schemas avoid unsupported top-level combinators.

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:

  • script/lint — passed, 0 issues, including after rebasing onto the updated parent.
  • script/test — passed, full race suite (go test -race ./...), including after rebasing onto the updated parent.
  • UPDATE_TOOLSNAPS=true go test ./... — passed during initial implementation; UPDATE_TOOLSNAPS=true go test ./pkg/github -run TestUpdateCodeScanningAlert -count=1 — passed for the field-description update.
  • go test ./pkg/github -run TestUpdateCodeScanningAlert -count=1 — passed for the final client-version and uncertain-response regressions.
  • go test ./pkg/inventory ./pkg/scopes ./pkg/skills/catalog ./cmd/github-mcp-server -count=1 — passed.
  • script/generate-docs — passed after the final rebase; generated files are current.
  • go build ./cmd/github-mcp-server ./cmd/mcpcurl — passed after the final rebase.
  • go run ./cmd/github-mcp-server list-scopes --toolsets=all --output=json — passed; combined inventory contains 149 tools, including both alert-update tools with security_events.

Focused registered-call coverage includes exact IDs above 2^53 and at int64 maximum, fractional/overflow rejection, nullable fields, actual returned state, assignee replacement/clearing, upstream errors, IFC labels, read-only exclusion, schema compatibility, field-specific decoding diagnostics, and one-PATCH uncertain-success handling. Configured-client tests cover default github.com routing and an actual HTTP server configured through WithEnterpriseURLs, preserving /api/v3, authentication and the client's default API version in both protocol eras. The custom PATCH DTO remains necessary because the SDK update type requires state and lacks assignees, create_request and explicit-null support. Dependabot implementation, tests, and snapshot are unchanged relative to the updated parent. Live PAT-dependent e2e tests were not run.

Docs

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

Regenerated README tool documentation, including state and dismissal-comment guidance, and updated the security-alert source reference.

Skills

  • Updated relevant skills or confirmed no bundled skill applies

Updated security-alert-triage and its optional tool catalog entry with nullable fields, delegated-dismissal policy, assignees, and actual-result reporting.

@belaltaher8
belaltaher8 requested a review from a team as a code owner November 18, 2026 19:27
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 19:27
@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

Missing schema descriptions and unnamed dismissal-field decoding errors leave generated documentation incomplete and callers without clear guidance on which argument to fix.

2 open issues
What changed in this PR

Adds update_code_scanning_alert to the opt-in code_security toolset, extending existing alert reads with write operations while excluding the tool from read-only mode.

Changes:

  • Supports reopening, dismissal, delegated dismissal requests, and assignee replacement or clearing.
  • Validates exact alert IDs and inputs, uses a request-local API version, and returns a limited, security-labeled response.
  • Adds registration, scope and schema coverage, generated documentation, and security-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 workflows and result reporting.
pkg/​skills/​catalog/​skills/​security-alert-triage/​references/​alert-sources.md Lists update support and delegated-dismissal behavior.
pkg/​github/​update_code_scanning_alert.go Implements validation, authenticated updates, and limited results.
pkg/​github/​update_code_scanning_alert_test.go Covers updates, validation, exact IDs, errors, and registration.
pkg/​github/​typed_security_outputs_test.go Registers the new output schema for verification.
pkg/​github/​tools.go Adds the tool to the server inventory.
pkg/​github/​__toolsnaps__/​update_code_scanning_alert.snap Records tool metadata and schemas.
cmd/​github-mcp-server/​main_test.go Checks scope listing and read-only exclusion.

Review effort: Max (adaptive)

@belaltaher8 belaltaher8 mentioned this pull request Nov 18, 2026
8 of 14 tasks
belaltaher8 and others added 2 commits November 18, 2026 15:00
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-code-scanning-alert-update branch from 6e647f8 to 931f6c7 Compare November 18, 2026 20:05
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