Skip to content

Honour the VS Code Checkmarx Self-Healing setting in Copilot agent hooks (AST-180812) - #1603

Merged
cx-rahul-pidde merged 8 commits into
stagingfrom
feature/AST-180812-vscode-self-healing-signed
Oct 28, 2026
Merged

cx-rahul-pidde merged 8 commits into
stagingfrom
feature/AST-180812-vscode-self-healing-signed

Conversation

@cx-rahul-pidde

Copy link
Copy Markdown
Contributor

Replaces #1601 (same change; the new branch carries signed commits, the old branch history could not be re-signed because of a repository rule).

Summary

Epic: AST-180812 · Design: TDD · Host detection based on the AST-186850 PoC (feature/AST-186850-vsCodeInstallItself)

GitHub Copilot in VS Code runs the cx-devassist Copilot plugin's hooks (cx hooks copilot-cli-*). The Checkmarx VS Code extension writes its Checkmarx Self-Healing setting and scanner switches to ~/.checkmarx/cx-onboarding-ide.properties. This PR lets the agent hooks honour that file for Copilot inside VS Code only.

Changes (internal/commands/agenthooks)

  • cx/hooks.go
    • pluginHost(): host from the PLUGIN_ROOT the host injects — /.copilot/installed-plugins/ → terminal (checked first), /agentplugins/ → VS Code (Windows/macOS/Linux, Insiders); fallback GITHUB_COPILOT_INTEGRATION_ID=vscode-chat.
    • selfHealingOff() in cxBeforeFileEdit only: Copilot in VS Code + cx_self_healing_enabled=false → ASCA / KICS / SCA-manifest / Secrets skipped, no telemetry, verbose log skip_reason=self_healing_disabled. Shell-command policy (blacklist / ask-user), the SCA package-install scan and prompt guardrails are unchanged.
    • scannerOn(): Copilot in VS Code takes scanner switches from the IDE file while it is valid, else from cx-onboarding.properties.
  • scannerconfig/scannerconfig.go: IDE file reader (IDEPath, SelfHealingEnabled, IDEEnabled). Missing, unreadable, > 8 KB or unknown cx_schema_version → on / fallback.

The terminal Copilot CLI and all other agents never read the IDE file. No go.mod / ast-cx-hooks change.

This is a backup for hooks that call cx directly (e.g. cx hooks install copilot); the plugin already stops before running cx when Self-Healing is off.

Companion PRs: cx-agentic-ai (Copilot plugin) and ast-vscode-extension.

Test plan

  • go vet ./internal/commands/agenthooks/...
  • go test ./internal/commands/agenthooks/... — all packages pass
  • New cx/vscode_self_healing_test.go: pluginHost table (incl. terminal-first order), OFF skips file-write scans, ON / missing / invalid file scans, terminal and other agents ignore the file, IDE scanner flags with fallback; existing blacklist / ask-user / SCA-install tests unchanged
  • scannerconfig tests for the IDE file rules
  • End-to-end with the Copilot plugin in VS Code

🤖 Generated with Claude Code

🤖 Generated with Claude Code

cx-rahul-pidde and others added 6 commits October 26, 2026 14:21
…ilot agent hooks

GitHub Copilot in VS Code runs the cx-devassist Copilot plugin's hooks, which
call `cx hooks copilot-cli-*`. The Checkmarx VS Code extension writes its
"Checkmarx Self-Healing" setting and scanner switches to
~/.checkmarx/cx-onboarding-ide.properties.

- pluginHost(): where a Copilot hook runs, from the PLUGIN_ROOT the host
  injects (AST-186850 PoC): ~/.copilot/installed-plugins → terminal (checked
  first), <VS Code user data>/agentPlugins → VS Code (all OSes, Insiders);
  fallback GITHUB_COPILOT_INTEGRATION_ID=vscode-chat.
- selfHealingOff(): for Copilot in VS Code with a valid IDE file saying
  cx_self_healing_enabled=false, the file-write handler skips ASCA / KICS /
  SCA-manifest / Secrets without telemetry. Shell-command policy, the SCA
  package-install scan and prompt guardrails are unchanged. Backup for hooks
  that call cx directly; the plugin already stops before running cx.
- scannerOn(): Copilot in VS Code takes scanner switches from the IDE file
  while it is valid, else from cx-onboarding.properties.
- scannerconfig: IDE file reader (IDEPath, SelfHealingEnabled, IDEEnabled);
  missing, unreadable, > 8 KB or unknown cx_schema_version means on.

The terminal Copilot CLI never reads the IDE file. No ast-cx-hooks change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
… host detection to VS Code

- New package agenthooks/hostenv: PluginHost() (moved from cx/hooks.go) and
  TelemetryAgent(). Only VS Code's own agentPlugins folder (Code, Code -
  Insiders) counts as VS Code; ~/.copilot/installed-plugins is the terminal
  (checked first); any other PLUGIN_ROOT (VS Code forks, JetBrains, Visual
  Studio, ...) is another editor; GITHUB_COPILOT_INTEGRATION_ID=vscode-chat is
  used only when PLUGIN_ROOT is not set.
- Telemetry agent for GitHub Copilot inside VS Code, by the extension that
  wrote the IDE file (cx_ide_extension): Copilot-VSCode-OneAssist (ast-results),
  Copilot-VSCode-DevAssist (cx-dev-assist), Copilot-VSCode (no valid file).
  Terminal Copilot and every other agent keep "<agent>-cli"; aiProvider is
  unchanged. Used by the ASCA, KICS, Secrets and remediation telemetry.
- scannerconfig.IDEExtension() reads cx_ide_extension from a valid IDE file.
- Self-Healing OFF only skips the file-write scans; shell-command policy, the
  SCA package-install scan and prompt guardrails always run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
VS Code has no severity threshold setting, so Copilot hooks running in VS Code now take
cx_severity_threshold only from ~/.checkmarx/cx-onboarding-ide.properties, which is unset today and
therefore low (nothing filtered). The terminal's cx-onboarding.properties threshold no longer relaxes
VS Code denies; the terminal Copilot CLI and other agents are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
- Drop Copilot-VSCode-OneAssist / Copilot-VSCode-DevAssist; GitHub Copilot
  inside VS Code now always reports "Copilot-VSCode".
- Remove the now-unused scannerconfig.IDEExtension() helper and the
  extension-specific test cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
Drop the GITHUB_COPILOT_INTEGRATION_ID=vscode-chat fallback: it names the
Copilot engine, not the plugin's host. Without PLUGIN_ROOT the host is now
unknown and handled like the terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
The VS Code extension writes cx_severity_threshold=low to its state file, so
only that file's value is read. Missing files, keys, or invalid values fall
back to low.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@cx-rahul-pidde
cx-rahul-pidde requested a review from a team October 28, 2026 10:53
@stepsecurity-app

stepsecurity-app Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

✅ Resolved — a later workflow run passed this policy check.

Original alert (resolved)

Security Policy Alert: Secret Policy Violation

This workflow run has been blocked by StepSecurity's secrets policy because it accesses secrets and the workflow file differs from the default branch.

Secret references detected:

  • secrets.CX_BASE_URI at line 222
  • secrets.CX_CLIENT_ID at line 223
  • secrets.CX_CLIENT_SECRET at line 224
  • secrets.CX_BASE_AUTH_URI at line 225
  • secrets.CX_AST_USERNAME at line 226
  • secrets.CX_AST_PASSWORD at line 227
  • secrets.CX_APIKEY at line 228
  • secrets.CX_TENANT at line 229
  • secrets.CX_SCAN_SSH_KEY at line 230
  • secrets.ECHO_LIBRARIES_ACCESS_KEY at line 232
  • secrets.PERSONAL_ACCESS_TOKEN at line 234
  • secrets.PROXY_USER at line 237
  • secrets.PROXY_PASSWORD at line 238
  • secrets.PR_GITLAB_TOKEN at line 243
  • secrets.PR_GITLAB_NAMESPACE at line 244
  • secrets.PR_GITLAB_REPO_NAME at line 245
  • secrets.PR_GITLAB_PROJECT_ID at line 246
  • secrets.PR_GITLAB_IID at line 247
  • secrets.AZURE_ORG at line 248
  • secrets.AZURE_PROJECT at line 249
  • secrets.AZURE_REPOS at line 250
  • secrets.AZURE_TOKEN at line 251
  • secrets.BITBUCKET_WORKSPACE at line 253
  • secrets.BITBUCKET_REPOS at line 254
  • secrets.BITBUCKET_USERNAME at line 255
  • secrets.BITBUCKET_PASSWORD at line 256
  • secrets.GITLAB_TOKEN at line 257
  • secrets.PR_BITBUCKET_TOKEN at line 259
  • secrets.MS_TEAMS_WEBHOOK_URL_INTEGRATION_TESTS at line 438

To approve this workflow, please add the workflows-approved label to this PR.

Note: The label must be added by someone other than the PR author (cx-rahul-pidde) or automation bots to ensure proper security review.

After the label is added, you can re-run the blocked workflow to proceed.

This workflow will be automatically approved once merged into the default branch.

For more information, see StepSecurity's Secret Exfiltration Policy documentation.

