diff --git a/agent_based/checkpoint_inv_updates.py b/agent_based/checkpoint_inv_updates.py index 868031a6c3d410c75c6eaa77577007a0e4c10cc6..631aa183ac84c664f4d138aa502e3822dd1a9db4 100644 --- a/agent_based/checkpoint_inv_updates.py +++ b/agent_based/checkpoint_inv_updates.py @@ -16,20 +16,20 @@ # sample string_table # [ # [ -# ['1', 'Check_Point_SmartConsole_R80_40_jumbo_HF_B411_Win.tgz', 'HFA', 'Installed'], -# ['2', 'Check_Point_R80_40_JUMBO_HF_Bundle_T78_sk165456_FULL.tgz', 'Wrapper', 'Installed'], -# ['3', 'Check_Point_CPinfo_Bundle_R80_40_T53.tgz', 'HFA', 'Installed'] +# ['Check_Point_SmartConsole_R80_40_jumbo_HF_B411_Win.tgz', 'HFA', 'Installed'], +# ['Check_Point_R80_40_JUMBO_HF_Bundle_T78_sk165456_FULL.tgz', 'Wrapper', 'Installed'], +# ['Check_Point_CPinfo_Bundle_R80_40_T53.tgz', 'HFA', 'Installed'] # ], # [ -# ['1', 'Check_Point_SmartConsole_R80_40_jumbo_HF_B411_Win.tgz', 'R80.40 SmartConsole Build 411', 'capability', 'Installed', '2020-09-30T00:00:00Z', 'Recommended', '2020-10-12T15:19:51Z'], -# ['2', 'Check_Point_R80_40_JUMBO_HF_Bundle_T78_sk165456_FULL.tgz', 'R80.40 Jumbo Hotfix Accumulator General Availability (Take 78)', 'jumbo', 'Installed', '2020-08-24T00:00:00Z', 'Recommended', '2020-10-12T15:36:58Z'], -# ['3', 'Check_Point_CPinfo_Bundle_R80_40_T53.tgz', 'Check Point CPinfo build 202 for R80.40', 'capability', 'Installed', '2020-01-26T00:00:00Z', 'Recommended', '2020-10-12T15:19:16Z'], -# ['4', 'Check_Point_SmartConsole_R80_40_jumbo_HF_B410_Win.tgz', 'Check Point SmartConsole R80.40 Jumbo Hotfix B410', 'capability', 'Available for Install', '2020-08-24T00:00:00Z', 'Not Recommended', '2020-09-08T16:33:07Z'], -# ['5', 'Check_Point_R80_40_JUMBO_HF_Bundle_T77_sk165456_FULL.tgz', 'Check_Point_R80_40_JUMBO_HF_Bundle_T77_sk165456_FULL.tgz', 'jumbo', 'Installed as part of', '1970-01-01T00:00:00Z', 'Not Recommended', '2020-09-07T19:06:50Z'], -# ['6', 'Check_Point_R81_T392_Fresh_Install_and_Upgrade.tgz', 'R81 Gaia Fresh Install and upgrade', 'major', 'Available for Download', '2020-10-22T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], -# ['7', 'Blink_image_1.1_Check_Point_R81_T392_SecurityManagement.tgz', '<b>[Latest] R81 Security Management for appliances </b>', 'major', 'Available for Download', '2020-10-22T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], -# ['8', 'Blink_image_1.1_Check_Point_R80.40_T294_JHF_T78_SecurityManagement.tgz', '<b>[Latest] R80.40 Security Management + JHF T78 for Appliances and Open Servers</b>', 'major', 'Available for Download', '2020-08-24T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], -# ['9', 'Check_Point_R80.40_T294_Fresh_Install_and_Upgrade.tgz', 'Check Point R80.40 Gaia Fresh Install and upgrade', 'major', 'Available for Download', '2020-01-27T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'] +# ['Check_Point_SmartConsole_R80_40_jumbo_HF_B411_Win.tgz', 'R80.40 SmartConsole Build 411', 'capability', 'Installed', '2020-09-30T00:00:00Z', 'Recommended', '2020-10-12T15:19:51Z'], +# ['Check_Point_R80_40_JUMBO_HF_Bundle_T78_sk165456_FULL.tgz', 'R80.40 Jumbo Hotfix Accumulator General Availability (Take 78)', 'jumbo', 'Installed', '2020-08-24T00:00:00Z', 'Recommended', '2020-10-12T15:36:58Z'], +# ['Check_Point_CPinfo_Bundle_R80_40_T53.tgz', 'Check Point CPinfo build 202 for R80.40', 'capability', 'Installed', '2020-01-26T00:00:00Z', 'Recommended', '2020-10-12T15:19:16Z'], +# ['Check_Point_SmartConsole_R80_40_jumbo_HF_B410_Win.tgz', 'Check Point SmartConsole R80.40 Jumbo Hotfix B410', 'capability', 'Available for Install', '2020-08-24T00:00:00Z', 'Not Recommended', '2020-09-08T16:33:07Z'], +# ['Check_Point_R80_40_JUMBO_HF_Bundle_T77_sk165456_FULL.tgz', 'Check_Point_R80_40_JUMBO_HF_Bundle_T77_sk165456_FULL.tgz', 'jumbo', 'Installed as part of', '1970-01-01T00:00:00Z', 'Not Recommended', '2020-09-07T19:06:50Z'], +# ['Check_Point_R81_T392_Fresh_Install_and_Upgrade.tgz', 'R81 Gaia Fresh Install and upgrade', 'major', 'Available for Download', '2020-10-22T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], +# ['Blink_image_1.1_Check_Point_R81_T392_SecurityManagement.tgz', '<b>[Latest] R81 Security Management for appliances </b>', 'major', 'Available for Download', '2020-10-22T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], +# ['Blink_image_1.1_Check_Point_R80.40_T294_JHF_T78_SecurityManagement.tgz', '<b>[Latest] R80.40 Security Management + JHF T78 for Appliances and Open Servers</b>', 'major', 'Available for Download', '2020-08-24T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'], +# ['Check_Point_R80.40_T294_Fresh_Install_and_Upgrade.tgz', 'Check Point R80.40 Gaia Fresh Install and upgrade', 'major', 'Available for Download', '2020-01-27T00:00:00Z', 'Not Recommended', '1970-01-01T00:00:00Z'] # ], # ] # @@ -37,11 +37,10 @@ from typing import List, NamedTuple from .agent_based_api.v1.type_defs import ( - StringTable, - InventoryResult, + StringTable, + InventoryResult, ) from .agent_based_api.v1 import ( - Attributes, register, SNMPTree, TableRow, @@ -51,11 +50,13 @@ from .agent_based_api.v1 import ( equals, ) + class CheckpointUpdatesRecommended(NamedTuple): name: str type: str status: list + class CheckpointUpdatesAvailable(NamedTuple): filename: str description: str @@ -65,10 +66,12 @@ class CheckpointUpdatesAvailable(NamedTuple): recommended: str installedat: str + class CheckpointUpdates(NamedTuple): updatesrecommended: list updatesavailable: list + def parse_checkpoint_updates(string_table: List[StringTable]) -> CheckpointUpdates: section = CheckpointUpdates section.updatesrecommended = string_table[0] @@ -76,59 +79,20 @@ def parse_checkpoint_updates(string_table: List[StringTable]) -> CheckpointUpdat return section -register.snmp_section( - name='checkpoint_inv_updates', - parse_function=parse_checkpoint_updates, - fetch=[ - SNMPTree( - base='.1.3.6.1.4.1.2620.1.6.20.8.1', # CHECKPOINT-MIB::updatesRecommendedEntry - oids=[ - '2', # updatesRecommendedName - '3', # updatesRecommendedType - '4', # updatesRecommendedStatus - ] - ), - SNMPTree( - base='.1.3.6.1.4.1.2620.1.6.20.10.1', # CHECKPOINT-MIB::availableUpdates - oids=[ - '2', # filename - '3', # description - '4', # type - '5', # status - '6', # available_since - '7', # recommended - '8', # installed_at - ] - ), - ], - detect= any_of( - startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2620'), - all_of( - equals('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.8072.3.2.10'), - equals('.1.3.6.1.4.1.2620.1.6.1.0','SVN Foundation' ), - ) - ) - ) - - def inventory_checkpoint_updates(section: CheckpointUpdates) -> InventoryResult: - - path = ['software', 'check_point', 'updates'] + path = ['software', 'check_point', 'updates'] for update in section.updatesrecommended: update = CheckpointUpdatesRecommended(*update) yield TableRow( - path=path, - key_columns={'file_name':update.name}, - inventory_columns={ - # 'index': update.index, - 'type': update.type, - 'status': update.status, - 'recommended': 'Recommended', - }, - ) - - path = ['software', 'check_point', 'updates'] + path=path, + key_columns={'file_name': update.name}, + inventory_columns={ + 'type': update.type, + 'status': update.status, + 'recommended': 'Recommended', + }, + ) for update in section.updatesavailable: update = CheckpointUpdatesAvailable(*update) @@ -136,24 +100,57 @@ def inventory_checkpoint_updates(section: CheckpointUpdates) -> InventoryResult: if not 'installed' in update.status.lower(): installedat = 'N/A' else: - installedat = update.installedat.replace('T', ' ').replace('Z','') + installedat = update.installedat.replace('T', ' ').replace('Z', '') yield TableRow( - path=path, - key_columns={'file_name':update.filename}, - inventory_columns={ - # 'index': update.index, - 'description': update.description, - 'type': update.type, - 'status': update.status, - 'recommended': update.recommended, - 'available_since': update.availablesince[:10], - 'installed_at': installedat, - }, - ) + path=path, + key_columns={'file_name': update.filename}, + inventory_columns={ + 'description': update.description, + 'type': update.type, + 'status': update.status, + 'recommended': update.recommended, + 'available_since': update.availablesince[:10], + 'installed_at': installedat, + }, + ) + +register.snmp_section( + name='checkpoint_inv_updates', + parse_function=parse_checkpoint_updates, + fetch=[ + SNMPTree( + base='.1.3.6.1.4.1.2620.1.6.20.8.1', # CHECKPOINT-MIB::updatesRecommendedEntry + oids=[ + '2', # updatesRecommendedName + '3', # updatesRecommendedType + '4', # updatesRecommendedStatus + ] + ), + SNMPTree( + base='.1.3.6.1.4.1.2620.1.6.20.10.1', # CHECKPOINT-MIB::availableUpdates + oids=[ + '2', # filename + '3', # description + '4', # type + '5', # status + '6', # available_since + '7', # recommended + '8', # installed_at + ] + ), + ], + detect=any_of( + startswith('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.2620'), + all_of( + equals('.1.3.6.1.2.1.1.2.0', '.1.3.6.1.4.1.8072.3.2.10'), + equals('.1.3.6.1.4.1.2620.1.6.1.0', 'SVN Foundation'), + ) + ) +) register.inventory_plugin( - name='checkpoint_inv_updates', - inventory_function=inventory_checkpoint_updates, + name='checkpoint_inv_updates', + inventory_function=inventory_checkpoint_updates, ) diff --git a/inv_checkpoint_updates.mkp b/inv_checkpoint_updates.mkp index 0b55efb5f4f876d258209c0b01f43a7e4531f25c..d8813ef1860c832f4ccf5fa44e9903f349b5fe1c 100644 Binary files a/inv_checkpoint_updates.mkp and b/inv_checkpoint_updates.mkp differ diff --git a/packages/inv_checkpoint_updates b/packages/inv_checkpoint_updates index d5995ea6cee34cbd2e80841431a8133ea71ad4da..0ab80acb3bb2f7bb500f51c8d1106d9851b7dcba 100644 --- a/packages/inv_checkpoint_updates +++ b/packages/inv_checkpoint_updates @@ -10,6 +10,6 @@ 'num_files': 2, 'title': 'Check Point appliance avilable updates inventory plugin', 'version': '20210208.v.0.1', - 'version.min_required': '2.0.0i1', - 'version.packaged': '2020.11.27', + 'version.min_required': '2.0.0b8', + 'version.packaged': '2.0.0b8', 'version.usable_until': None} \ No newline at end of file