Skip to content

Commit 260019f

Browse files
authored
Bugfix/security-data flattened checkpoint on v2 events (#399)
* fix v2 checkpoint bug when format is json * fix v2 checkpoint bug when format is json * fix some new flake8 errors * style
1 parent 24c11c9 commit 260019f

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
The intended audience of this file is for py42 consumers -- as such, changes that don't affect
99
how a consumer would use the library (e.g. adding unit tests, updating documentation, etc) are not captured here.
1010

11+
## 1.16.4 - 2023-01-27
12+
13+
### Fixed
14+
15+
- Bug in `security-data search|send-to` where using `--format json` and a checkpoint raised an error when configured for V2 file events.
16+
1117
## 1.16.3 - 2022-12-08
1218

1319
### Fixed

Diff for: setup.cfg

+2
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ ignore =
2929
W503
3030
# exception chaining
3131
B904
32+
# manual quoting
33+
B907
3234
# up to 88 allowed by bugbear B950
3335
max-line-length = 80

Diff for: src/code42cli/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.16.3"
1+
__version__ = "1.16.4"

Diff for: src/code42cli/cmds/securitydata.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,17 @@ def search(
459459
"riskSeverity",
460460
]
461461

462+
flatten = format in (OutputFormat.TABLE, OutputFormat.CSV)
463+
462464
if use_checkpoint:
463465
cursor = _get_file_event_cursor_store(state.profile.name)
464466
checkpoint = _handle_timestamp_checkpoint(cursor.get(use_checkpoint), state)
465467

466468
if state.profile.use_v2_file_events == "True":
467469

468470
def checkpoint_func(event):
469-
cursor.replace(use_checkpoint, event["event.id"])
471+
event_id = event["event.id"] if flatten else event["event"]["id"]
472+
cursor.replace(use_checkpoint, event_id)
470473

471474
else:
472475

@@ -477,7 +480,6 @@ def checkpoint_func(event):
477480
checkpoint = checkpoint_func = None
478481

479482
query = _construct_query(state, begin, end, saved_search, advanced_query, or_query)
480-
flatten = format in (OutputFormat.TABLE, OutputFormat.CSV)
481483
dfs = _get_all_file_events(state, query, checkpoint, flatten)
482484
formatter = FileEventsOutputFormatter(format, checkpoint_func=checkpoint_func)
483485
# sending to pager when checkpointing can be inaccurate due to pager buffering, so disallow pager

Diff for: tests/test_config.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_create_profile_when_given_default_name_does_not_create(
151151
self, config_parser_for_create
152152
):
153153
accessor = ConfigAccessor(config_parser_for_create)
154-
with pytest.raises(Exception):
154+
with pytest.raises(NoConfigProfileError):
155155
accessor.create_profile(
156156
ConfigAccessor.DEFAULT_VALUE, "foo", "bar", False, False, False
157157
)
@@ -201,7 +201,7 @@ def test_update_profile_when_no_profile_exists_raises_exception(
201201
self, config_parser_for_multiple_profiles
202202
):
203203
accessor = ConfigAccessor(config_parser_for_multiple_profiles)
204-
with pytest.raises(Exception):
204+
with pytest.raises(NoConfigProfileError):
205205
accessor.update_profile("Non-existent Profile")
206206

207207
def test_update_profile_updates_profile(self, config_parser_for_multiple_profiles):

0 commit comments

Comments
 (0)