@cx-rahul-pidde
cx-rahul-pidde changed the base branch from main to staging October 28, 2026 12:13
@cx-rahul-pidde
cx-rahul-pidde changed the base branch from staging to main October 28, 2026 12:13
@cx-rahul-pidde cx-rahul-pidde changed the title AST-180812 - Honour the VS Code Checkmarx Self-Healing setting in Copilot agent hooks Honour the VS Code Checkmarx Self-Healing setting in Copilot agent hooks (AST-180812) Oct 28, 2026
Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@cx-kedar-bhujade
cx-kedar-bhujade self-requested a review October 28, 2026 12:42
@cx-rahul-pidde
cx-rahul-pidde changed the base branch from main to staging October 28, 2026 12:53
@cx-rahul-pidde
cx-rahul-pidde changed the base branch from staging to main October 28, 2026 12:54
@cx-rahul-pidde
cx-rahul-pidde dismissed cx-kedar-bhujade’s stale review October 28, 2026 12:54

The base branch was changed.

@cx-rahul-pidde
cx-rahul-pidde changed the base branch from main to staging October 28, 2026 14:05
@cx-rahul-pidde
cx-rahul-pidde changed the base branch from staging to main October 28, 2026 14:05
@cx-rahul-pidde
cx-rahul-pidde changed the base branch from main to staging October 28, 2026 14:36
@cx-rahul-pidde
cx-rahul-pidde merged commit 5b1e1eb into staging Oct 28, 2026
43 of 66 checks passed
cx-aniket-shinde added a commit that referenced this pull request Nov 5, 2026
* Honour the VS Code Checkmarx Self-Healing setting in Copilot agent hooks (AST-180812) (#1603)

* AST-180812 - Detect VS Code Copilot CLI sessions from GITHUB_COPILOT_INTEGRATION_ID (#1604)

* Feature/ast 180812 vscode copilot cli host (#1607)

* Update brotli dependency to v1.2.7 (AST-189161) (#1610)

* Update github.com/andybalholm/brotli from v1.2.0 to v1.2.7 (AST-189161)

Indirect dependency pulled in via anchore/syft -> anchore/archiver.
No API removals; archiver only uses NewWriterLevel/NewReader, which are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Update Docker base image checkmarx/bash:5.3 to latest digest (AST-189161)

Bumps the SHA256-pinned base image to the 5.3-r14 build pushed on 2026-11-04.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Replace .trivyignore entries with current binary findings (AST-189161)

Ignore GO-2026-5932 (x/crypto/openpgp via helm provenance), CVE-2026-78661 and
CVE-2026-97045 (x/net/html via syft Maven cataloger). Remove the previous Wolfi
base-image and syft/docker entries, which no longer apply.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Restore syft and docker entries in .trivyignore (AST-189161)

CVE-2026-33481 (syft temp cleanup) and CVE-2026-33997 (moby plugin privilege
bypass) are still reported against the binary. Neither has an adoptable fix:
syft >= 1.42.3 reintroduces the binary-size regression reverted in AST-188320
and docker/docker has no 29.x release on its module path. Justifications and
reachability analysis are recorded in the file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Bump golang.org/x/net to v0.62.0 and trim .trivyignore (AST-189161)

Bump the indirect golang.org/x/net dependency to v0.62.0, which fixes
CVE-2026-78661 and CVE-2026-97045, so their ignore entries are dropped.
Keep only the ignores that cannot be fixed directly: GO-2026-5932
(x/crypto openpgp, via helm), CVE-2026-33481 (syft) and CVE-2026-33997
(docker).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: atishj99 <atish.jadhav@checkmarx.com>

* revret exclude git config changes (#1609)

Co-authored-by: Aniket Shinde <aniket.shinde@checkmarx.com>

* Use self-repository syntax for reusable workflow in nightly-parallel (AST-189161)

Replace `uses: ./.github/workflows/ci-tests.yml` with the `$/` form to
satisfy the zizmor `self-repository` audit (added in zizmor v1.30.0).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Anurag Dalke <anurag.dalke@checkmarx.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: atishj99 <atish.jadhav@checkmarx.com>
Co-authored-by: Sumit Morchhale <sumit.morchhale@checkmarx.com>
Co-authored-by: Aniket Shinde <aniket.shinde@checkmarx.com>
cx-aniket-shinde added a commit that referenced this pull request Nov 12, 2026
* Honour the VS Code Checkmarx Self-Healing setting in Copilot agent hooks (AST-180812) (#1603)

* AST-180812 - Detect VS Code Copilot CLI sessions from GITHUB_COPILOT_INTEGRATION_ID (#1604)

* Feature/ast 180812 vscode copilot cli host (#1607)

* Update brotli dependency to v1.2.7 (AST-189161) (#1610)

* Update github.com/andybalholm/brotli from v1.2.0 to v1.2.7 (AST-189161)

Indirect dependency pulled in via anchore/syft -> anchore/archiver.
No API removals; archiver only uses NewWriterLevel/NewReader, which are unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Update Docker base image checkmarx/bash:5.3 to latest digest (AST-189161)

Bumps the SHA256-pinned base image to the 5.3-r14 build pushed on 2026-11-04.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Replace .trivyignore entries with current binary findings (AST-189161)

Ignore GO-2026-5932 (x/crypto/openpgp via helm provenance), CVE-2026-78661 and
CVE-2026-97045 (x/net/html via syft Maven cataloger). Remove the previous Wolfi
base-image and syft/docker entries, which no longer apply.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Restore syft and docker entries in .trivyignore (AST-189161)

CVE-2026-33481 (syft temp cleanup) and CVE-2026-33997 (moby plugin privilege
bypass) are still reported against the binary. Neither has an adoptable fix:
syft >= 1.42.3 reintroduces the binary-size regression reverted in AST-188320
and docker/docker has no 29.x release on its module path. Justifications and
reachability analysis are recorded in the file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* Bump golang.org/x/net to v0.62.0 and trim .trivyignore (AST-189161)

Bump the indirect golang.org/x/net dependency to v0.62.0, which fixes
CVE-2026-78661 and CVE-2026-97045, so their ignore entries are dropped.
Keep only the ignores that cannot be fixed directly: GO-2026-5932
(x/crypto openpgp, via helm), CVE-2026-33481 (syft) and CVE-2026-33997
(docker).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: atishj99 <atish.jadhav@checkmarx.com>

* revret exclude git config changes (#1609)

Co-authored-by: Aniket Shinde <aniket.shinde@checkmarx.com>

* Use self-repository syntax for reusable workflow in nightly-parallel (AST-189161)

Replace `uses: ./.github/workflows/ci-tests.yml` with the `$/` form to
satisfy the zizmor `self-repository` audit (added in zizmor v1.30.0).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Handle missing feature flags(AST-188568) (#1613)

* Handle missing feature flags gracefully (code 100 response)

When the API returns a 404 with error code 100 and message
"flag with the given name is not found", return a disabled flag
model instead of nil to prevent nil pointer dereference panics
in calling code. Missing flags are treated as enabled (default)
to ensure safe feature flag fallback behavior.

Fixes panic: runtime error: invalid memory address or nil pointer dereference
when GetSpecificFlag is called and the flag doesn't exist on the server.

* Refactor: use existing WebError struct instead of inline type

Replace inline error response struct with the existing WebError struct
from ast.go for consistency with the rest of the codebase. This improves
maintainability and follows the established pattern in wrappers like
bfl-http.go and codebashing-http.go.

* handle remove ff

* Remove INCREASE_FILE_UPLOAD_LIMIT flag - now always enabled for large files

Removed the INCREASE_FILE_UPLOAD_LIMIT feature flag that controlled multipart
uploads. The flag is now permanently enabled - files > 5GB always use multipart
upload, smaller files use single upload. This simplifies the code by removing
the flag check and associated tests.

Changes:
- Removed flag constant from feature-flags.go
- Updated scan.go to always check file size (no flag check)
- Consolidated 5 tests to 3 tests (removed redundant flag-based tests)
- Behavior unchanged: multipart for >5GB, single for <=5GB

No regression - functionality preserved, code simplified.

* removed status code handling

* updated docker image

---------

Co-authored-by: Anurag Dalke <120229307+cx-anurag-dalke@users.noreply.github.com>

* Undo merge conflict resolution commit

This removes the problematic merge commit a1df4b1 that resolved
the Dockerfile conflict. Going back to the clean state before
that merge attempt.

All code is preserved - reverting to e3250aa state.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

* Ignore glibc CVE-2026-84243 and Go stdlib CVE-2026-97054 in Trivy

Both are newly disclosed. glibc comes from the checkmarx/bash base image
(fix in 2.44-r16, no rebuilt image yet); stdlib is fixed in Go 1.26.11.
Remove once the base image is rebuilt and the Go toolchain is bumped.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Rahul Pidde <206018639+cx-rahul-pidde@users.noreply.github.com>
Co-authored-by: Anurag Dalke <anurag.dalke@checkmarx.com>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: atishj99 <atish.jadhav@checkmarx.com>
Co-authored-by: Aniket Shinde <aniket.shinde@checkmarx.com>
Co-authored-by: Anurag Dalke <120229307+cx-anurag-dalke@users.noreply.github.com>
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