Skip to content

docs: add testing guide and ADK governance adapter#312

Closed
imran-siddique wants to merge 1 commit intomicrosoft:mainfrom
imran-siddique:main
Closed

docs: add testing guide and ADK governance adapter#312
imran-siddique wants to merge 1 commit intomicrosoft:mainfrom
imran-siddique:main

Conversation

@imran-siddique
Copy link
Member

  • docs/TESTING_GUIDE.md: Step-by-step guide for external testers (4 paths: demo, own agent, SQL policy, full suite)
  • adk-agentmesh: Google ADK governance adapter with PolicyEvaluator (33 tests)
  • examples/policies/adk-governance.yaml: Sample ADK policy config

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions bot added size/L Large PR (< 500 lines) documentation Improvements or additions to documentation labels Mar 20, 2026
@github-actions
Copy link

🤖 AI Agent: breaking-change-detector

🔍 API Compatibility Report

Summary

This pull request introduces documentation updates and examples for testing and integrating the Agent Governance Toolkit. It does not modify any existing code or APIs, nor does it introduce changes to the public API. The changes are entirely additive and focus on providing guidance and examples for users.

Findings

Severity Package Change Impact
N/A No changes to public APIs No impact on API compatibility

Migration Guide

No migration steps are required as this pull request does not introduce any breaking or potentially breaking changes.


No breaking changes detected.

@github-actions
Copy link

🤖 AI Agent: docs-sync-checker

📝 Documentation Sync Report

Issues Found

  • ⚠️ docs/TESTING_GUIDE.md — New documentation added, but no reference to it in the project-level README.md or other relevant documentation. Consider linking to this guide for discoverability.
  • ⚠️ examples/policies/adk-governance.yaml — New example policy added, but no mention of it in the package-level README.md or examples/ documentation.
  • ⚠️ CHANGELOG.md — No entry for the addition of the new testing guide or the ADK governance adapter.

