Skip to content

Commit

Permalink
chore: fix vulnerabilities and deprecation warnings (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
saikumarrs authored Sep 25, 2024
1 parent ff1f2f0 commit 5aed86f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
6 changes: 3 additions & 3 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
backoff==2.2.1
deprecation==2.1.0
mock==4.0.3
mock==5.1.0
monotonic==1.6
packaging==24.1
pytest==7.4.4
pytest==8.3.3
requests==2.32.3
flake8==7.1.0
flake8==7.1.1
python-dateutil==2.9.0
python-dotenv==1.0.1
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
#
backoff==2.2.1
# via -r requirements.in
certifi==2024.6.2
certifi==2024.8.30
# via requests
charset-normalizer==3.3.2
# via requests
deprecation==2.1.0
# via -r requirements.in
flake8==7.1.0
flake8==7.1.1
# via -r requirements.in
idna==3.7
idna==3.10
# via requests
iniconfig==2.0.0
# via pytest
mccabe==0.7.0
# via flake8
mock==4.0.3
mock==5.1.0
# via -r requirements.in
monotonic==1.6
# via -r requirements.in
Expand All @@ -31,11 +31,11 @@ packaging==24.1
# pytest
pluggy==1.5.0
# via pytest
pycodestyle==2.12.0
pycodestyle==2.12.1
# via flake8
pyflakes==3.2.0
# via flake8
pytest==7.4.4
pytest==8.3.3
# via -r requirements.in
python-dateutil==2.9.0
# via -r requirements.in
Expand All @@ -45,5 +45,5 @@ requests==2.32.3
# via -r requirements.in
six==1.16.0
# via python-dateutil
urllib3==2.2.2
urllib3==2.2.3
# via requests
4 changes: 2 additions & 2 deletions rudderstack/analytics/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone
from uuid import uuid4
import logging
import numbers
Expand Down Expand Up @@ -245,7 +245,7 @@ def _enqueue(self, msg):
"""Push a new `msg` onto the queue, return `(success, msg)`"""
timestamp = msg['timestamp']
if timestamp is None:
timestamp = datetime.utcnow().replace(tzinfo=tzutc())
timestamp = datetime.now(timezone.utc).replace(tzinfo=tzutc())
message_id = msg.get('messageId')
if message_id is None:
message_id = uuid4()
Expand Down
5 changes: 2 additions & 3 deletions rudderstack/analytics/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

from queue import Empty

MAX_MSG_SIZE = 4 << 10 << 10 ## 4 mb

# Our servers only accept batches less than 500KB. Here limit is set slightly
# Our servers only accept payloads within this limit. Here limit is set slightly
# lower to leave space for extra data that will be added later, eg. "sentAt".
MAX_MSG_SIZE = 4 << 10 << 10 ## 4 mb
BATCH_SIZE_LIMIT = 4 << 10 << 10 ## 4 mb


Expand Down
4 changes: 2 additions & 2 deletions rudderstack/analytics/request.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import date, datetime
from datetime import date, datetime, timezone
from io import BytesIO
from gzip import GzipFile
import logging
Expand All @@ -17,7 +17,7 @@ def post(write_key, host=None, gzip=True, timeout=15, proxies=None, **kwargs):
"""Post the `kwargs` to the API"""
log = logging.getLogger('rudderstack')
body = kwargs
body["sentAt"] = datetime.utcnow().replace(tzinfo=tzutc()).isoformat()
body["sentAt"] = datetime.now(timezone.utc).replace(tzinfo=tzutc()).isoformat()
url = remove_trailing_slash(host or 'https://api.rudderstack.com') + '/v1/batch'
auth = HTTPBasicAuth(write_key, '')
data = json.dumps(body, cls=DatetimeSerializer)
Expand Down
4 changes: 2 additions & 2 deletions rudderstack/analytics/test/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import date, datetime, timedelta
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal
import unittest

Expand Down Expand Up @@ -51,7 +51,7 @@ def test_clean(self):
def test_clean_with_dates(self):
dict_with_dates = {
'birthdate': date(1980, 1, 1),
'registration': datetime.utcnow(),
'registration': datetime.now(timezone.utc),
}
self.assertEqual(dict_with_dates, utils.clean(dict_with_dates))

Expand Down

0 comments on commit 5aed86f

Please sign in to comment.