chg: [website] Provide the possibility to the user to set the timestamp of a sighting (optional).

This commit is contained in:
Cédric Bonhomme 2024-11-12 09:22:11 +01:00
parent 9ab342c19f
commit e3506e69a7
Signed by untrusted user who does not match committer: cedric
GPG key ID: A1CB94DE57B7A70D

View file

@ -218,13 +218,16 @@ class SightingsList(Resource): # type: ignore[misc]
sighting = sighting_ns.payload
sighting["uuid"] = sighting.get("uuid", str(uuid.uuid4()))
sighting["vulnerability_lookup_origin"] = local_instance_uuid
sighting["creation_timestamp"] = current_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if sighting.get("creation_timestamp"):
sighting["creation_timestamp"] = sighting["creation_timestamp"]
else:
sighting["creation_timestamp"] = current_time.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
if (
Sighting.query.filter(
Sighting.vulnerability.ilike(sighting["vulnerability"]),
Sighting.source == sighting["source"],
func.date(Sighting.creation_timestamp) == func.date(current_time),
# func.date(Sighting.creation_timestamp) == func.date(current_time),
).count()
!= 0
):