Suggestions

  • 💡 Add a section in the project-level README.md to reference the new docs/TESTING_GUIDE.md and explain its purpose.
  • 💡 Update the packages/agent-mesh/README.md to include a reference to the new examples/policies/adk-governance.yaml file and explain its use case.
  • 💡 Add an entry to CHANGELOG.md under a new version header (e.g., ## [Unreleased]) to document the addition of the testing guide and the ADK governance adapter.

Additional Notes

  • The new docs/TESTING_GUIDE.md is comprehensive and well-written, providing clear instructions for users. No issues were found with its content.
  • The new examples/policies/adk-governance.yaml file appears to be a sample policy configuration, but its purpose and usage are not documented in the README.md or elsewhere in the repository.
  • No new public APIs were introduced in this PR, so no issues with missing docstrings or type hints.
  • Example code in examples/ appears to be up-to-date and relevant to the changes introduced in this PR.

Action Required

Please address the issues and suggestions above to ensure documentation remains in sync with the repository changes.

@github-actions
Copy link

🤖 AI Agent: security-scanner

Security Review of Changes

The pull request introduces a new testing guide and an ADK governance adapter. While the changes are primarily documentation and testing-related, they still require a security review to ensure no vulnerabilities or misconfigurations are introduced. Below is the analysis based on the provided diff:


1. Prompt Injection Defense Bypass

  • Risk: The testing guide includes a demo (maf_governance_demo.py) that simulates adversarial attacks, including prompt injection. However, the guide does not explicitly state whether the toolkit's defenses against prompt injection are robust or how they are implemented.
  • Rating: 🟡 MEDIUM
  • Attack Vector: If the prompt injection defenses are not robust, a malicious user could craft inputs to bypass policy guards and execute unauthorized actions.
  • Recommendation: Ensure that the demo includes comprehensive tests for all known prompt injection techniques, such as instruction reversal, token smuggling, and nested injections. Document the expected behavior for each scenario and verify that the toolkit handles them correctly.

2. Policy Engine Circumvention

  • Risk: The guide describes how to load and test policies but does not explicitly address the possibility of policy tampering or circumvention.
  • Rating: 🟠 HIGH
  • Attack Vector: If an attacker can modify the policy file (my-policy.yaml or other YAML files) or bypass the policy engine, they could execute unauthorized actions.
  • Recommendation: Ensure that the toolkit validates the integrity of the policy files (e.g., using cryptographic signatures) before loading them. Additionally, document how the toolkit prevents runtime policy circumvention.

3. Trust Chain Weaknesses

  • Risk: The architecture summary mentions an "Identity Check (Ed25519 DID)" step, but there is no mention of how this is tested or validated in the guide.
  • Rating: 🟡 MEDIUM
  • Attack Vector: If the trust chain validation (e.g., SPIFFE/SVID or certificate pinning) is not robust, an attacker could impersonate a trusted agent or service.
  • Recommendation: Include specific tests in the guide to validate the integrity of the trust chain, such as testing for certificate spoofing or invalid DID signatures.

4. Credential Exposure

  • Risk: The guide instructs users to set API keys as environment variables but does not mention secure practices for managing these keys.
  • Rating: 🟡 MEDIUM
  • Attack Vector: If API keys are exposed in logs, error messages, or version control, they could be exploited by attackers to gain unauthorized access to LLM services.
  • Recommendation: Update the guide to include best practices for managing secrets, such as using a secrets manager or environment variable management tools. Warn users against hardcoding secrets in scripts or committing them to version control.

5. Sandbox Escape

  • Risk: The guide mentions "Capability Sandboxing" but does not provide details on how the sandboxing is implemented or tested.
  • Rating: 🟠 HIGH
  • Attack Vector: If the sandboxing mechanism is not robust, an attacker could exploit vulnerabilities to escape the sandbox and execute arbitrary code on the host system.
  • Recommendation: Include details in the guide about how the sandboxing is implemented and tested. Add tests to verify that the sandbox cannot be escaped using common techniques (e.g., directory traversal, symbolic links, or process injection).

6. Deserialization Attacks

  • Risk: The guide includes YAML configuration files but does not mention whether the YAML parsing is safe from deserialization attacks.
  • Rating: 🔴 CRITICAL
  • Attack Vector: If the YAML files are parsed using an unsafe method (e.g., yaml.load() instead of yaml.safe_load()), an attacker could inject malicious code into the YAML file and execute it during parsing.
  • Recommendation: Ensure that all YAML files are parsed using yaml.safe_load() instead of yaml.load(). Update the guide to explicitly mention this and provide examples of safe YAML parsing.

7. Race Conditions

  • Risk: The guide does not mention whether the policy engine or trust evaluation mechanisms are thread-safe.
  • Rating: 🟡 MEDIUM
  • Attack Vector: If the policy engine is not thread-safe, an attacker could exploit race conditions to bypass policy checks or manipulate trust evaluations.
  • Recommendation: Include tests for concurrent policy evaluations and trust checks to ensure thread safety. Document any limitations or precautions related to concurrency.

8. Supply Chain Risks

  • Risk: The guide includes installation instructions that use pip install, but it does not address the risk of dependency confusion or typosquatting.
  • Rating: 🟠 HIGH
  • Attack Vector: An attacker could publish a malicious package with a similar name to one of the dependencies (e.g., pyyaml or cryptography) and trick users into installing it.
  • Recommendation: Update the guide to recommend using a requirements.txt file with pinned versions or a lockfile to ensure that only trusted versions of dependencies are installed. Additionally, recommend using tools like pip-audit to check for vulnerabilities in dependencies.

Additional Observations

  • The guide is well-structured and provides clear instructions for testing the toolkit. However, it lacks explicit details on how the toolkit defends against specific attack vectors, such as prompt injection, policy tampering, and sandbox escapes.
  • The guide mentions "tamper-proof" audit logs but does not explain how this is achieved or tested. This could be a potential area for further scrutiny.

Summary of Findings

Finding Rating Recommendation
Prompt injection defense bypass 🟡 MEDIUM Add comprehensive tests for known prompt injection techniques.
Policy engine circumvention 🟠 HIGH Validate policy file integrity and document runtime policy circumvention defenses.
Trust chain weaknesses 🟡 MEDIUM Add tests for trust chain validation and document the process.
Credential exposure 🟡 MEDIUM Include best practices for managing secrets in the guide.
Sandbox escape 🟠 HIGH Document sandboxing implementation and add tests for common escape techniques.
Deserialization attacks 🔴 CRITICAL Use yaml.safe_load() for YAML parsing and update the guide to reflect this.
Race conditions 🟡 MEDIUM Test for thread safety in policy evaluations and trust checks.
Supply chain risks 🟠 HIGH Use pinned dependencies and recommend tools like pip-audit.

Overall Assessment

The changes in this pull request are primarily documentation and testing-related, but they expose potential security risks that need to be addressed. The most critical issue is the potential for deserialization attacks due to unsafe YAML parsing. Additionally, there are high-priority concerns around policy engine circumvention, sandbox escapes, and supply chain risks. These issues should be addressed before merging the pull request to ensure the security of the toolkit and its downstream users.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review of Pull Request: docs: add testing guide and ADK governance adapter


🔴 CRITICAL

  1. Potential Policy Bypass in Adversarial Testing:

    • The demo/maf_governance_demo.py --include-attacks script mentions testing adversarial attacks like "prompt injection," "tool alias bypass," and "SQL injection." However, the documentation does not explicitly confirm that all attacks are successfully blocked. This leaves ambiguity about whether the toolkit is resilient to these attacks.
    • Action: Ensure that all adversarial scenarios are explicitly tested and documented with expected results. If any attacks are not blocked, this must be addressed immediately.
  2. Lack of Cryptographic Key Validation:

    • The documentation mentions Ed25519 DID generation for trust identity but does not specify whether the cryptographic keys are validated or rotated securely. Improper key handling could lead to impersonation or trust issues.
    • Action: Verify that the AgentIdentity module securely generates, validates, and rotates Ed25519 keys. Add tests to confirm key integrity and resistance to tampering.
  3. Sandbox Escape Vectors:

    • The execute_shell and run_command actions are explicitly blocked in the example policy, but the documentation does not confirm whether sandboxing mechanisms prevent indirect execution (e.g., via aliasing or chained commands).
    • Action: Test for sandbox escape vectors, such as calling blocked actions through indirect means (e.g., using os.system or subprocess modules). Ensure these are documented and mitigated.

🟡 WARNING

  1. Backward Compatibility Risk:

    • The DeprecationWarning: create_default_policies() in the "Common Issues" section indicates a breaking change in the API. While the warning suggests using create_policies_from_config() instead, this could break existing integrations.
    • Action: Provide a clear migration guide for users relying on create_default_policies(). Consider maintaining backward compatibility or issuing a major version bump.
  2. Policy File Format Changes:

    • The example policy file (my-policy.yaml) introduces a new format. If this format differs from previous versions, it could break existing configurations.
    • Action: Confirm backward compatibility with older policy file formats. If incompatible, document the changes and provide a migration tool or script.

💡 SUGGESTIONS

  1. Expand Adversarial Testing:

    • The adversarial testing scenarios are a great addition, but they could be expanded to include:
      • Credential leakage: Ensure sensitive data like API keys are not exposed in logs or error messages.
      • Policy tampering: Test whether policies can be modified at runtime by unauthorized agents.
      • Replay attacks: Ensure that previously allowed actions cannot be replayed in unauthorized contexts.
    • Action: Add these scenarios to the adversarial testing suite and document the results.
  2. Thread Safety in Concurrent Execution:

    • The documentation does not address thread safety when multiple agents execute actions concurrently. This is critical for environments with high concurrency.
    • Action: Add a section in the documentation about thread safety and test the toolkit under concurrent execution scenarios to ensure no race conditions or deadlocks occur.
  3. Type Safety and Pydantic Validation:

    • The examples do not explicitly demonstrate the use of Pydantic models for policy validation. This could lead to runtime errors if policies are malformed.
    • Action: Include examples of Pydantic validation for policy files in the documentation. Ensure that all policy configurations are validated before execution.
  4. Audit Log Tamper-Proofing:

    • The documentation mentions a "tamper-proof" audit log but does not explain how this is achieved (e.g., cryptographic signing, hashing).
    • Action: Elaborate on the tamper-proofing mechanism in the documentation. If not implemented, consider adding cryptographic integrity checks to the audit log.
  5. SQL Policy Customization:

    • The SQL policy examples are useful but could benefit from more customization options, such as:
      • Allowing specific users or roles to bypass certain restrictions.
      • Defining time-based policies (e.g., stricter rules during off-hours).
    • Action: Expand the SQL policy examples to include these advanced use cases.
  6. Documentation Usability:

    • The TESTING_GUIDE.md is comprehensive but lengthy. Consider breaking it into smaller, focused guides (e.g., "Quickstart," "Adversarial Testing," "SQL Policies").
    • Action: Split the guide into modular sections and provide a table of contents with links for easier navigation.

Summary of Actions

  • 🔴 Address critical issues:

    • Ensure all adversarial attacks are blocked and documented.
    • Verify secure handling of Ed25519 keys.
    • Test and mitigate sandbox escape vectors.
  • 🟡 Mitigate backward compatibility risks:

    • Provide migration guides for deprecated APIs and policy format changes.
  • 💡 Implement suggested improvements:

    • Expand adversarial testing scenarios.
    • Test thread safety in concurrent execution.
    • Add Pydantic validation examples.
    • Elaborate on audit log tamper-proofing.
    • Enhance SQL policy customization.
    • Improve documentation usability.

This PR introduces valuable documentation and testing resources but requires addressing critical security and compatibility concerns before merging.

@github-actions
Copy link

🤖 AI Agent: security-scanner

Security Analysis of the Pull Request

This pull request primarily introduces a testing guide and a new governance adapter for Google ADK. While the changes are largely documentation and example code, there are still potential security implications that need to be reviewed carefully, especially given the critical nature of this repository.


Findings

1. Prompt Injection Defense Bypass

  • Severity: 🔵 LOW
  • Analysis: The testing guide mentions a demo scenario for "Content Filtering" where the toolkit blocks dangerous prompts before they reach the LLM. However, the guide does not provide details about the robustness of the filtering mechanism or how it handles advanced prompt injection attacks. While this is not a direct issue with the PR, the lack of clarity in the documentation could lead to testers overlooking potential weaknesses in the filtering logic.
  • Recommendation: Add a section in the testing guide that explains how the content filtering mechanism works, including specific examples of prompt injection attacks it can handle. Encourage testers to create additional adversarial test cases to validate the robustness of the filtering.

2. Policy Engine Circumvention

  • Severity: 🟠 HIGH
  • Analysis: The example policy in my-policy.yaml includes a deny rule with patterns like "delete_.*". However, this approach is vulnerable to bypasses if the agent uses alternative spellings, encodings, or aliases for restricted actions. For example, an agent could use del_ete or remove_file to bypass the delete_.* pattern.
  • Recommendation: Update the documentation to warn users about the limitations of pattern-based rules and recommend using more robust mechanisms, such as explicit action enumeration or semantic analysis, to prevent circumvention.

3. Trust Chain Weaknesses

  • Severity: 🔵 LOW
  • Analysis: The architecture summary mentions "Identity Check (Ed25519 DID)" as part of the governance process. However, the documentation does not explain how the identity verification process works or how it ensures the integrity of the trust chain. This omission could lead to testers overlooking potential weaknesses in the implementation.
  • Recommendation: Add a section to the testing guide that explains the trust chain validation process, including how Ed25519 DIDs are generated, verified, and protected against tampering.

4. Credential Exposure

  • Severity: 🟠 HIGH
  • Analysis: The testing guide instructs users to set API keys (e.g., OPENAI_API_KEY, AZURE_OPENAI_API_KEY, GOOGLE_API_KEY) as environment variables. While this is a common practice, it is not secure if these keys are logged or exposed in error messages. Additionally, the guide does not mention any precautions for handling these sensitive credentials.
  • Recommendation: Update the documentation to include a warning about the risks of exposing API keys in logs or error messages. Recommend using secure methods for managing secrets, such as environment variable managers (e.g., dotenv) or secret management tools (e.g., Azure Key Vault, AWS Secrets Manager).

5. Sandbox Escape

  • Severity: 🔵 LOW
  • Analysis: The documentation mentions "Capability Sandboxing" as a feature of the governance toolkit but does not provide details on how the sandboxing is implemented or tested. Without this information, it is difficult to assess the robustness of the sandbox against potential escape attempts.
  • Recommendation: Include a detailed explanation of the sandboxing mechanism in the documentation, along with examples of how testers can validate its effectiveness against common escape techniques (e.g., file system access, network access).

6. Deserialization Attacks

  • Severity: 🟠 HIGH
  • Analysis: The testing guide includes examples of loading YAML policy files (e.g., my-policy.yaml, sql-strict.yaml) without mentioning whether the YAML parsing is done securely. If the YAML parser used (e.g., pyyaml) is not configured to use safe loading methods, this could lead to deserialization attacks.
  • Recommendation: Ensure that all YAML parsing in the codebase uses safe loading methods (e.g., yaml.safe_load() instead of yaml.load()). Update the documentation to explicitly mention this and encourage testers to verify the use of secure parsing methods.

7. Race Conditions

  • Severity: 🔵 LOW
  • Analysis: The documentation does not mention any specific mechanisms for handling potential race conditions in policy checks or trust evaluations. While this is not directly related to the changes in the PR, it is worth noting as a potential area for improvement.
  • Recommendation: Add a note in the testing guide to encourage testers to evaluate the system's behavior under concurrent requests, particularly for policy evaluation and trust verification.

8. Supply Chain Risks

  • Severity: 🟠 HIGH
  • Analysis: The testing guide instructs users to install dependencies using pip install commands, including httpx and pyyaml. However, there is no mention of verifying the integrity of these dependencies to prevent supply chain attacks (e.g., dependency confusion or typosquatting).
  • Recommendation: Update the documentation to recommend using tools like pip-audit or safety to check for vulnerabilities in dependencies. Additionally, consider pinning dependency versions in requirements.txt or setup.py to reduce the risk of supply chain attacks.

Summary of Findings

Finding Severity Recommendation
Prompt injection defense bypass 🔵 LOW Add details about content filtering and encourage adversarial testing.
Policy engine circumvention 🟠 HIGH Warn about pattern-based rule limitations and recommend robust alternatives.
Trust chain weaknesses 🔵 LOW Document the trust chain validation process.
Credential exposure 🟠 HIGH Warn about API key handling and recommend secure secret management practices.
Sandbox escape 🔵 LOW Document sandboxing mechanisms and suggest testing against escape techniques.
Deserialization attacks 🟠 HIGH Ensure YAML parsing uses safe_load() and document this in the guide.
Race conditions 🔵 LOW Encourage testing for concurrent policy evaluation and trust verification.
Supply chain risks 🟠 HIGH Recommend dependency auditing tools and pinning versions in requirements.txt.

Overall Assessment

While the changes in this PR are primarily documentation and examples, there are several areas where additional clarity and security considerations are needed. Addressing these issues will help ensure that the toolkit remains robust and secure, even when used by external testers.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Agent: code-reviewer

Review Summary

This pull request introduces a comprehensive Testing Guide for the Agent Governance Toolkit and adds a new ADK governance adapter under adk-agentmesh. The documentation is well-structured and provides clear, step-by-step instructions for various testing paths. However, there are a few areas that require attention, particularly regarding security, backward compatibility, and clarity.


🔴 CRITICAL

  1. Adversarial Attacks in Demo:

    • The demo includes adversarial attack scenarios (e.g., prompt injection, SQL injection). While this is a great feature, there is no mention of how these attacks are detected or mitigated in the code. If these scenarios are not fully blocked or logged, it could lead to a false sense of security.
    • Action: Ensure that the demo explicitly logs the detection and mitigation of each attack. Add a note in the documentation about how these attacks are handled and what the expected behavior is.
  2. Policy Bypass Risks:

    • The examples/policies/adk-governance.yaml file is not included in the diff, so it is unclear if the sample policy is secure by default. Misconfigured policies could lead to security bypasses.
    • Action: Verify that the sample policy enforces strict security measures (e.g., deny dangerous actions by default). Add a note in the documentation about reviewing and customizing policies before deployment.
  3. Identity and Trust:

    • The documentation mentions "Ed25519 DID" for identity checks but does not explain how the keys are generated, stored, or rotated. Improper handling of cryptographic keys could lead to impersonation or unauthorized access.
    • Action: Document the key management process (e.g., where keys are stored, how they are secured, and how they can be rotated). Ensure that the AgentIdentity implementation is robust and tamper-proof.

🟡 WARNING

  1. Backward Compatibility:

    • The new adk-agentmesh adapter introduces a PolicyEvaluator with 33 tests. If this adapter modifies existing APIs or behaviors, it could break backward compatibility for users relying on previous versions.
    • Action: Confirm that the new adapter does not introduce breaking changes. If it does, document these changes clearly in the release notes.
  2. Deprecation Warning:

    • The guide mentions a DeprecationWarning for create_default_policies(). While this is noted as "expected," it could confuse users.
    • Action: Clearly document the migration path from create_default_policies() to create_policies_from_config() in the release notes and deprecation warnings.

💡 SUGGESTIONS

  1. Thread Safety:

    • The StatelessKernel and ExecutionContext are used in examples, but there is no mention of thread safety. If these components are used in multi-threaded environments, race conditions could occur.
    • Suggestion: Add a note in the documentation about whether the toolkit is thread-safe. If not, provide guidance on how to use it safely in concurrent environments.
  2. Type Safety:

    • The examples do not use type hints for function arguments or return types. This could lead to runtime errors in user code.
    • Suggestion: Add type hints to all examples in the documentation to promote type safety and align with Python best practices.
  3. Audit Logging:

    • The guide mentions that all governance decisions are logged, but it does not specify the format or location of the logs.
    • Suggestion: Include an example of the audit log output in the documentation. Specify where the logs are stored and how they can be accessed.
  4. Testing Coverage:

    • The guide mentions running 6,100+ tests but does not specify the coverage metrics (e.g., percentage of code covered, critical paths tested).
    • Suggestion: Add a section in the guide or repository README summarizing the test coverage and highlighting any known gaps.
  5. Error Handling:

    • The guide lists common issues but does not provide troubleshooting steps for more complex errors (e.g., policy parsing failures, runtime exceptions).
    • Suggestion: Expand the "Common Issues" section to include detailed troubleshooting steps for less common but critical errors.
  6. Policy Examples:

    • The guide references multiple policy files (e.g., sql-strict.yaml, sql-safety.yaml, sql-readonly.yaml) but does not provide their contents.
    • Suggestion: Include the full contents of these policy files in the documentation or link to their location in the repository.

Final Recommendation

  • Merge Readiness: The PR is well-written and provides valuable documentation and functionality. However, the critical issues related to security and backward compatibility must be addressed before merging.
  • Next Steps:
    1. Address the critical issues related to adversarial attacks, policy security, and identity management.
    2. Confirm backward compatibility and document any breaking changes.
    3. Consider implementing the suggested improvements for enhanced clarity and usability.

Let me know if you need further clarification or assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/L Large PR (< 500 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant