Skip to content

Commit

Permalink
Replaced utcnow calls
Browse files Browse the repository at this point in the history
  • Loading branch information
3c7 committed Feb 28, 2024
1 parent 856fce0 commit 7741401
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions common_osint_model/models/domain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, UTC
from typing import Optional, List

from pydantic import BaseModel
Expand All @@ -15,15 +15,15 @@ class Entity(BaseModel):
postal_code: Optional[str]
country: Optional[str]
phone: Optional[str]
timestamp: datetime = datetime.utcnow()
timestamp: datetime = datetime.now(UTC)


class Domain(BaseModel):
"""Represents a domain pointing to a specific host. Also, this object might be used to represent found via other
sources, therefore a 'query' field might contain the query used to find it"""
domain: str
first_seen: datetime = datetime.utcnow()
last_seen: datetime = datetime.utcnow()
first_seen: datetime = datetime.now(UTC)
last_seen: datetime = datetime.now(UTC)
source: Optional[str]
type: Optional[str]
soa: Optional[List[str]]
Expand Down
6 changes: 3 additions & 3 deletions common_osint_model/models/host.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ipaddress
import json
from datetime import datetime
from datetime import datetime, UTC
from typing import Optional, Dict, List, Union

from pydantic import BaseModel, validator
Expand All @@ -22,8 +22,8 @@ class Host(BaseModel, ShodanDataHandler, CensysDataHandler, BinaryEdgeDataHandle
# List of open ports also mentioned in the open
ports: Optional[List[int]]
# Timestamps for activity tracking
first_seen: Optional[datetime] = datetime.utcnow()
last_seen: Optional[datetime] = datetime.utcnow()
first_seen: Optional[datetime] = datetime.now(UTC)
last_seen: Optional[datetime] = datetime.now(UTC)
# A list of domains, fqdns, common names - or other attributes which represent domainnames - assigned to the host
domains: Optional[List[Domain]]
# This represents the source where the host information was obtained, e.g. shodan, censys...
Expand Down
6 changes: 3 additions & 3 deletions common_osint_model/models/service.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, UTC
from typing import Dict, List, Optional

from pydantic import BaseModel
Expand All @@ -24,8 +24,8 @@ class Service(BaseModel, ShodanDataHandler, CensysDataHandler, BinaryEdgeDataHan
murmur: Optional[str]
# Every service object should include these timestamps. "timestamp" can be used for tracking the observation
# timestamp from scanning services (e.g. Shodan)
first_seen: Optional[datetime] = datetime.utcnow()
last_seen: Optional[datetime] = datetime.utcnow()
first_seen: Optional[datetime] = datetime.now(UTC)
last_seen: Optional[datetime] = datetime.now(UTC)
timestamp: Optional[datetime]
# We need to include every possible service component here. In order to not export empty dictionary keys, the class
# object can be exported with dict(exclude_none=True), so e.g. empty tls keys are skipped.
Expand Down
4 changes: 2 additions & 2 deletions common_osint_model/models/tls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import binascii
from datetime import datetime
from datetime import datetime, UTC
from typing import Dict, List, Optional, Union

import pytz
Expand Down Expand Up @@ -314,7 +314,7 @@ def from_binaryedge(cls, d: Union[Dict, List]):
)
issued = datetime.fromisoformat(data["validity"]["not_before"]).replace(tzinfo=pytz.utc)
expires = datetime.fromisoformat(data["validity"]["not_after"]).replace(tzinfo=pytz.utc)
expired = datetime.utcnow().replace(tzinfo=pytz.utc) < expires
expired = datetime.now(UTC) < expires
trusted = not data.get("self_issued", False) or data.get("self_signed", False)
return TLSComponentCertificate(
issuer=TLSComponentCertificateEntity.from_binaryedge(data["issuer"]),
Expand Down

0 comments on commit 7741401

Please sign in to comment.