88import typer
99from typing import Optional
1010import json
11+ from datetime import date , timedelta
1112from conviso .core .notifier import info , error , summary , success
1213from conviso .clients .client_graphql import graphql_request
1314from conviso .core .output_manager import export_data
@@ -26,6 +27,7 @@ def list_vulnerabilities(
2627 project_types : Optional [str ] = typer .Option (None , "--project-types" , help = "Comma-separated project types (e.g. PENETRATION_TEST, WEB_PENETRATION_TESTING)." ),
2728 cves : Optional [str ] = typer .Option (None , "--cves" , help = "Comma-separated CVE identifiers." ),
2829 issue_types : Optional [str ] = typer .Option (None , "--types" , help = "Comma-separated failure types (e.g. WEB_VULNERABILITY, DAST_FINDING, SAST_FINDING, SOURCE_CODE_VULNERABILITY, NETWORK_VULNERABILITY, SCA_FINDING)." ),
30+ days_back : Optional [int ] = typer .Option (None , "--days-back" , help = "Filter by created date in the last N days (sets --created-start automatically)." ),
2931 created_start : Optional [str ] = typer .Option (None , "--created-start" , help = "Created at >= (YYYY-MM-DD)." ),
3032 created_end : Optional [str ] = typer .Option (None , "--created-end" , help = "Created at <= (YYYY-MM-DD)." ),
3133 risk_until_start : Optional [str ] = typer .Option (None , "--risk-until-start" , help = "Risk accepted until >= (YYYY-MM-DD)." ),
@@ -156,6 +158,15 @@ def _split_strs(value: Optional[str]):
156158 if business_impact_list :
157159 business_impact_list = [b .upper () for b in business_impact_list ]
158160
161+ if days_back is not None :
162+ if days_back < 0 :
163+ error ("--days-back must be >= 0." )
164+ raise typer .Exit (code = 1 )
165+ if created_start :
166+ error ("Use either --days-back or --created-start, not both." )
167+ raise typer .Exit (code = 1 )
168+ created_start = (date .today () - timedelta (days = days_back )).isoformat ()
169+
159170 created_range = None
160171 if created_start or created_end :
161172 created_range = {"startDate" : created_start , "endDate" : created_end }
0 commit comments