Skip to content

Commit 9d83843

Browse files
authored
Merge pull request #510 from carbonblack/release-1.5.2
CBAPI-5202: Release 1.5.2 merge to master
2 parents 538ff13 + f37dbfd commit 9d83843

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3841
-3516
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# VMware Carbon Black Cloud Python SDK
22

3-
**Latest Version:** 1.5.1
3+
**Latest Version:** 1.5.2
44
<br>
5-
**Release Date:** January 30, 2024
5+
**Release Date:** May 1, 2024
66

77
[![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)
88
[![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)

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.1
1+
1.5.2

docs/audit-log.rst

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,58 @@ In the Carbon Black Cloud, *audit logs* are records of various organization-wide
88
* Creation of connectors
99
* LiveResponse events
1010

11-
The Audit Log API allows these records to be retrieved in JSON format, sorted by time in ascending order
12-
(oldest records come first). The API call returns only *new* audit log records that have been added since
13-
the last time the call was made using the same API Key ID. Once records have been returned, they are *cleared*
14-
and will not be included in future responses.
15-
16-
When reading audit log records using a *new* API key, the queue for reading audit logs will begin three days
17-
earlier. This may lead to duplicate data if audit log records were previously read with a different API key.
18-
19-
.. note::
20-
Future versions of the Carbon Black Cloud and this SDK will support a more flexible API for finding and retrieving
21-
audit log records. This Guide will be rewritten to cover this when it is incorporated into the SDK.
11+
The Audit Log API allows these records to be retrieved as objects, either by getting the most recent audit logs, or
12+
through a flexible search API.
2213

2314
API Permissions
2415
---------------
2516

26-
To call this API function, use a custom API key created with a role containing the ``READ`` permission on
17+
To call the Audit Log APIs, use a custom API key created with a role containing the ``READ`` permission on
2718
``org.audits``.
2819

29-
Example of API Usage
30-
--------------------
20+
Retrieving Queued Audit Log Events
21+
----------------------------------
22+
23+
The Carbon Black Cloud maintains a queue of audit log events for each API key, which is initialized with the last three
24+
days of audit logs when the API key is created. This demonstrates how to read audit log events from the queue::
25+
26+
>>> from cbc_sdk import CBCloudAPI
27+
>>> from cbc_sdk.platform import AuditLog
28+
>>> api = CBCloudAPI(profile='sample')
29+
>>> events = AuditLog.get_queued_auditlogs(api)
30+
>>> for event in events:
31+
... print(f"{event.create_time}: {event.actor} {event.description}")
32+
33+
Once audit log events have been retrieved from the queue, they are "cleared" and will not be included in future
34+
responses to a ``get_queued_auditlogs()`` call.
35+
36+
.. note::
37+
Reading queued audit log events using *different* API keys may lead to duplicate data.
38+
39+
Searching for Audit Log Events
40+
------------------------------
41+
42+
Audit log events may be searched for in a manner similar to other objects within the SDK::
3143

32-
.. code-block:: python
44+
# assume "api" contains our CBCloudAPI reference as above
45+
>>> query = api.select(AuditLog).where("description:Logged in")
46+
>>> query.sort_by("create_time")
47+
>>> for event in query:
48+
... print(f"{event.create_time}: {event.actor} {event.description}")
3349

34-
import time
35-
from cbc_sdk import CBCloudAPI
36-
from cbc_sdk.platform import AuditLog
50+
See also the :ref:`searching-guide` guide page for a more detailed discussion of searching.
3751

38-
cb = CBCloudAPI(profile='yourprofile')
39-
running = True
52+
Exporting Audit Log Events
53+
--------------------------
4054

41-
while running:
42-
events_list = AuditLog.get_auditlogs(cb)
43-
for event in events_list:
44-
print(f"Event {event['eventId']}:")
45-
for (k, v) in event.items():
46-
print(f"\t{k}: {v}")
47-
# omitted: decide whether running should be set to False
48-
if running:
49-
time.sleep(5)
55+
Any search query may also be used to export audit log data, in either CSV or JSON format::
5056

57+
# assume "api" contains our CBCloudAPI reference as above
58+
>>> query = api.select(AuditLog).where("description:Logged in")
59+
>>> query.sort_by("create_time")
60+
>>> job = query.export("csv")
61+
>>> result = job.await_completion().result()
62+
>>> print(result)
5163

52-
Check out the example script ``audit_log.py`` in the examples/platform directory on `GitHub <https://github.com/carbonblack/carbon-black-cloud-sdk-python>`_.
64+
Note that the ``export()`` call returns a ``Job`` object, as exports can take some time to complete. The results may
65+
be obtained from the ``Job`` when the export process is completed.

docs/authentication.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Authentication
44
==============
55

6-
76
Carbon Black Cloud APIs require authentication to secure your data.
87

98
There are several methods for authentication listed below. Every method requires
@@ -52,9 +51,6 @@ Store the credential with a profile name, and reference the profile when creatin
5251

5352
For more examples on Live Response, check :doc:`live-response`
5453

55-
56-
57-
5854
Authentication Methods
5955
----------------------
6056

@@ -117,8 +113,9 @@ Authentication Methods
117113
With a File
118114
^^^^^^^^^^^
119115
Credentials may be supplied in a file that resembles a Windows ``.INI`` file in structure, which allows for
120-
multiple "profiles" or sets of credentials to be supplied in a single file. The file format is backwards compatible with
121-
CBAPI, so older files can continue to be used.
116+
multiple "profiles" or sets of credentials to be supplied in a single file. The file format is backwards compatible
117+
with CBAPI, so older files can continue to be used. The file must be encoded as UTF-8, or as UTF-16 using either
118+
big-endian or little-endian format.
122119

123120
**Example of a credentials file containing two profiles**
124121

docs/cbc_sdk.workload.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Workload Package
22
*****************
33

4+
CIS Benchmarks
5+
-----------------------------------------
6+
7+
.. automodule:: cbc_sdk.workload.compliance_assessment
8+
:members:
9+
:inherited-members:
10+
:show-inheritance:
11+
412
NSX Remediation Module
513
-----------------------------------------
614

docs/changelog.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,43 @@
11
Changelog
22
================================
3+
CBC SDK 1.5.2 - Released May 1, 2024
4+
------------------------------------
5+
6+
New Features:
7+
8+
* Enhanced Audit Log support with search and export capabilities
9+
* CIS Benchmarking:
10+
11+
* Schedule compliance scans
12+
* Search, create, update, and delete benchmark sets
13+
* Search and modify benchmark rules within a benchmark set
14+
* Search and export device summaries for benchmark sets
15+
* Enable, disable, and trigger reassessment on benchmark sets or individual devices
16+
* Search benchmark set summaries
17+
* Search and export device compliance summaries
18+
* Search and export rule compliance summaries
19+
* Search rule results for devices
20+
* Get and acknowledge compliance bundle version updates, show differences, get rule info
21+
22+
Updates:
23+
24+
* Added `collapse_field` parameter for process searches
25+
* Added an exponential backoff for polling of Job completion status
26+
* Added rule configurations for event reporting and sensor operation exclusions
27+
28+
Bug Fixes:
29+
30+
* Fixed implementation of iterable queries for consistency across the SDK
31+
* Fixed parsing of credential files that are encoded in UTF-16
32+
* Fixed processing of Job so that it doesn't rely on an API call that doesn't give proper answers
33+
* Fixed missing properties in Process
34+
35+
Documentation:
36+
37+
* Fixed documentation for Alert and Process to include links to the Developer Network field descriptions
38+
* New example script for identifying devices that have checked in but have not sent any events
39+
* Added guide page for Devices including searching and actions
40+
341
CBC SDK 1.5.1 - Released January 30, 2024
442
-----------------------------------------
543

docs/compliance.rst

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
Compliance Benchmarks
2+
======
3+
4+
CIS benchmarks are configuration guidelines published by the Center for Internet Security.
5+
The CIS Benchmark enable configuration and retrieval of Benchmark Sets and Rules in Carbon Black Cloud, and
6+
retrieval of the results from scans performed using these Rules.
7+
8+
For more information on CIS Benchmarks, see the `Center for Internet Security <https://www.cisecurity.org/cis-benchmarks>`_.
9+
CIS benchmarks contain over 100 configuration guidelines created by a global community of cybersecurity experts to safeguard
10+
various systems against attacks targeting configuration vulnerabilities.
11+
12+
You can use all the operations shown in the API, such as retrieving, filtering, reaccessing and enabling/disabling the benchmark rules.
13+
You can locate the full list of operations and attributes in the :py:mod:`ComplianceBenchmark() <cbc_sdk.workload.compliance_assessment.ComplianceBenchmark>` class.
14+
15+
Resources
16+
---------
17+
* `API Documentation <https://developer.carbonblack.com/reference/carbon-black-cloud/workload-protection/latest/cis-benchmark-api>`_ on Developer Network
18+
* `User Guide <https://docs.vmware.com/en/VMware-Carbon-Black-Cloud/services/carbon-black-cloud-user-guide/GUID-47645D2C-A093-47C8-B4CA-D6F685392733.html>`_
19+
20+
Retrieve Compliance Benchmarks
21+
---------------
22+
23+
By using the following the example, you can retrieve the list of supported benchmarks
24+
25+
.. code-block:: python
26+
27+
>>> from cbc_sdk import CBCloudAPI
28+
>>> from cbc_sdk.workload import ComplianceBenchmark
29+
>>> api = CBCloudAPI(profile='sample')
30+
>>> benchmark_query = api.select(ComplianceBenchmark)
31+
>>> for benchmark in benchmark_query:
32+
>>> print(benchmark)
33+
ComplianceBenchmark object, bound to https://defense-test03.cbdtest.io.
34+
-------------------------------------------------------------------------------
35+
36+
bundle_name: CIS Compliance - Microsoft Windows Server
37+
create_time: 2023-03-20T13:44:10.923039Z
38+
created_by: emuthu+csr@carbonblack.com
39+
enabled: True
40+
id: b7d1b266-d899-4e28-bae6-7619019447ba
41+
name: CIS Windows Server Retail application Prod
42+
os_family: WINDOWS_SERVER
43+
release_time: 2023-07-10T13:55:59.274881Z
44+
supported_os_info: [list:5 items]:
45+
[0]: {'os_metadata_id': '1', 'os_type': 'WINDOWS', '...
46+
[1]: {'os_metadata_id': '2', 'os_type': 'WINDOWS', '...
47+
[2]: {'os_metadata_id': '3', 'os_type': 'WINDOWS', '...
48+
[...]
49+
type: Custom
50+
update_time: 2024-04-15T21:24:43.283032Z
51+
updated_by:
52+
version: 1.0.0.4
53+
54+
55+
Modify Compliance Benchmarks Schedule
56+
---------------
57+
58+
By using the following the example, you can get and set the benchmark assessment schedule
59+
60+
.. code-block:: python
61+
62+
>>> from cbc_sdk import CBCloudAPI
63+
>>> from cbc_sdk.workload import ComplianceBenchmark
64+
>>> api = CBCloudAPI(profile='sample')
65+
>>> ComplianceBenchmark.set_compliance_schedule(api, "RRULE:FREQ=DAILY;BYHOUR=17;BYMINUTE=30;BYSECOND=0", "UTC")
66+
>>> schedule = ComplianceBenchmark.get_compliance_schedule(api)
67+
>>> print(schedule)
68+
{
69+
"scan_schedule": "FREQ=WEEKLY;BYDAY=TU;BYHOUR=11;BYMINUTE=30;BYSECOND=0",
70+
"scan_timezone": "UTC"
71+
}
72+
73+
74+
Reassess Compliance Benchmarks
75+
---------------
76+
77+
By using the following the example, you can reasses a benchmark
78+
79+
.. code-block:: python
80+
81+
>>> from cbc_sdk import CBCloudAPI
82+
>>> from cbc_sdk.workload import ComplianceBenchmark
83+
>>> api = CBCloudAPI(profile='sample')
84+
>>> benchmark = api.select(ComplianceBenchmark).first()
85+
>>> # Execute for all devices matching benchmark
86+
>>> benchmark.execute_action("REASSESS")
87+
>>> # Execute for a specific set of devices
88+
>>> benchmark.execute_action("REASSESS", [ 1, 2, 3 ])
89+
90+
91+
Device Compliance Summary
92+
---------------
93+
94+
By using the following the example, you can fetch the compliance percentage for each device assessed by the Compliance Benchmark
95+
96+
.. code-block:: python
97+
98+
>>> from cbc_sdk import CBCloudAPI
99+
>>> from cbc_sdk.workload import ComplianceBenchmark
100+
>>> api = CBCloudAPI(profile='sample')
101+
>>> benchmark = api.select(ComplianceBenchmark).first()
102+
>>> summaries = benchmark.get_device_compliances()
103+
>>> print(summaries[0])
104+
{
105+
"device_id": 39074613,
106+
"device_name": "Example\\Win2022",
107+
"os_version": "Windows Server 2022 x64",
108+
"compliance_percentage": 93,
109+
"last_assess_time": "2024-04-16T00:00:00.014765Z",
110+
"excluded_on": None,
111+
"excluded_by": None,
112+
"reason": None,
113+
"deployment_type": "WORKLOAD"
114+
}

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
# -- Project information -----------------------------------------------------
2020

2121
project = 'Carbon Black Cloud Python SDK'
22-
copyright = '2020-2023 VMware Carbon Black'
22+
copyright = '2020-2024 VMware Carbon Black'
2323
author = 'Developer Relations'
2424

2525
# The full version, including alpha/beta/rc tags
26-
release = '1.5.1'
26+
release = '1.5.2'
2727

2828

2929
# -- General configuration ---------------------------------------------------

0 commit comments

Comments
 (0)