Skip to content

fix(gateway): prevent cleanup scripts from destroying shared resources - #1954

Merged
EashanKaushik merged 1 commit into
awslabs:mainfrom
jyotsnamas:fix/cleanup-scripts-safe-deletion
Aug 24, 2026
Merged

fix(gateway): prevent cleanup scripts from destroying shared resources#1954
EashanKaushik merged 1 commit into
awslabs:mainfrom
jyotsnamas:fix/cleanup-scripts-safe-deletion

Conversation

@jyotsnamas

Copy link
Copy Markdown
Contributor

Summary

Two cleanup scripts have destructive bugs when used with shared gateways:

1. scripts/waf/cleanup.py — deletes entire gateway instead of its own target

  • The WAF tutorial's deploy.py accepts an existing GATEWAY_ID and creates a single target on it
  • But cleanup.py calls admin.delete_gateway() which deletes all targets and the gateway itself
  • This destroys resources belonging to other tutorials running on the same gateway
  • Fix: Only delete the specific target using TARGET_ID stored in .env

2. scripts/semantic-search/cleanup.py — race condition on gateway deletion

  • Calls admin.delete_gateway() which deletes targets then immediately attempts gateway deletion
  • Target deletion is asynchronous — gateway delete fails with ValidationException: Gateway has targets associated
  • Fix: Explicitly delete targets, poll list_gateway_targets until empty (up to 2 min), then delete gateway

Test plan

  • WAF cleanup: verified it only removes its own target, leaving other targets intact
  • Semantic search cleanup: verified targets are fully deleted before gateway deletion proceeds
  • Both scripts handle already-deleted resources gracefully (ResourceNotFoundException)

🤖 Generated with Claude Code

Two cleanup script bugs:

1. **waf/cleanup.py** calls `admin.delete_gateway(gateway_id)` which
   deletes ALL targets on the gateway and the gateway itself. But the
   WAF tutorial only creates one target on an existing shared gateway.
   Fix: only delete the specific target (via TARGET_ID from .env).

2. **semantic-search/cleanup.py** calls `admin.delete_gateway()` which
   internally deletes targets then immediately tries to delete the
   gateway. Target deletion is asynchronous — the gateway delete fails
   with "Gateway has targets associated". Fix: explicitly delete
   targets, poll until they're gone, then delete the gateway.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Latest scan for commit: 2516759 | Updated: 2026-08-13 20:19:06 UTC

Security Scan Results

Scan Metadata

  • Project: ASH
  • Scan executed: 2026-08-13T20:18:52+00:00
  • ASH version: 3.0.0

Summary

Scanner Results

The table below shows findings by scanner, with status based on severity thresholds and dependencies:

Column Explanations:

Severity Levels (S/C/H/M/L/I):

  • Suppressed (S): Security findings that have been explicitly suppressed/ignored and don't affect the scanner's pass/fail status
  • Critical (C): The most severe security vulnerabilities requiring immediate remediation (e.g., SQL injection, remote code execution)
  • High (H): Serious security vulnerabilities that should be addressed promptly (e.g., authentication bypasses, privilege escalation)
  • Medium (M): Moderate security risks that should be addressed in normal development cycles (e.g., weak encryption, input validation issues)
  • Low (L): Minor security concerns with limited impact (e.g., information disclosure, weak recommendations)
  • Info (I): Informational findings for awareness with minimal security risk (e.g., code quality suggestions, best practice recommendations)

Other Columns:

  • Time: Duration taken by each scanner to complete its analysis
  • Action: Total number of actionable findings at or above the configured severity threshold that require attention

Scanner Results:

  • PASSED: Scanner found no security issues at or above the configured severity threshold - code is clean for this scanner
  • FAILED: Scanner found security vulnerabilities at or above the threshold that require attention and remediation
  • MISSING: Scanner could not run because required dependencies/tools are not installed or available
  • SKIPPED: Scanner was intentionally disabled or excluded from this scan
  • ERROR: Scanner encountered an execution error and could not complete successfully

Severity Thresholds (Thresh Column):

  • CRITICAL: Only Critical severity findings cause scanner to fail
  • HIGH: High and Critical severity findings cause scanner to fail
  • MEDIUM (MED): Medium, High, and Critical severity findings cause scanner to fail
  • LOW: Low, Medium, High, and Critical severity findings cause scanner to fail
  • ALL: Any finding of any severity level causes scanner to fail

Threshold Source: Values in parentheses indicate where the threshold is configured:

  • (g) = global: Set in the global_settings section of ASH configuration
  • (c) = config: Set in the individual scanner configuration section
  • (s) = scanner: Default threshold built into the scanner itself

Statistics calculation:

  • All statistics are calculated from the final aggregated SARIF report
  • Suppressed findings are counted separately and do not contribute to actionable findings
  • Scanner status is determined by comparing actionable findings to the threshold
Scanner S C H M L I Time Action Result Thresh
bandit 0 0 0 0 0 0 398ms 0 PASSED MED (g)
cdk-nag 0 0 0 0 0 0 6.1s 0 PASSED MED (g)
cfn-nag 0 0 0 0 0 0 6ms 0 PASSED MED (g)
checkov 0 0 0 0 0 0 4.5s 0 PASSED MED (g)
detect-secrets 0 0 0 0 0 0 931ms 0 PASSED MED (g)
grype 0 0 0 0 0 0 56.0s 0 PASSED MED (g)
npm-audit 0 0 0 0 0 0 167ms 0 PASSED MED (g)
opengrep 0 0 0 0 0 0 <1ms 0 SKIPPED MED (g)
semgrep 0 0 0 0 0 0 <1ms 0 MISSING MED (g)
syft 0 0 0 0 0 0 2.1s 0 PASSED MED (g)

@EashanKaushik
EashanKaushik merged commit 911643a into awslabs:main Aug 24, 2026
7 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