Skip to content

Commit 3a988a7

Browse files
authored
Implement a flag --day-back to list new vulns (#10)
Implement a flag --day-back to list new vulns
2 parents ac98124 + bb87b40 commit 3a988a7

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ conviso --help
9494
- Tasks (only valid YAML): `python -m conviso.app tasks list --company-id 443 --project-id 26102 --only-valid`
9595
- Tasks (create with inline YAML): `python -m conviso.app tasks create --company-id 443 --label "Quick Task" --yaml "name: quick\nsteps:\n - action: echo\n message: ok"`
9696
- Vulnerabilities: `python -m conviso.app vulns list --company-id 443 --severities HIGH,CRITICAL --asset-tags cloud --all`
97+
- Vulnerabilities (last 7 days): `python -m conviso.app vulns list --company-id 443 --days-back 7 --severities HIGH,CRITICAL --all`
9798

9899
Output options: `--format table|json|csv`, `--output path` to save JSON/CSV.
99100

src/conviso/commands/vulnerabilities.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import typer
99
from typing import Optional
1010
import json
11+
from datetime import date, timedelta
1112
from conviso.core.notifier import info, error, summary, success
1213
from conviso.clients.client_graphql import graphql_request
1314
from 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

Comments
 (0)