From 783e0b44607d32beccf240d37e77dd2be76763df Mon Sep 17 00:00:00 2001 From: Bracey Summers Date: Thu, 6 Apr 2023 17:44:18 -0500 Subject: [PATCH] APP-3898 - updated release notes; addressed failing test cases; minor update to V3 create/delete/update methods --- pyproject.toml | 1 + release_notes.md | 12 ++++++++---- tcex/api/tc/v3/object_abc.py | 3 +++ tests/api/tc/v3/groups/test_group_interface.py | 2 +- .../api/tc/v3/indicators/test_indicator_snippets.py | 6 +++--- tests/api/tc/v3/v3_helpers.py | 8 ++++---- 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fff425600..2650805c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -27,6 +27,7 @@ disable = "C0103,C0302,C0330,C0415,E0401,R0205,R0801,R0902,R0903,R0904,R0912,R09 extension-pkg-whitelist = "pydantic" [tool.pytest.ini_options] +# addopts = "-n auto" junit_family = "xunit2" testpaths = [ "tests", diff --git a/release_notes.md b/release_notes.md index 84105dc59..5e879a485 100644 --- a/release_notes.md +++ b/release_notes.md @@ -2,10 +2,14 @@ ### 3.0.8 -- APP-3899 [CLI] Updated error handling on CLI when downloading template files -- APP-3900 [CLI] Updated proxy support for CLI -- APP-3906 [CLI] Don't create requirements.lock file if any errors occurred during tcex deps. - APP-3922 [API] Update TI Transforms to treat event_date field on some group types as a datetime transform. +- APP-3899 - [CLI] Updated error handling on CLI when downloading template files +- APP-3900 - [CLI] Updated proxy support for CLI +- APP-3906 - [CLI] Updated Deps command to no create the requirements.lock file on error +- APP-3922 - [API] Updated TI Transforms to treat event_date field on some group types as a datetime transform +- APP-3937 - [TcEx] Pinned dependencies to prevent pickup up packages that dropped support for Python 3.6 +- APP-3938 - [API] Updated TI Transforms to support active field on indicators +- APP-3939 - [API] Updated TI Transforms to support Security Labels +- APP-3940 - [API] Updated `api.tc.v3` module to support changes in TC 7.1 ### 3.0.7 diff --git a/tcex/api/tc/v3/object_abc.py b/tcex/api/tc/v3/object_abc.py index c2f253989..254e96701 100644 --- a/tcex/api/tc/v3/object_abc.py +++ b/tcex/api/tc/v3/object_abc.py @@ -162,6 +162,8 @@ def create(self, params: Optional[dict] = None) -> 'Response': """ method = 'POST' body = self.model.gen_body_json(method=method) + + params = self.gen_params(params or {}) self._request( method, self.url(method), @@ -345,6 +347,7 @@ def update(self, mode: Optional[str] = None, params: Optional[dict] = None) -> ' # validate an id is available self._validate_id(unique_id, self.url(method)) + params = self.gen_params(params or {}) self._request( method, self.url(method, unique_id=unique_id), diff --git a/tests/api/tc/v3/groups/test_group_interface.py b/tests/api/tc/v3/groups/test_group_interface.py index 3b48d178f..999b4d332 100644 --- a/tests/api/tc/v3/groups/test_group_interface.py +++ b/tests/api/tc/v3/groups/test_group_interface.py @@ -197,7 +197,7 @@ def test_victim_asset_associations(self): ) staged_victim.stage_victim_asset(asset) - staged_victim.update(params={'owner': 'TCI'}) + staged_victim.update(params={'owner': 'TCI', 'fields': ['_all_']}) assert asset.as_entity.get('type') == 'Victim Asset : EmailAddress' assert asset.as_entity.get('value') == 'Trojan : malware@example.com' diff --git a/tests/api/tc/v3/indicators/test_indicator_snippets.py b/tests/api/tc/v3/indicators/test_indicator_snippets.py index 73b84cafa..140b0a491 100644 --- a/tests/api/tc/v3/indicators/test_indicator_snippets.py +++ b/tests/api/tc/v3/indicators/test_indicator_snippets.py @@ -296,7 +296,7 @@ def test_add_indicator_file_actions(self): # Begin Snippet relationship_type = 'File DNS Query' indicator.stage_file_action({'relationship': relationship_type, 'indicator': host.model}) - indicator.update() + indicator.update(params={'fields': ['_all_']}) # End Snippet assert len(indicator.model.file_actions.data) == 1 @@ -323,7 +323,7 @@ def test_remove_indicator_file_actions(self): # [Stage Testing] - Stage an the file action to be removed indicator.stage_file_action({'relationship': relationship_type, 'indicator': host.model}) # [Delete Testing] - Delete the newly staged file action - indicator.update(mode='delete') + indicator.update(mode='delete', params={'fields': ['_all_']}) # End Snippet assert len(indicator.model.file_actions.data) == 1 @@ -349,7 +349,7 @@ def test_replace_indicator_file_actions(self): # [Stage Testing] - Stage an the file action. This will replace the existing file actions. indicator.stage_file_action({'relationship': relationship_type, 'indicator': host_2.model}) # [Replace Testing] - Replace all the current file actions with the new file actions. - indicator.update(mode='replace') + indicator.update(mode='replace', params={'fields': ['_all_']}) # End Snippet assert len(indicator.model.file_actions.data) == 1 diff --git a/tests/api/tc/v3/v3_helpers.py b/tests/api/tc/v3/v3_helpers.py index aa06e19ee..0d9f5ce63 100644 --- a/tests/api/tc/v3/v3_helpers.py +++ b/tests/api/tc/v3/v3_helpers.py @@ -409,7 +409,7 @@ def create_case(self, **kwargs): case.stage_task(self.v3.task(**task)) # create object - case.create(kwargs.get('params', {})) + case.create(params={'fields': ['_all_']}) # store case id for cleanup self._v3_objects.append(case) @@ -482,7 +482,7 @@ def create_group(self, type_: Optional[str] = 'Adversary', **kwargs): group.stage_tag(self.v3.tag(**tag)) # create object - group.create() + group.create(params={'fields': ['_all_']}) # store case id for cleanup self._v3_objects.append(group) @@ -589,7 +589,7 @@ def value_3_map(): indicator.stage_tag(self.v3.tag(**tag)) # create object - indicator.create() + indicator.create(params={'fields': ['_all_']}) # store case id for cleanup self._v3_objects.append(indicator) @@ -669,7 +669,7 @@ def create_victim(self, **kwargs): victim.stage_tag(self.v3.tag(**tag)) # create object - victim.create() + victim.create(params={'fields': ['_all_']}) # store case id for cleanup self._v3_objects.append(victim)