Skip to content

Add comprehensive unit tests for agenthooks guardrails (AST-165778) - #1537

Open
cx-atish-jadhav wants to merge 2 commits into
mainfrom
other/unit-test
Open

Add comprehensive unit tests for agenthooks guardrails (AST-165778)#1537
cx-atish-jadhav wants to merge 2 commits into
mainfrom
other/unit-test

Conversation

@cx-atish-jadhav

Copy link
Copy Markdown
Contributor

Add extensive unit tests and test helpers for agenthooks guardrails. hooks_test.go: introduce sampleJWT, recordingTelemetry, and helpers (resetHookGlobals, setHomeDir, writePolicy, currentOS); add tests for session IDs, tool-call rules (blacklist, tool rules, SCA), file-edit rules (secrets, blast radius, total size, KICS, SCA manifest), fullAfterContent/newline normalization, prompt handling, RegisterGuardrails/RegisterPassThrough, telemetry logging, and agent string mapping. guardrails/asca_test.go: add tests for ASCA-supported extensions, highestSeverity, existing ignore file path, shouldUpdateVersion flag, ASCA telemetry, and ScanFileEdit early-return cases. No production code changed.

By submitting this pull request, you agree to the terms within the Checkmarx Code of Conduct. Please review the contributing guidelines for guidance on creating high-quality pull requests.

Description

Please provide a summary of the changes and the related issue. Include relevant motivation and context.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Related Issues

Link any related issues or tickets.

Checklist

  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules
  • I have updated the CLI help for new/changed functionality in this PR (if applicable)
  • All active GitHub checks for tests, formatting, and security are passing
  • The correct base branch is being used

Screenshots (if applicable)

Add screenshots to help explain your changes.

Additional Notes

Add any other relevant information.

Add extensive unit tests and test helpers for agenthooks guardrails. hooks_test.go: introduce sampleJWT, recordingTelemetry, and helpers (resetHookGlobals, setHomeDir, writePolicy, currentOS); add tests for session IDs, tool-call rules (blacklist, tool rules, SCA), file-edit rules (secrets, blast radius, total size, KICS, SCA manifest), fullAfterContent/newline normalization, prompt handling, RegisterGuardrails/RegisterPassThrough, telemetry logging, and agent string mapping. guardrails/asca_test.go: add tests for ASCA-supported extensions, highestSeverity, existing ignore file path, shouldUpdateVersion flag, ASCA telemetry, and ScanFileEdit early-return cases. No production code changed.
@cx-atish-jadhav cx-atish-jadhav changed the title Add comprehensive unit tests for agenthooks guardrails Add comprehensive unit tests for agenthooks guardrails (AST-165778) Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants