Skip to content

feat(ui): filter empty Attack Paths queries from the selector in Cloud#12010

Open
danibarranqueroo wants to merge 2 commits into
masterfrom
PROWLER-2195-attack-paths-filter-empty-queries
Open

feat(ui): filter empty Attack Paths queries from the selector in Cloud#12010
danibarranqueroo wants to merge 2 commits into
masterfrom
PROWLER-2195-attack-paths-filter-empty-queries

Conversation

@danibarranqueroo

@danibarranqueroo danibarranqueroo commented Jul 16, 2026

Copy link
Copy Markdown
Member

Context

Frontend piece of the Attack Paths "precompute query results / filter empty queries" epic (PROWLER-2195).

Depends on the Cloud API exposing the per-query result summary (result_summary) on the queries endpoint. That work is Cloud-only; this PR is written so it is a no-op on self-hosted (see the feature flag below).

Description

In Prowler Cloud, the Attack Paths query selector now lists only the queries that returned data for the selected scan. Empty queries are hidden, so users aren't offered queries that can't return anything for their account.

The queries API now returns a result_summary ({ status, has_data } or null) per query. The adapter filters on it with one rule — hide a query only when the scan computed it and found it empty:

  • has_data === true → shown
  • has_data === false (status ok) → hidden
  • errored during precompute (has_data null) → shown
  • parameterized queries (no summary, run live on demand) → shown
  • scans predating the precompute step (no summary) → shown

So a null/missing summary is never treated as "empty", which means a partial precompute or a broken query never wrongly hides something.

Feature-flagged. All of this is gated behind NEXT_PUBLIC_IS_CLOUD_ENV via the existing isCloud() helper. Self-hosted deployments, whose API does not precompute result summaries, keep showing every query exactly as today.

Changes

  • types/attack-paths.ts — add AttackPathQueryResultSummary and an optional result_summary on the query attributes.
  • actions/attack-paths/queries.adapter.tsshouldShowQuery predicate (short-circuits to "show all" when not in Cloud); applied in adaptAttackPathQueriesResponse.
  • actions/attack-paths/queries.adapter.test.ts — filtering tests covering a mix of has_data true/false, errored, and parameterized queries, plus the flag-off (self-hosted) case.

Steps to review

  1. queries.adapter.ts — the predicate and the flag gate.
  2. queries.adapter.test.ts — 5 tests; verify the "absent ≠ empty" and flag-off behaviour.
  3. Note the selector component is unchanged — filtering lives in the adapter (data layer), so the component test the ticket mentions is covered at the adapter layer where the logic actually is.

Verified locally against a real Cloud API + a genuine scan: with the flag on, the dropdown drops from all queries to only the with-data ones; with the flag off, all queries show. pnpm --filter ui test for the attack-paths actions passes (23 tests), eslint/prettier clean.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Summary by CodeRabbit

  • New Features

    • Attack Paths now hide queries with no returned data in Prowler Cloud.
    • Queries with data, errors, parameters, or unavailable result summaries remain visible.
    • Self-hosted deployments continue to display all queries.
  • Bug Fixes

    • Pagination counts now reflect the filtered query results.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Attack path query result summaries now support Cloud-only filtering of queries with explicitly empty results. The adapter updates filtered pagination counts, while self-hosted behavior retains all queries. Tests cover filtering, missing responses, pagination, and environment differences.

Changes

Attack path query filtering

Layer / File(s) Summary
Summary contract and environment-aware predicate
ui/types/attack-paths.ts, ui/actions/attack-paths/queries.adapter.ts
Adds optional query result summaries and exports shouldShowQuery, which hides only explicitly empty queries in Cloud.
Adapter filtering and validation
ui/actions/attack-paths/queries.adapter.ts, ui/actions/attack-paths/queries.adapter.test.ts, ui/changelog.d/*
Filters response data before enrichment, adjusts pagination counts, and tests Cloud, self-hosted, missing-response, and retained-query behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AttackPathQueriesResponse
  participant adaptAttackPathQueriesResponse
  participant shouldShowQuery
  AttackPathQueriesResponse->>adaptAttackPathQueriesResponse: provide response data
  adaptAttackPathQueriesResponse->>shouldShowQuery: evaluate each query
  shouldShowQuery-->>adaptAttackPathQueriesResponse: return visible queries
  adaptAttackPathQueriesResponse-->>AttackPathQueriesResponse: return enriched data and pagination count
Loading

Suggested reviewers: alejandrobailo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly describes the main change: Cloud-only filtering of empty Attack Paths queries.
Description check ✅ Passed The description follows the template and includes context, change summary, review steps, and license, with only optional checklist items omitted.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch PROWLER-2195-attack-paths-filter-empty-queries

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

No Conflicts

No conflict markers, and the branch merges cleanly into its base.

@github-actions

Copy link
Copy Markdown
Contributor

✅ All required changelog fragments are present.

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🔒 Container Security Scan

Image: prowler-ui:d923bb5
Last scan: 2026-07-22 14:15:09 UTC

✅ No Vulnerabilities Detected

The container image passed all security checks. No known CVEs were found.

📋 Resources:

@danibarranqueroo
danibarranqueroo force-pushed the PROWLER-2195-attack-paths-filter-empty-queries branch 2 times, most recently from 73dbad1 to 279ca71 Compare July 21, 2026 12:00
In Prowler Cloud, the Attack Paths query selector now lists only parameterless
queries that returned data for the selected scan, using the precomputed
per-query result summary from the queries API. Parameterized and custom queries
are always shown (they run live on demand), and so are queries that errored
during precompute or a scan predating the precompute step -- a query is hidden
only when the scan computed it and found it empty.

Gated behind NEXT_PUBLIC_IS_CLOUD_ENV: self-hosted deployments, whose API does
not precompute result summaries, keep showing every query as before.

Refs PROWLER-2195
@danibarranqueroo
danibarranqueroo force-pushed the PROWLER-2195-attack-paths-filter-empty-queries branch from 279ca71 to a381ac9 Compare July 22, 2026 12:04
The Cloud flag moved from build-time NEXT_PUBLIC_IS_CLOUD_ENV to the
runtime UI_CLOUD_ENABLED (#12061). The adapter already gates on isCloud(),
which resolves the new mechanism; update the stale docstring to match.
@danibarranqueroo
danibarranqueroo marked this pull request as ready for review July 22, 2026 15:35
@danibarranqueroo
danibarranqueroo requested a review from a team as a code owner July 22, 2026 15:35

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/changelog.d/attack-paths-filter-empty-queries.added.md`:
- Line 1: Update the changelog statement to say that only queries confirmed
empty for the selected scan are hidden, while avoiding the broader claim that
all queries without returned data are removed.

In `@ui/types/attack-paths.ts`:
- Around line 136-138: Update AttackPathQueryResultSummary.status to use the
UI’s const-object pattern: define or reuse a const status object and derive the
property type from its values instead of declaring the inline "ok" | "error"
union. Preserve the existing allowed status values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a40e955e-2088-4e06-a11c-888851eb192d

📥 Commits

Reviewing files that changed from the base of the PR and between ff45f46 and a27fc88.

📒 Files selected for processing (4)
  • ui/actions/attack-paths/queries.adapter.test.ts
  • ui/actions/attack-paths/queries.adapter.ts
  • ui/changelog.d/attack-paths-filter-empty-queries.added.md
  • ui/types/attack-paths.ts

@@ -0,0 +1 @@
In Prowler Cloud, the Attack Paths query selector now lists only queries that returned data for the selected scan, hiding empty ones

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Describe only confirmed-empty queries as hidden.

This says only queries that returned data remain, but errored, parameterized, and precompute-missing queries intentionally remain visible. Update it to say that queries confirmed empty for the selected scan are hidden.

-In Prowler Cloud, the Attack Paths query selector now lists only queries that returned data for the selected scan, hiding empty ones
+In Prowler Cloud, the Attack Paths query selector now hides queries confirmed to have no results for the selected scan.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
In Prowler Cloud, the Attack Paths query selector now lists only queries that returned data for the selected scan, hiding empty ones
In Prowler Cloud, the Attack Paths query selector now hides queries confirmed to have no results for the selected scan.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/changelog.d/attack-paths-filter-empty-queries.added.md` at line 1, Update
the changelog statement to say that only queries confirmed empty for the
selected scan are hidden, while avoiding the broader claim that all queries
without returned data are removed.

Comment thread ui/types/attack-paths.ts
Comment on lines +136 to +138
export interface AttackPathQueryResultSummary {
status: "ok" | "error";
has_data: boolean | null;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== ui/types/attack-paths.ts =="
nl -ba ui/types/attack-paths.ts | sed -n '1,240p'

echo
echo "== string-literal unions in ui/types =="
rg -n --glob 'ui/types/**/*.ts' '"[^"]+"\s*\|\s*"[^"]+"' ui/types

echo
echo "== const-object union patterns in ui/types =="
rg -n --glob 'ui/types/**/*.ts' 'as const;' ui/types

Repository: prowler-cloud/prowler

Length of output: 230


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="ui/types/attack-paths.ts"
if [ -f "$file" ]; then
  echo "== $file (around target lines) =="
  nl -ba "$file" | sed -n '120,180p'
else
  echo "missing file: $file" >&2
  exit 1
fi

echo
echo "== nearby union patterns in ui/types/attack-paths.ts =="
rg -n '"[^"]+"\s*\|\s*"[^"]+"' "$file" || true

echo
echo "== usages of AttackPathQueryResultSummary =="
rg -n 'AttackPathQueryResultSummary' ui || true

Repository: prowler-cloud/prowler

Length of output: 252


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== ui/types/attack-paths.ts (lines 120-180) =="
sed -n '120,180p' ui/types/attack-paths.ts | cat -n

echo
echo "== string-literal unions in ui/types =="
rg -n --glob 'ui/types/**/*.ts' '"[^"]+"\s*\|\s*"[^"]+"' ui/types || true

echo
echo "== const-object patterns in ui/types =="
rg -n --glob 'ui/types/**/*.ts' 'as const;' ui/types || true

echo
echo "== usages of AttackPathQueryResultSummary =="
rg -n 'AttackPathQueryResultSummary' ui || true

Repository: prowler-cloud/prowler

Length of output: 7091


Use the const-object pattern for status.

status: "ok" | "error" should be defined from a const object to match the UI type convention.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/types/attack-paths.ts` around lines 136 - 138, Update
AttackPathQueryResultSummary.status to use the UI’s const-object pattern: define
or reuse a const status object and derive the property type from its values
instead of declaring the inline "ok" | "error" union. Preserve the existing
allowed status values.

Sources: Coding guidelines, Path instructions

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant