Skip to content

test : add unit tests for finding_intelligence build_asset_summary function #1183

Description

@tmdeveloper007

Summary of What Needs to be Done:
The backend/secuscan/finding_intelligence.py module's build_asset_summary function is a public, pure function that is not covered by the existing test_finding_intelligence.py tests (which only cover build_finding_groups and build_scan_diff). This function merges service inventory with finding data to produce an asset-level summary. Adding unit tests ensures correctness of severity ranking, asset grouping, and sorting logic.

Changes that Need to be Made:
Add test cases to testing/backend/unit/test_finding_intelligence.py (extend existing file):

  • build_asset_summary returns one entry per unique asset_id
  • Services are grouped under their corresponding assets
  • Findings increment finding_count per asset
  • Validated findings increment validated_count
  • Severity is correctly escalated to the highest finding severity
  • Assets are sorted by severity desc, then finding_count desc
  • Empty inputs return empty list

Import: from backend.secuscan.finding_intelligence import build_asset_summary
Run: python3 -m pytest testing/backend/unit/test_finding_intelligence.py -v --noconftest

Impact that it would Provide:

  • Prevents regressions in asset summary aggregation logic
  • Ensures severity escalation and sorting work correctly
  • Increases coverage for a function used in dashboard and reporting

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions