Skip to content

Commit

Permalink
Updates for API module
Browse files Browse the repository at this point in the history
APP-4076 - [TcEx] Added support for System type App
APP-4174 - [API] Updated API module for TC 7.3 changes
  • Loading branch information
bsummers-tc authored Sep 19, 2023
1 parent a35d6e6 commit 76ca4fd
Show file tree
Hide file tree
Showing 29 changed files with 358 additions and 122 deletions.
6 changes: 6 additions & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# Release Notes

### 3.0.10

- APP-4076 - [Input] Added support for System type App
- APP-4174 - [API] Updated API module for TC 7.3 changes

### 3.0.9

- APP-3943 - [API] Update Transforms to Support Email Group Type
- APP-3981 - [API] Updated v3 gen body to allow 0 and false in body
- APP-3972 - [Logging] Add lock to sensitive filter to fix concurrent update exception
Expand Down
2 changes: 1 addition & 1 deletion tcex/__metadata__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
__license__ = 'Apache License, Version 2'
__package_name__ = 'tcex'
__url__ = 'https://github.com/ThreatConnect-Inc/tcex'
__version__ = '3.0.9'
__version__ = '3.0.10'
__download_url__ = f'https://github.com/ThreatConnect-Inc/tcex/tarball/{__version__}'
16 changes: 8 additions & 8 deletions tcex/api/tc/v3/_gen/_gen_model_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,24 +355,24 @@ def gen_model_fields(self) -> str:
_model.append(f'''{self.i2}methods={prop.extra.methods},''')

# max_length
if prop.max_length is not None:
_model.append(f'''{self.i2}max_length={prop.max_length},''')
# if prop.max_length is not None:
# _model.append(f'''{self.i2}max_length={prop.max_length},''')

# max_size
# if field_max_size is not None:
# _model.append(f'''{self.i2}max_items={field_max_size},''')

# max_value
if prop.max_value is not None:
_model.append(f'''{self.i2}maximum={prop.max_value},''')
# if prop.max_value is not None:
# _model.append(f'''{self.i2}maximum={prop.max_value},''')

# min_length
if prop.min_length is not None:
_model.append(f'''{self.i2}min_length={prop.min_length},''')
# if prop.min_length is not None:
# _model.append(f'''{self.i2}min_length={prop.min_length},''')

# min_value
if prop.min_value is not None:
_model.append(f'''{self.i2}minimum={prop.min_value},''')
# if prop.min_value is not None:
# _model.append(f'''{self.i2}minimum={prop.min_value},''')

# readOnly/allow_mutation setting
_model.append(f'''{self.i2}read_only={prop.read_only},''')
Expand Down
1 change: 1 addition & 0 deletions tcex/api/tc/v3/_gen/models/_property_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def __process_dict_types(cls, pm: 'PropertyModel', extra: Dict[str, str]):
'Links',
'Map',
'ValidationRule',
'Strings',
'WhoIs',
]
if pm.type in types:
Expand Down
6 changes: 0 additions & 6 deletions tcex/api/tc/v3/artifacts/artifact_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,6 @@ class ArtifactModel(
None,
description='The field name for the artifact.',
methods=['POST', 'PUT'],
max_length=100,
min_length=0,
read_only=False,
title='fieldName',
)
Expand Down Expand Up @@ -216,17 +214,13 @@ class ArtifactModel(
None,
description='The **source** for the Artifact.',
methods=['POST', 'PUT'],
max_length=100,
min_length=0,
read_only=False,
title='source',
)
summary: Optional[str] = Field(
None,
description='The **summary** for the Artifact.',
methods=['POST', 'PUT'],
max_length=500,
min_length=1,
read_only=False,
title='summary',
)
Expand Down
1 change: 0 additions & 1 deletion tcex/api/tc/v3/case_attributes/case_attribute_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ class CaseAttributeModel(
None,
description='The attribute value.',
methods=['POST', 'PUT'],
min_length=1,
read_only=False,
title='value',
)
Expand Down
6 changes: 0 additions & 6 deletions tcex/api/tc/v3/cases/case_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ class CaseModel(
None,
description='The description of the Case.',
methods=['POST', 'PUT'],
max_length=1500,
min_length=0,
read_only=False,
title='description',
)
Expand All @@ -204,8 +202,6 @@ class CaseModel(
None,
description='The name of the Case.',
methods=['POST', 'PUT'],
max_length=255,
min_length=1,
read_only=False,
title='name',
)
Expand Down Expand Up @@ -303,8 +299,6 @@ class CaseModel(
None,
description='The **xid** for the Case.',
methods=['POST'],
max_length=100,
min_length=10,
read_only=False,
title='xid',
)
Expand Down
1 change: 0 additions & 1 deletion tcex/api/tc/v3/group_attributes/group_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class GroupAttribute(ObjectABC):
Args:
default (bool, kwargs): A flag indicating that this is the default attribute of its type
within the object. Only applies to certain attribute and data types.
group (Group, kwargs): Details of group associated with attribute.
group_id (int, kwargs): Group associated with attribute.
pinned (bool, kwargs): A flag indicating that the attribute has been noted for importance.
security_labels (SecurityLabels, kwargs): A list of Security Labels corresponding to the
Expand Down
5 changes: 2 additions & 3 deletions tcex/api/tc/v3/group_attributes/group_attribute_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ class GroupAttributeModel(
)
group: Optional['GroupModel'] = Field(
None,
allow_mutation=False,
description='Details of group associated with attribute.',
methods=['POST'],
read_only=False,
read_only=True,
title='group',
)
group_id: Optional[int] = Field(
Expand Down Expand Up @@ -152,7 +152,6 @@ class GroupAttributeModel(
None,
description='The attribute value.',
methods=['POST', 'PUT'],
min_length=1,
read_only=False,
title='value',
)
Expand Down
7 changes: 6 additions & 1 deletion tcex/api/tc/v3/groups/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ class Group(ObjectABC):
due_date (str, kwargs): The date and time that the Task is due.
escalation_date (str, kwargs): The escalation date and time.
event_date (str, kwargs): The date and time that the incident or event was first created.
external_date_added (str, kwargs): The date and time that the item was first created
externally.
external_date_expires (str, kwargs): The date and time the item expires externally.
external_last_modified (str, kwargs): The date and time the item was modified externally.
file_name (str, kwargs): The document or signature file name.
file_text (str, kwargs): The signature file text.
file_type (str, kwargs): The signature file type.
first_seen (str, kwargs): The date and time that the campaign was first created.
first_seen (str, kwargs): The date and time that the item was first seen.
from_ (str, kwargs): The email From field.
header (str, kwargs): The email Header field.
last_seen (str, kwargs): The date and time that the item was last seen.
malware (bool, kwargs): Is the document malware?
name (str, kwargs): The name of the group.
owner_id (int, kwargs): The id of the Organization, Community, or Source that the item
Expand Down
69 changes: 69 additions & 0 deletions tcex/api/tc/v3/groups/group_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,54 @@ def event_date(self, operator: Enum, event_date: str):
event_date = self.utils.any_to_datetime(event_date).strftime('%Y-%m-%d %H:%M:%S')
self._tql.add_filter('eventDate', operator, event_date, TqlType.STRING)

def external_date_added(self, operator: Enum, external_date_added: str):
"""Filter External Date Added based on **externalDateAdded** keyword.
Args:
operator: The operator enum for the filter.
external_date_added: The date and time that the group was first created externally.
"""
external_date_added = self.utils.any_to_datetime(external_date_added).strftime(
'%Y-%m-%d %H:%M:%S'
)
self._tql.add_filter('externalDateAdded', operator, external_date_added, TqlType.STRING)

def external_date_expires(self, operator: Enum, external_date_expires: str):
"""Filter External Date Expires based on **externalDateExpires** keyword.
Args:
operator: The operator enum for the filter.
external_date_expires: The date and time the group expires externally.
"""
external_date_expires = self.utils.any_to_datetime(external_date_expires).strftime(
'%Y-%m-%d %H:%M:%S'
)
self._tql.add_filter('externalDateExpires', operator, external_date_expires, TqlType.STRING)

def external_last_modified(self, operator: Enum, external_last_modified: str):
"""Filter External Last Modified based on **externalLastModified** keyword.
Args:
operator: The operator enum for the filter.
external_last_modified: The date and time the group was modified externally.
"""
external_last_modified = self.utils.any_to_datetime(external_last_modified).strftime(
'%Y-%m-%d %H:%M:%S'
)
self._tql.add_filter(
'externalLastModified', operator, external_last_modified, TqlType.STRING
)

def first_seen(self, operator: Enum, first_seen: str):
"""Filter First Seen based on **firstSeen** keyword.
Args:
operator: The operator enum for the filter.
first_seen: The date and time that the group was first seen.
"""
first_seen = self.utils.any_to_datetime(first_seen).strftime('%Y-%m-%d %H:%M:%S')
self._tql.add_filter('firstSeen', operator, first_seen, TqlType.STRING)

def generated_report(self, operator: Enum, generated_report: bool):
"""Filter Generated (Report) based on **generatedReport** keyword.
Expand Down Expand Up @@ -245,6 +293,17 @@ def has_intel_query(self, operator: Enum, has_intel_query: int):
"""
self._tql.add_filter('hasIntelQuery', operator, has_intel_query, TqlType.INTEGER)

def has_intel_requirement(self, operator: Enum, has_intel_requirement: int):
"""Filter Associated Intel Requirement based on **hasIntelRequirement** keyword.
Args:
operator: The operator enum for the filter.
has_intel_requirement: A nested query for association to intel requirements.
"""
self._tql.add_filter(
'hasIntelRequirement', operator, has_intel_requirement, TqlType.INTEGER
)

@property
def has_security_label(self):
"""Return **SecurityLabel** for further filtering."""
Expand Down Expand Up @@ -313,6 +372,16 @@ def last_modified(self, operator: Enum, last_modified: str):
last_modified = self.utils.any_to_datetime(last_modified).strftime('%Y-%m-%d %H:%M:%S')
self._tql.add_filter('lastModified', operator, last_modified, TqlType.STRING)

def last_seen(self, operator: Enum, last_seen: str):
"""Filter Last Seen based on **lastSeen** keyword.
Args:
operator: The operator enum for the filter.
last_seen: The date and time that the group was last seen.
"""
last_seen = self.utils.any_to_datetime(last_seen).strftime('%Y-%m-%d %H:%M:%S')
self._tql.add_filter('lastSeen', operator, last_seen, TqlType.STRING)

def owner(self, operator: Enum, owner: int):
"""Filter Owner ID based on **owner** keyword.
Expand Down
44 changes: 29 additions & 15 deletions tcex/api/tc/v3/groups/group_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ class GroupModel(
applies_to=['Email'],
description='The email Body.',
methods=['POST', 'PUT'],
max_length=65535,
min_length=0,
read_only=False,
title='body',
)
Expand Down Expand Up @@ -204,14 +202,33 @@ class GroupModel(
read_only=False,
title='eventDate',
)
external_date_added: Optional[datetime] = Field(
None,
description='The date and time that the item was first created externally.',
methods=['POST', 'PUT'],
read_only=False,
title='externalDateAdded',
)
external_date_expires: Optional[datetime] = Field(
None,
description='The date and time the item expires externally.',
methods=['POST', 'PUT'],
read_only=False,
title='externalDateExpires',
)
external_last_modified: Optional[datetime] = Field(
None,
description='The date and time the item was modified externally.',
methods=['POST', 'PUT'],
read_only=False,
title='externalLastModified',
)
file_name: Optional[str] = Field(
None,
applies_to=['Document', 'Report', 'Signature'],
conditional_required=['Document', 'Report', 'Signature'],
description='The document or signature file name.',
methods=['POST', 'PUT'],
max_length=255,
min_length=0,
read_only=False,
title='fileName',
)
Expand Down Expand Up @@ -241,8 +258,7 @@ class GroupModel(
)
first_seen: Optional[datetime] = Field(
None,
applies_to=['Campaign'],
description='The date and time that the campaign was first created.',
description='The date and time that the item was first seen.',
methods=['POST', 'PUT'],
read_only=False,
title='firstSeen',
Expand All @@ -253,8 +269,6 @@ class GroupModel(
applies_to=['Email'],
description='The email From field.',
methods=['POST', 'PUT'],
max_length=100,
min_length=0,
read_only=False,
title='from',
)
Expand All @@ -270,8 +284,6 @@ class GroupModel(
applies_to=['Email'],
description='The email Header field.',
methods=['POST', 'PUT'],
max_length=65535,
min_length=0,
read_only=False,
title='header',
)
Expand All @@ -288,6 +300,13 @@ class GroupModel(
read_only=True,
title='lastModified',
)
last_seen: Optional[datetime] = Field(
None,
description='The date and time that the item was last seen.',
methods=['POST', 'PUT'],
read_only=False,
title='lastSeen',
)
legacy_link: Optional[str] = Field(
None,
allow_mutation=False,
Expand All @@ -307,8 +326,6 @@ class GroupModel(
None,
description='The name of the group.',
methods=['POST', 'PUT'],
max_length=100,
min_length=0,
read_only=False,
title='name',
)
Expand Down Expand Up @@ -424,8 +441,6 @@ class GroupModel(
applies_to=['Email'],
description='The email Subject section.',
methods=['POST', 'PUT'],
max_length=255,
min_length=0,
read_only=False,
title='subject',
)
Expand All @@ -451,7 +466,6 @@ class GroupModel(
None,
description='The **type** for the Group.',
methods=['POST', 'PUT'],
min_length=1,
read_only=False,
title='type',
)
Expand Down
1 change: 0 additions & 1 deletion tcex/api/tc/v3/indicator_attributes/indicator_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class IndicatorAttribute(ObjectABC):
Args:
default (bool, kwargs): A flag indicating that this is the default attribute of its type
within the object. Only applies to certain attribute and data types.
indicator (Indicator, kwargs): Details of indicator associated with attribute.
indicator_id (int, kwargs): Indicator associated with attribute.
pinned (bool, kwargs): A flag indicating that the attribute has been noted for importance.
security_labels (SecurityLabels, kwargs): A list of Security Labels corresponding to the
Expand Down
Loading

0 comments on commit 76ca4fd

Please sign in to comment.