Skip to content

fix: default STATIC scan categories; fix target init scaffold schema - #298

Merged
cdot65 merged 3 commits into
cdot65:mainfrom
thresh97:fix/scan-categories-and-target-scaffold
Aug 5, 2026
Merged

fix: default STATIC scan categories; fix target init scaffold schema#298
cdot65 merged 3 commits into
cdot65:mainfrom
thresh97:fix/scan-categories-and-target-scaffold

Conversation

@thresh97

Copy link
Copy Markdown
Contributor

Summary

Two bugs found while building red-team scan automation against private EKS endpoints using the CUSTOM_TARGET_ADAPTER + NETWORK_BROKER pattern. Both verified against the live API.

Bug 1: airs redteam scan fails with 422 when --categories is omitted

Root cause: createScan() builds job_metadata: {} for STATIC scans when no categories are provided. The API rejects an empty object with a generic 422 — no useful error message, hard to debug.

Fix: When jobType === 'STATIC' and no categories are specified, fetch all available categories via getCategories() and use them as the default. MULTI_TURN is excluded from defaults because it requires multi_turn_supported: true on the target — most targets don't have it, and the API returns 400 if requested for an unsupported target.

A bare airs redteam scan --target <uuid> --name foo now works as expected.

Bug 2: airs redteam targets init <provider> generates stale schema

Root cause: The scaffold embedded the raw getTargetTemplates() response (url, no response_key) directly as connection_params. The current API expects RestConnectionParamsBase fields and requires several top-level fields that were missing. Generated JSON fails on POST /v1/target without manual correction.

Fix:

  • REST/HUGGING_FACE/STREAMING/WEBSOCKET: scaffold now uses correct RestConnectionParamsBase fields (api_endpoint promoted from template url, request_headers, response_key) with all required top-level fields (connection_type, api_endpoint_type, response_mode, auth_type, auth_config)
  • OPENAI/BEDROCK/DATABRICKS: scaffold uses NativeConnectionParamsBase with target_connection_config
  • Add CUSTOM_TARGET_ADAPTER provider: scaffolds an AGENT target with NETWORK_BROKER endpoint type, adapter_uuid placeholder, and adapter_variable_overrides as an empty array — the correct shape (a dict causes 422)
  • Add WEBSOCKET to valid providers list
  • Remove stale target_metadata field (not accepted on create)

Test plan

  • All 870 existing tests pass
  • Updated redteam-init.spec.ts to assert new schema shapes; added 4 new cases
  • Live tested: airs redteam scan --target <uuid> --name test --no-wait (STATIC, no --categories) → scan QUEUED, not 422
  • Live tested: airs redteam targets init RESTapi_endpoint, response_key, correct auth_config shape
  • Live tested: airs redteam targets init CUSTOM_TARGET_ADAPTERAGENT type, NETWORK_BROKER, adapter_variable_overrides: []

🤖 Generated with Claude Code

scan: default to all categories when --categories omitted

airs redteam scan --target <uuid> --name foo (STATIC, no --categories)
sent job_metadata: {} to the API, which returned 422 with no useful error.

Fix: when jobType is STATIC and no categories are provided, fetch the full
category list and use all of them. This matches the intuitive expectation
that a bare scan command tests everything available.

targets init: fix scaffold to match current API schema

The scaffold generated by airs redteam targets init <provider> used a
legacy connection_params format (url, no response_key) that the API
now rejects. Multiple required top-level fields were also missing.

Changes:
- REST/HUGGING_FACE/STREAMING/WEBSOCKET: scaffold now uses
  RestConnectionParamsBase fields (api_endpoint, request_headers,
  response_key) with correct top-level connection_type, api_endpoint_type,
  response_mode, auth_type, auth_config
- OPENAI/BEDROCK/DATABRICKS: scaffold uses target_connection_config inside
  connection_params (NativeConnectionParamsBase)
- Add CUSTOM_TARGET_ADAPTER provider: scaffolds an AGENT target with
  NETWORK_BROKER endpoint type, adapter_uuid, and adapter_variable_overrides
  array (the correct array-not-dict shape the API expects)
- Add WEBSOCKET to valid providers list
- Remove stale target_metadata field from scaffold (not a create field)

Tests: update existing scaffold test; add four new cases covering REST
api_endpoint, HUGGING_FACE url promotion, CUSTOM_TARGET_ADAPTER structure,
and updated error message. All 870 tests pass.
cdot65 added 2 commits August 5, 2026 17:09
# Conflicts:
#	docs-site/docs/developers/api/classes/SdkRedTeamService.md
@cdot65

cdot65 commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Maintainer follow-up is complete on 988f648:

  • Moved bare STATIC default-category resolution into the CLI via exported buildDefaultCategories; all current subcategories are selected except MULTI_TURN, with a --quiet-aware status notice.
  • Restored the service boundary: library callers must provide STATIC categories, receive a descriptive local error when omitted, and no hidden category/API request occurs.
  • Added the missing helper/service coverage while preserving CUSTOM and DYNAMIC behavior.
  • Kept the contributor's target scaffold fixes, applied Biome formatting, added a patch changeset, and documented scan defaults plus the WEBSOCKET/custom-adapter scaffold shapes.
  • Merged current main normally (no force-push) and regenerated the API reference.

Validation:

  • Local: TypeScript, Biome, 75 test files / 941 tests, and Docusaurus production build all pass.
  • Live: bare STATIC scan a7785491-9f31-481a-9333-faa00e6f64d4 defaulted to 27 categories with MULTI_TURN excluded, remained RUNNING for five minutes, then aborted successfully with final status ABORTED.
  • GitHub Actions run 31051750233: test, lint, typecheck, and docs-build all green.

@cdot65
cdot65 merged commit e67fd7e into cdot65:main Aug 5, 2026
4 checks passed
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.

2 participants