Skip to content

fix(engine): allow excluding OpenAPI queries by their override (version-specific) IDs#7977

Open
cx-ori-bendet wants to merge 1 commit intomasterfrom
fix/openapi-override-query-exclusion
Open

fix(engine): allow excluding OpenAPI queries by their override (version-specific) IDs#7977
cx-ori-bendet wants to merge 1 commit intomasterfrom
fix/openapi-override-query-exclusion

Conversation

@cx-ori-bendet
Copy link
Contributor

Summary

  • OpenAPI queries have version-specific variants defined via an "override" field in metadata.json (e.g. a Swagger 2.0 variant with a different ID than the OpenAPI 3.0 primary query)
  • These variant IDs are what get reported in scan results when scanning a Swagger 2.0 file, but checkQueryExclude only compared against the top-level metadata["id"]
  • Passing an override ID to --exclude-queries had no effect, making it impossible to suppress findings for those queries
  • Fix: extend checkQueryExclude to also iterate through metadata["override"] and check each version variant's "id" against the ByIDs exclusion list

Example — for a query with this metadata:

{
  "id": "e3f026e8-fdb4-4d5a-bcfd-bd94452073fe",
  "override": {
    "2.0": { "id": "6e96ed39-bf45-4089-99ba-f1fe7cf6966f" }
  }
}

Both e3f026e8-... and 6e96ed39-... can now be used with --exclude-queries.

Fixes #7574

Test plan

  • Scan a swagger.json file that triggers one of the affected queries (e.g. 6e96ed39-bf45-4089-99ba-f1fe7cf6966f)
  • Run with --exclude-queries 6e96ed39-bf45-4089-99ba-f1fe7cf6966f and verify the query is excluded from results
  • Run with the primary ID e3f026e8-fdb4-4d5a-bcfd-bd94452073fe — should still be excluded (existing behaviour preserved)
  • Run go test ./pkg/engine/source/... to verify existing tests pass

I submit this contribution under the Apache-2.0 license.

🤖 Generated with Claude Code

…on-specific) IDs

OpenAPI queries define version-specific variants via an "override" field in
metadata.json (e.g. a Swagger 2.0 variant of an OpenAPI 3.0 query). These
variants have their own IDs which are reported in scan results, but
checkQueryExclude only checked the primary metadata "id", so passing an
override ID to --exclude-queries had no effect.

Extend checkQueryExclude to also iterate the "override" map and check each
variant's "id" against the ByIDs exclusion list.

Fixes #7574

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cx-ori-bendet cx-ori-bendet requested a review from a team as a code owner February 28, 2026 22:59
@github-actions github-actions bot added community Community contribution query New query feature openapi OpenAPI query labels Feb 28, 2026
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.18

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

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

Labels

community Community contribution openapi OpenAPI query query New query feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(query): some openapi queries cannot be excluded from the report

1 participant