Skip to content

Commit c1a7b13

Browse files
authored
Added server check for STIX (demisto#12897)
* added server check for STIX * added rn
1 parent fff3604 commit c1a7b13

4 files changed

Lines changed: 65 additions & 3 deletions

File tree

Packs/Base/ReleaseNotes/1_11_5.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
#### Scripts
3+
##### CommonServerPython
4+
- Maintenance and stability enhancements.

Packs/Base/Scripts/CommonServerPython/CommonServerPython.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __del__(self):
6666
CONTENT_RELEASE_VERSION = '0.0.0'
6767
CONTENT_BRANCH_NAME = 'master'
6868
IS_PY3 = sys.version_info[0] == 3
69-
69+
STIX_PREFIX = "STIX "
7070
# pylint: disable=undefined-variable
7171

7272
ZERO = timedelta(0)
@@ -402,6 +402,22 @@ def ip_to_indicator_type(ip):
402402
else:
403403
return None
404404

405+
@staticmethod
406+
def indicator_type_by_server_version(indicator_type):
407+
"""Returns the indicator type of the input by the server version.
408+
If the server version is 6.2 and greater, remove the STIX prefix of the type
409+
410+
:type indicator_type: ``str``
411+
:param indicator_type: Type of an indicator.
412+
413+
:rtype: ``str``
414+
:return:: Indicator type .
415+
"""
416+
a = is_demisto_version_ge("6.2.0")
417+
if a and indicator_type.startswith(STIX_PREFIX):
418+
return indicator_type[len(STIX_PREFIX):]
419+
return indicator_type
420+
405421

406422
# -------------------------------- Threat Intel Objects ----------------------------------- #
407423

Packs/Base/Scripts/CommonServerPython/CommonServerPython_test.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,48 @@ def test_is_demisto_version_build_ge(mocker):
12041204
assert not is_demisto_version_ge('5.5.0', '50001')
12051205

12061206

1207+
def test_indicator_type_by_server_version_under_6_1(mocker, clear_version_cache):
1208+
"""
1209+
Given
1210+
- demisto version mock under 6.2
1211+
1212+
When
1213+
- demisto version mock under 6.2
1214+
1215+
Then
1216+
- Do not remove the STIX indicator type prefix.
1217+
"""
1218+
mocker.patch.object(
1219+
demisto,
1220+
'demistoVersion',
1221+
return_value={
1222+
'version': '6.1.0',
1223+
}
1224+
)
1225+
assert FeedIndicatorType.indicator_type_by_server_version("STIX Attack Pattern") == "STIX Attack Pattern"
1226+
1227+
1228+
def test_indicator_type_by_server_version_6_2(mocker, clear_version_cache):
1229+
"""
1230+
Given
1231+
- demisto version mock set to 6.2
1232+
1233+
When
1234+
- demisto version mock set to 6.2
1235+
1236+
Then
1237+
- Return the STIX indicator type with the STIX prefix
1238+
"""
1239+
mocker.patch.object(
1240+
demisto,
1241+
'demistoVersion',
1242+
return_value={
1243+
'version': '6.2.0',
1244+
}
1245+
)
1246+
assert FeedIndicatorType.indicator_type_by_server_version("STIX Attack Pattern") == "Attack Pattern"
1247+
1248+
12071249
def test_assign_params():
12081250
from CommonServerPython import assign_params
12091251
res = assign_params(a='1', b=True, c=None, d='')

Packs/Base/pack_metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Base",
33
"description": "The base pack for Cortex XSOAR.",
44
"support": "xsoar",
5-
"currentVersion": "1.11.4",
5+
"currentVersion": "1.11.5",
66
"author": "Cortex XSOAR",
77
"serverMinVersion": "6.0.0",
88
"url": "https://www.paloaltonetworks.com/cortex",
@@ -18,4 +18,4 @@
1818
"common"
1919
],
2020
"dependencies": {}
21-
}
21+
}

0 commit comments

Comments
 (0)