Skip to content

fix(cloud-security): exclude per-task runs from latest scan selection - #3341

Merged
tofikwest merged 3 commits into
mainfrom
tofik/cs-702-bug-aws-cloud-security-tests
Jul 6, 2026
Merged

fix(cloud-security): exclude per-task runs from latest scan selection#3341
tofikwest merged 3 commits into
mainfrom
tofik/cs-702-bug-aws-cloud-security-tests

Conversation

@tofikwest

@tofikwest tofikwest commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Automated daily AWS Cloud Security scans show minimal results while manual scans on the same day return full results. Customers see an incomplete security posture from automated runs but get correct data when triggering manually.

Root cause

The getLatestRunsByConnection and getNewPlatformFindings queries select the newest IntegrationCheckRun per connection using distinct(['connectionId']) without filtering by check type. The full AWS security scan (checkId 'aws-security-scan') runs at 05:00 and produces complete results. Later at 06:00 per-task evidence checks write their own runs to the same connectionId with status updates. Since the query picks the absolute newest run per connection, it shadows the full scan result with a tiny per-task run. Manual scans bypass this by writing a fresh full run that temporarily becomes the latest.

Fix

Scope the latest-run selection to only the provider's 'security-scan' checkId, excluding per-task evidence check runs from the latest run calculation. This ensures the dashboard always displays the full scan result as intended.

Explicitly NOT touched

Per-task evidence check runs continue to execute and store normally. No changes to scan scheduling or task execution logic. Historical data remains intact.

Verification

✅ Automated daily scan now returns full result set matching manual scan
✅ Dashboard latest run consistently shows complete AWS security findings
✅ Per-task check runs still execute and don't interfere with primary results

Fixes CS-702


Summary by cubic

Fixes CS-702 by scoping “latest run” selection to cloud-security scan checkIds so per-task and all runs no longer shadow the full daily scan. Automated results now match manual scans across AWS, GCP, and Azure.

  • Bug Fixes
    • Scope latest-run queries in CloudSecurityQueryService to aws-security-scan, gcp-security-scan, and azure-security-scan (via CLOUD_SCAN_CHECK_IDS).
    • Add regression tests that reproduce the 05:00 scan vs 06:00 per-task ordering and verify findings and provider summaries use the full scan, including asserting the scoped checkId filter.

Written for commit e1b6c0b. Summary will update on new commits.

Review in cubic

## Problem

Automated daily AWS Cloud Security scans show minimal results while manual scans on the same day return full results. Customers see an incomplete security posture from automated runs but get correct data when triggering manually.

## Root cause

The `getLatestRunsByConnection` and `getNewPlatformFindings` queries select the newest `IntegrationCheckRun` per connection using `distinct(['connectionId'])` without filtering by check type. The full AWS security scan (checkId 'aws-security-scan') runs at 05:00 and produces complete results. Later at 06:00 per-task evidence checks write their own runs to the same connectionId with status updates. Since the query picks the absolute newest run per connection, it shadows the full scan result with a tiny per-task run. Manual scans bypass this by writing a fresh full run that temporarily becomes the latest.

## Fix

Scope the latest-run selection to only the provider's 'security-scan' checkId, excluding per-task evidence check runs from the latest run calculation. This ensures the dashboard always displays the full scan result as intended.

## Explicitly NOT touched

Per-task evidence check runs continue to execute and store normally. No changes to scan scheduling or task execution logic. Historical data remains intact.

## Verification

✅ Automated daily scan now returns full result set matching manual scan
✅ Dashboard latest run consistently shows complete AWS security findings
✅ Per-task check runs still execute and don't interfere with primary results
@linear

linear Bot commented Jul 2, 2026

Copy link
Copy Markdown

CS-702

@vercel

vercel Bot commented Jul 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Jul 6, 2026 3:02pm
comp-framework-editor Ready Ready Preview, Comment Jul 6, 2026 3:02pm
portal Ready Ready Preview, Comment Jul 6, 2026 3:02pm

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cubic analysis

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Linked issue analysis

Linked issue: CS-702: [Bug] - AWS Cloud Security Tests — Automated Daily Scan Returns Minimal Results vs. Manual Scan

Status Acceptance criteria Notes
Automated daily scans return the full result set (comparable to manual scan) Unit test reproduces the scenario (full scan at 05:00, newer per-task run at 06:00) and asserts getFindings returns the three full-scan results and excludes the per-task-only result.
Cloud Tests dashboard latestRun shows the complete AWS security findings (summary metrics from full scan) Unit test asserts the provider latestRun contains the full-scan totals (totalChecked/passedCount/failedCount) after the change.
Latest-run selection is scoped to provider 'security-scan' checkIds (excluding per-task/'all' runs) Code adds CLOUD_SCAN_CHECK_IDS and applies checkId: { in: CLOUD_SCAN_CHECK_IDS } to integrationCheckRun.findMany; a test asserts findMany was called with the expected checkId array.
Regression covered by tests that emulate Prisma ordering/distinct to ensure per-task runs don't shadow full scans The spec file includes an in-memory mock of the Prisma semantics and fixtures (scanRun and taskRun) that reproduce the problematic ordering and verify the fix.

Re-trigger cubic

@tofikwest
tofikwest merged commit 1cef7fd into main Jul 6, 2026
10 checks passed
@tofikwest
tofikwest deleted the tofik/cs-702-bug-aws-cloud-security-tests branch July 6, 2026 15:22
@claudfuen

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.98.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants