def test_collect_scripts_depends_on_with_two_inputs(self, id_set): expected_result = {('Active_Directory_Query', True), ('Feedsslabusech', True)} test_input = [ { "DummyScript1": { "name": "DummyScript1", "file_path": "dummy_path1", "depends_on": [ "sslbl-get-indicators" ], "pack": "dummy_pack" } }, { "DummyScript2": { "name": "DummyScript2", "file_path": "dummy_path1", "depends_on": [ "ad-get-user" ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_command_to_integration(self, id_set): """ Given - A script entry in the id_set containing command_to_integration. When - Building dependency graph for pack. Then - Extracting the pack that the script depends on. - Should recognize the pack. """ expected_result = {('Active_Directory_Query', True)} test_input = [ { "DummyScript": { "name": "ADGetUser", "file_path": "Packs/Active_Directory_Query/Scripts/script-ADGetUser.yml", "depends_on": [ ], "command_to_integration": { "ad-search": "activedir" }, "pack": "Active_Directory_Query" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts__filter_toversion(self, id_set): """ Given - A script entry in the id_set depending on QRadar command. When - Building dependency graph for pack. Then - Extracting the packs that the script depends on. - Should ignore the Deprecated pack due to toversion settings of old QRadar integration. """ expected_result = {('QRadar', True)} test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ "qradar-searches", ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), exclude_ignored_dependencies=False ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_depends_on_two_integrations(self, id_set): """ Given - A script entry in the id_set depending on 2 integrations. When - Building dependency graph for pack. Then - Extracting the packs that the script depends on. - Should recognize both packs. """ expected_result = {('Active_Directory_Query', True), ('Feedsslabusech', True)} test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ "sslbl-get-indicators", "ad-get-user" ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_depends_on_two_scripts(self, id_set): """ Given - A script entry in the id_set depending on 2 scripts. When - Building dependency graph for pack. Then - Extracting the packs that the script depends on. - Should recognize both packs. """ expected_result = {('HelloWorld', True), ('PrismaCloudCompute', True)} test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ "PrismaCloudComputeParseAuditAlert", "HelloWorldScript" ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_depends_on_integration(self, dependency_integration_command, expected_result, id_set): """ Given - A script entry in the id_set depending on integration commands. When - Building dependency graph for pack. Then - Extracting the packs that the script depends on. - Should recognize the pack. """ test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ dependency_integration_command ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_command_to_integrations_and_script_executions(self, id_set): """ Given - A script entry in the id_set containing command_to_integrations with a reputation command and script_executions. When - Building dependency graph for pack. Then - Extracting the packs that the script depends on. - Should recognize the mandatory pack and the non mandatory packs. """ expected_result = { ('Active_Directory_Query', True), ('Recorded_Future', False), ('illuminate', False), ('ThreatQ', False), ('Anomali_ThreatStream', False), ('URLHaus', False), ('Symantec_Deepsight', False), ('XForceExchange', False), ('Active_Directory_Query', True), ('XFE', False), ('MISP', False), ('AlienVault_OTX', False), ('ThreatMiner', False), ('isight', False), ('CrowdStrikeIntel', False), ('ReversingLabs_A1000', False), ('PolySwarm', False), ('TruSTAR', False), ('ReversingLabs_Titanium_Cloud', False), ('ThreatExchange', False), ('EclecticIQ', False), ('AutoFocus', False), ('McAfee-TIE', False), ('Maltiverse', False), ('Palo_Alto_Networks_WildFire', False), ('Polygon', False), ('Cofense-Intelligence', False), ('Lastline', False), ('ThreatConnect', False), ('VirusTotal', False), ('Flashpoint', False) } test_input = [ { "DummyScript": { "name": "double_dependency", "file_path": "Packs/DeprecatedContent/Scripts/script-ADIsUserMember.yml", "deprecated": False, "depends_on": [ ], "command_to_integration": { "file": "many integrations" }, "script_executions": [ "ADGetUser", ], "pack": "Active_Directory_Query" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_depends_on_integration(self, dependency_integration_command, expected_result, id_set): test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ dependency_integration_command ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set) assert found_result == expected_result
def test_collect_scripts_depends_on_script(self, dependency_script, expected_result, id_set): test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ dependency_script ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_depends_on_two_integrations(self, id_set): test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ "sslbl-get-indicators", "ad-get-user" ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set) assert found_result == {('Active_Directory_Query', True), ('Feedsslabusech', True)}
def test_collect_scripts_depends_on_two_scripts(self, id_set): test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ "PrismaCloudComputeParseAuditAlert", "HelloWorldScript" ], "pack": "dummy_pack" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set) assert found_result == {('HelloWorld', True), ('PrismaCloudCompute', True)}
def test_collect_scripts_depends_on_integration( self, dependency_integration_command, expected_result, id_set): test_input = [{ "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [dependency_integration_command], "pack": "dummy_pack" } }] found_result = PackDependencies._collect_scripts_dependencies( pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_detection_of_optional_dependencies(self, generic_command, id_set): test_input = [ { "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": [ generic_command ], "pack": "dummy_pack" } } ] dependencies_set = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set) assert len(dependencies_set) > 0 for dependency_data in dependencies_set: assert not dependency_data[1] # validate that mandatory is set to False
def test_collect_scripts_depends_on_two_scripts(self, id_set): expected_result = {('HelloWorld', True), ('PrismaCloudCompute', True)} test_input = [{ "DummyScript": { "name": "DummyScript", "file_path": "dummy_path", "depends_on": ["PrismaCloudComputeParseAuditAlert", "HelloWorldScript"], "pack": "dummy_pack" } }] found_result = PackDependencies._collect_scripts_dependencies( pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)
def test_collect_scripts_script_executions(self, id_set): """ Given - A script entry in the id_set containing a script_executions, e.g: demisto.executeCommand(<command>). When - Building dependency graph for pack. Then - Extracting the pack that the script depends on. - Should recognize the pack. """ expected_result = {('Active_Directory_Query', True)} test_input = [ { "DummyScript": { "name": "ADIsUserMember", "file_path": "Packs/DeprecatedContent/Scripts/script-ADIsUserMember.yml", "deprecated": False, "depends_on": [ ], "script_executions": [ "ADGetUser", ], "pack": "Active_Directory_Query" } } ] found_result = PackDependencies._collect_scripts_dependencies(pack_scripts=test_input, id_set=id_set, verbose_file=VerboseFile(), ) assert IsEqualFunctions.is_sets_equal(found_result, expected_result)