Skip to content

Commit

Permalink
Merge pull request #526 from carbonblack/release-1.5.4
Browse files Browse the repository at this point in the history
Release 1.5.4 - merge to master
  • Loading branch information
abowersox-cb authored Jul 10, 2024
2 parents be15613 + 3adbc86 commit 1c754c9
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Carbon Black Cloud Python SDK

**Latest Version:** 1.5.3
**Latest Version:** 1.5.4
<br>
**Release Date:** June 27, 2024
**Release Date:** July 10, 2024

[![Coverage Status](https://coveralls.io/repos/github/carbonblack/carbon-black-cloud-sdk-python/badge.svg?t=Id6Baf)](https://coveralls.io/github/carbonblack/carbon-black-cloud-sdk-python)
[![Codeship Status for carbonblack/carbon-black-cloud-sdk-python](https://app.codeship.com/projects/9e55a370-a772-0138-aae4-129773225755/status?branch=develop)](https://app.codeship.com/projects/402767)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.3
1.5.4
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
Changelog
=========

CBC SDK 1.5.4 - Released July 10, 2024
--------------------------------------

Bug Fixes:

* Fixed dependency on backports-datetime-fromisoformat for Python 3.11 and later.
* Fixed a bug affecting the ability to access alert attributes with array syntax.

CBC SDK 1.5.3 - Released June 27, 2024
--------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
author = 'Developer Relations'

# The full version, including alpha/beta/rc tags
release = '1.5.3'
release = '1.5.4'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ validators
jsonschema
keyring;platform_system=='Darwin'
boto3
backports-datetime-fromisoformat==2.0.1
backports-datetime-fromisoformat==2.0.1 ; python_version < '3.11'


# Dev dependencies
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
'jsonschema',
"keyring;platform_system=='Darwin'",
'boto3',
'backports-datetime-fromisoformat==2.0.1'
]

extras_require = {
Expand All @@ -44,6 +43,8 @@

if sys.version_info < (3, 0):
install_requires.extend(['futures'])
if sys.version_info < (3, 11):
install_requires.extend(['backports-datetime-fromisoformat==2.0.1'])


def read(fname):
Expand Down
4 changes: 2 additions & 2 deletions src/cbc_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
__title__ = 'cbc_sdk'
__author__ = 'Carbon Black Developer Network'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020-2024 VMware Carbon Black'
__version__ = '1.5.3'
__copyright__ = 'Copyright 2020-2024 Broadcom Inc. Carbon Black'
__version__ = '1.5.4'

from .rest_api import CBCloudAPI
from .cache import lru
44 changes: 32 additions & 12 deletions src/cbc_sdk/platform/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import time
import datetime
import sys

from cbc_sdk.errors import ApiError, ObjectNotFoundError, NonQueryableModel, FunctionalityDecommissioned
from cbc_sdk.platform import PlatformModel
Expand All @@ -51,7 +52,8 @@
from cbc_sdk.platform.network_threat_metadata import NetworkThreatMetadata
from cbc_sdk.enterprise_edr.threat_intelligence import Watchlist

from backports._datetime_fromisoformat import datetime_fromisoformat
if sys.version_info < (3, 11):
from backports._datetime_fromisoformat import datetime_fromisoformat

"""Alert Models"""

Expand Down Expand Up @@ -474,9 +476,13 @@ def __getitem__(self, item):
try:
return super(Alert.Note, self).__getattribute__(Alert.Note.REMAPPED_NOTES_V6_TO_V7.get(item, item))
except AttributeError:
raise AttributeError("'{0}' object has no attribute '{1}'".format(self.__class__.__name__,
item))
# fall through to the rest of the logic...
pass

# try looking up via self._info, if we already have it.
if item in self._info:
return self._info[item]
else:
raise AttributeError("'{0}' object has no attribute '{1}'".format(self.__class__.__name__, item))

def __getattr__(self, item):
"""
Expand All @@ -495,9 +501,13 @@ def __getattr__(self, item):
item = Alert.Note.REMAPPED_NOTES_V6_TO_V7.get(item, item)
return super(Alert.Note, self).__getattr__(Alert.Note.REMAPPED_NOTES_V6_TO_V7.get(item, item))
except AttributeError:
raise AttributeError("'{0}' object has no attribute '{1}'".format(self.__class__.__name__,
item))
# fall through to the rest of the logic...
pass

# try looking up via self._info, if we already have it.
if item in self._info:
return self._info[item]
else:
raise AttributeError("'{0}' object has no attribute '{1}'".format(self.__class__.__name__, item))

def notes_(self, threat_note=False):
"""
Expand Down Expand Up @@ -765,9 +775,13 @@ def __getitem__(self, item):
try:
return super(Alert, self).__getattribute__(Alert.REMAPPED_ALERTS_V6_TO_V7.get(item, item))
except AttributeError:
raise AttributeError("'{0}' object has no attribute '{1}'".format(self.__class__.__name__,
item))
# fall through to the rest of the logic...
pass

# try looking up via self._info, if we already have it.
if item in self._info:
return self._info[item]
else:
raise AttributeError("'{0}' object has no attribute '{1}'".format(self.__class__.__name__, item))

def __getattr__(self, item):
"""
Expand Down Expand Up @@ -1388,9 +1402,15 @@ def _create_valid_time_filter(self, kwargs):
etime = kwargs["end"]
try:
if isinstance(stime, str):
stime = datetime_fromisoformat(stime)
if sys.version_info < (3, 11):
stime = datetime_fromisoformat(stime)
else:
stime = datetime.datetime.fromisoformat(stime)
if isinstance(etime, str):
etime = datetime_fromisoformat(etime)
if sys.version_info < (3, 11):
etime = datetime_fromisoformat(etime)
else:
etime = datetime.datetime.fromisoformat(etime)
if isinstance(stime, datetime.datetime) and isinstance(etime, datetime.datetime):
time_filter = {"start": stime.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"end": etime.strftime("%Y-%m-%dT%H:%M:%S.%fZ")}
Expand Down
15 changes: 12 additions & 3 deletions src/cbc_sdk/platform/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@
"""

import datetime
import sys

from cbc_sdk.base import (UnrefreshableModel, BaseQuery, QueryBuilder, QueryBuilderSupportMixin,
CriteriaBuilderSupportMixin, ExclusionBuilderSupportMixin, IterableQueryMixin,
AsyncQueryMixin)
from cbc_sdk.errors import ApiError
from cbc_sdk.platform.jobs import Job

from backports._datetime_fromisoformat import datetime_fromisoformat
if sys.version_info < (3, 11):
from backports._datetime_fromisoformat import datetime_fromisoformat


"""Model Class"""
Expand Down Expand Up @@ -171,9 +174,15 @@ def _create_valid_time_filter(kwargs):
etime = kwargs["end"]
try:
if isinstance(stime, str):
stime = datetime_fromisoformat(stime)
if sys.version_info < (3, 11):
stime = datetime_fromisoformat(stime)
else:
stime = datetime.datetime.fromisoformat(stime)
if isinstance(etime, str):
etime = datetime_fromisoformat(etime)
if sys.version_info < (3, 11):
etime = datetime_fromisoformat(etime)
else:
etime = datetime.datetime.fromisoformat(etime)
if isinstance(stime, datetime.datetime) and isinstance(etime, datetime.datetime):
time_filter = {"start": stime.strftime("%Y-%m-%dT%H:%M:%S.%fZ"),
"end": etime.strftime("%Y-%m-%dT%H:%M:%S.%fZ")}
Expand Down
6 changes: 3 additions & 3 deletions src/tests/unit/platform/test_alertsv7_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ def on_post(url, body, **kwargs):
.add_criteria("device_target_value", ["HIGH"]).add_criteria("threat_id", ["B0RG"]) \
.add_criteria("workflow_status", ["OPEN"]).sort_by("name", "DESC")
a = query.one()
assert a.id == "S0L0"
assert a.org_key == "test"
assert a.threat_id == "B0RG"
assert a["id"] == "S0L0"
assert a["org_key"] == "test"
assert a["threat_id"] == "B0RG"
assert a.workflow["status"] == "OPEN"


Expand Down

0 comments on commit 1c754c9

Please sign in to comment.