-
Notifications
You must be signed in to change notification settings - Fork 0
ROX-31495: wiremock for central #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
janisz
wants to merge
22
commits into
main
Choose a base branch
from
ROX-31495-wiremock-mock-service
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5fbca6c
ROX-31495: Add WireMock standalone mock service for StackRox Central
janisz cef9fbf
Simplify smoke test to focus on functionality
janisz 07bf2c0
chore: cleanup WireMock code and documentation
janisz a157c6b
feat: Use go mod cache for proto files instead of manual repo clone
janisz cf2af0c
feat: Add E2E test infrastructure with mock/real service support
janisz 15497ef
fix: Configure E2E tests to work with WireMock mock service
janisz 01f58ab
fix: Fix WireMock JSONPath patterns for gRPC protobuf field names
janisz ad34e28
fix: Fix WireMock smoke test failures and add grpcurl dependency
janisz a878c6f
Delete IMPLEMENTATION_SUMMARY.md
janisz 56d0a4a
Change contains prompt
janisz 924e044
Apply suggestion from @mtodor
janisz 2e28dd4
Apply suggestion from @mtodor
janisz c7559c8
fixes
janisz 488768d
Address PR review comments from @mtodor
janisz 5cf7602
Clean up unused WireMock files and compact README
janisz 74fc864
fix: Fix WireMock JSONPath patterns for deployment CVE queries
janisz 4e23fe9
feat: Add automatic protoc installation to Makefile
janisz 7763733
refactor: Simplify e2e tests to only support WireMock mode
janisz 84bb4ab
Merge branch 'main' into ROX-31495-wiremock-mock-service
janisz 3ba6aaf
Update .github/workflows/wiremock-test.yml
janisz 483ee9e
fix: Fix WireMock smoke test in GitHub Actions
janisz f5bb3b0
fix: Correct JSON payload in smoke test to match protobuf structure
janisz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| name: WireMock Smoke Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| types: | ||
| - opened | ||
| - reopened | ||
| - synchronize | ||
|
|
||
| jobs: | ||
| wiremock-smoke-test: | ||
| name: WireMock Smoke Test | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
|
|
||
| - name: Set up Java | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'temurin' | ||
| java-version: '11' | ||
|
|
||
| - name: Download Go dependencies | ||
| run: go mod download | ||
|
|
||
| - name: Install protoc | ||
| run: make proto-install | ||
|
|
||
| - name: Setup proto files from go mod cache | ||
| run: ./scripts/setup-proto-files.sh | ||
|
|
||
| - name: Run smoke test | ||
| run: make mock-test | ||
|
|
||
| - name: Upload logs on failure | ||
| if: failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: wiremock-logs | ||
| path: wiremock/wiremock.log | ||
| if-no-files-found: ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,6 @@ This is useful for CI and quickly checking that everything compiles. | |
| - Go 1.25+ | ||
| - Google Cloud Project with Vertex AI enabled (for Claude agent) | ||
| - OpenAI API Key (for LLM judge) | ||
| - StackRox API Token | ||
|
|
||
| ## Setup | ||
|
|
||
|
|
@@ -39,9 +38,6 @@ Create `.env` file: | |
| # Required: GCP Project for Vertex AI (Claude agent) | ||
| ANTHROPIC_VERTEX_PROJECT_ID=<GCP Project ID> | ||
|
|
||
| # Required: StackRox Central API Token | ||
| STACKROX_MCP__CENTRAL__API_TOKEN=<StackRox API Token> | ||
|
|
||
| # Required: OpenAI API Key (for LLM judge) | ||
| OPENAI_API_KEY=<OpenAI API Key> | ||
|
|
||
|
|
@@ -52,12 +48,22 @@ CLOUD_ML_REGION=us-east5 | |
| JUDGE_MODEL_NAME=gpt-5-nano | ||
| ``` | ||
|
|
||
| Note: No StackRox API token required - tests use WireMock mock service. | ||
|
|
||
| ## Running Tests | ||
|
|
||
| Run tests against the WireMock mock service: | ||
|
|
||
| ```bash | ||
| ./scripts/run-tests.sh | ||
| ``` | ||
|
|
||
| The test suite: | ||
| - Starts WireMock automatically on localhost:8081 | ||
| - Uses deterministic test fixtures | ||
| - Requires no StackRox API tokens | ||
| - Fast and reliable for development and CI | ||
|
|
||
| Results are saved to `mcpchecker/mcpchecker-stackrox-mcp-e2e-out.json`. | ||
|
|
||
| ### View Results | ||
|
|
@@ -72,21 +78,24 @@ jq '[.[] | .callHistory.ToolCalls[]? | {name: .request.Params.name, arguments: . | |
|
|
||
| ## Test Cases | ||
|
|
||
| | Test | Description | Tool | | ||
| |------|-------------|------| | ||
| | `list-clusters` | List all clusters | `list_clusters` | | ||
| | `cve-detected-workloads` | CVE detected in deployments | `get_deployments_for_cve` | | ||
| | `cve-detected-clusters` | CVE detected in clusters | `get_clusters_with_orchestrator_cve` | | ||
| | `cve-nonexistent` | Handle non-existent CVE | `get_clusters_with_orchestrator_cve` | | ||
| | `cve-cluster-does-exist` | CVE with cluster filter | `get_clusters_with_orchestrator_cve` | | ||
| | `cve-cluster-does-not-exist` | CVE with cluster filter | `get_clusters_with_orchestrator_cve` | | ||
| | `cve-clusters-general` | General CVE query | `get_clusters_with_orchestrator_cve` | | ||
| | `cve-cluster-list` | CVE across clusters | `get_clusters_with_orchestrator_cve` | | ||
| | Test | Description | Tool | Eval Coverage | | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: I'm not sure if |
||
| |------|-------------|------|---------------| | ||
| | `list-clusters` | List all clusters | `list_clusters` | - | | ||
| | `cve-detected-workloads` | CVE detected in deployments | `get_deployments_for_cve` | Eval 1 | | ||
| | `cve-detected-clusters` | CVE detected in clusters | `get_clusters_with_orchestrator_cve` | Eval 1 | | ||
| | `cve-nonexistent` | Handle non-existent CVE | `get_clusters_with_orchestrator_cve` | Eval 2 | | ||
| | `cve-cluster-does-exist` | CVE with cluster filter | `get_clusters_with_orchestrator_cve` | Eval 4 | | ||
| | `cve-cluster-does-not-exist` | CVE with non-existent cluster | `list_clusters` | - | | ||
| | `cve-clusters-general` | General CVE query | `get_clusters_with_orchestrator_cve` | Eval 1 | | ||
| | `cve-cluster-list` | CVE across clusters | `get_clusters_with_orchestrator_cve` | - | | ||
| | `cve-log4shell` | Well-known CVE (log4shell) | `get_deployments_for_cve` | Eval 3 | | ||
| | `cve-multiple` | Multiple CVEs in one prompt | `get_deployments_for_cve` | Eval 5 | | ||
| | `rhsa-not-supported` | RHSA detection (should fail) | None | Eval 7 | | ||
|
|
||
| ## Configuration | ||
|
|
||
| - **`mcpchecker/eval.yaml`**: Main test configuration, agent settings, assertions | ||
| - **`mcpchecker/mcp-config.yaml`**: MCP server configuration | ||
| - **`mcpchecker/eval.yaml`**: Test configuration, agent settings, assertions | ||
| - **`mcpchecker/mcp-config-mock.yaml`**: MCP server configuration for WireMock | ||
| - **`mcpchecker/tasks/*.yaml`**: Individual test task definitions | ||
|
|
||
| ## How It Works | ||
|
|
@@ -103,8 +112,8 @@ mcpchecker uses a proxy architecture to intercept MCP tool calls: | |
| ## Troubleshooting | ||
|
|
||
| **Tests fail - no tools called** | ||
| - Verify StackRox Central is accessible | ||
| - Check API token permissions | ||
| - Verify WireMock is running: `make mock-status` | ||
| - Check WireMock logs: `make mock-logs` | ||
|
|
||
| **Build errors** | ||
| ```bash | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| mcpServers: | ||
| stackrox-mcp: | ||
| command: go | ||
| args: | ||
| - run | ||
| - ../../cmd/stackrox-mcp/... | ||
| - --config | ||
| - ../stackrox-mcp-e2e-config.yaml | ||
| # Explicit environment overrides for mock mode | ||
| # mcpchecker doesn't support proper environment inheritance, | ||
| # so we need to explicitly set all required variables here | ||
| env: | ||
| STACKROX_MCP__CENTRAL__URL: "localhost:8081" | ||
| STACKROX_MCP__CENTRAL__API_TOKEN: "test-token-admin" | ||
| STACKROX_MCP__CENTRAL__INSECURE_SKIP_TLS_VERIFY: "true" | ||
| STACKROX_MCP__CENTRAL__AUTH_TYPE: "static" | ||
| STACKROX_MCP__SERVER__TYPE: "stdio" | ||
| STACKROX_MCP__TOOLS__VULNERABILITY__ENABLED: "true" | ||
| STACKROX_MCP__TOOLS__CONFIG_MANAGER__ENABLED: "true" | ||
| # Auto-approve all tools | ||
| enableAllTools: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| kind: Task | ||
| metadata: | ||
| name: "cve-log4shell" | ||
| difficulty: easy | ||
| steps: | ||
| prompt: | ||
| inline: "Is log4shell CVE detected in my cluster fleet?" | ||
| verify: | ||
| contains: The commonly used name "log4shell" is resolved into the exact CVE number (CVE-2021-44228). And it's detected in a few deployments. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| kind: Task | ||
| metadata: | ||
| name: "cve-multiple" | ||
| difficulty: medium | ||
| steps: | ||
| prompt: | ||
| inline: "Are CVE-2021-31805 and CVE-2016-1000031 detected in my cluster fleet?" | ||
| verify: | ||
| contains: "Both CVEs (CVE-2021-31805 and CVE-2016-1000031), along with the cluster names, deployments, and namespaces where they are detected." |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test this directly, but I have used
rm -rfmanually and I'm facing some issues:And that always causes
jj"checkout" problems. 😞