Skip to content

Commit

Permalink
Change: Calculate both start and end date, if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
n-thumann authored and greenbonebot committed Nov 10, 2023
1 parent 3d6a376 commit bc27067
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pontos/nvd/cve_change_history/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Params,
convert_camel_case,
format_date,
now,
)
from pontos.nvd.models.cve_change import CVEChange, EventName

Expand Down Expand Up @@ -103,10 +104,12 @@ async def cve_changes(
"""
total_results: Optional[int] = None

if bool(change_start_date) ^ bool(change_end_date):
raise PontosError(
"change_start_date and change_end_date must be provided mutally"
if change_start_date and not change_end_date:
change_end_date = min(
now(), change_start_date + timedelta(days=120)
)
elif change_end_date and not change_start_date:
change_start_date = change_end_date - timedelta(days=120)

params: Params = {}
if change_start_date and change_end_date:
Expand Down

0 comments on commit bc27067

Please sign in to comment.