diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8bada118..b3aa2ec5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Linting: black" run: "poetry run invoke black" bandit: @@ -31,7 +31,7 @@ jobs: - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Linting: bandit" run: "poetry run invoke bandit" needs: @@ -46,7 +46,7 @@ jobs: - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Type-Hints: mypy" run: "poetry run invoke mypy" needs: @@ -61,7 +61,7 @@ jobs: - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Linting: pydocstyle" run: "poetry run invoke pydocstyle" needs: @@ -76,7 +76,7 @@ jobs: - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Linting: flake8" run: "poetry run invoke flake8" needs: @@ -91,7 +91,7 @@ jobs: - name: "Setup environment" uses: "networktocode/gh-action-setup-poetry-environment@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Linting: yamllint" run: "poetry run invoke yamllint" needs: @@ -100,7 +100,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: "ubuntu-20.04" env: PYTHON_VER: "${{ matrix.python-version }}" @@ -137,7 +137,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.11"] + python-version: ["3.12"] env: PYTHON_VER: "${{ matrix.python-version }}" steps: @@ -173,7 +173,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: ["3.8", "3.9", "3.10", "3.11"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] runs-on: "ubuntu-20.04" env: PYTHON_VER: "${{ matrix.python-version }}" @@ -220,7 +220,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Install Python Packages" run: "pip install poetry" - name: "Set env" @@ -249,7 +249,7 @@ jobs: - name: "Set up Python" uses: "actions/setup-python@v2" with: - python-version: "3.11" + python-version: "3.12" - name: "Install Python Packages" run: "pip install poetry" - name: "Set env" diff --git a/.github/workflows/proto_num_filepull.yml b/.github/workflows/proto_num_filepull.yml new file mode 100644 index 00000000..ced8694e --- /dev/null +++ b/.github/workflows/proto_num_filepull.yml @@ -0,0 +1,56 @@ +--- +name: "Protocol-Number-Updates" + +on: # yamllint disable-line rule:truthy + schedule: + - cron: "0 2 1 * *" + +jobs: + data_gathering: + runs-on: "ubuntu-latest" + env: + BRANCH_NAME: "PROTO_NUM_Updates" + steps: + # Checkout repo + - name: "Check out code" + uses: "actions/checkout@v2" + with: + ref: "develop" + # Delete old branch if it exists + - name: "Delete existing branch" + run: "git branch -D $BRANCH_NAME || true" + # Create branch for Flatbot + - name: "Create Flatbot branch" + run: "git checkout -b $BRANCH_NAME" + # Push new branch so Flatbot can make its commit + - name: "Push Flatbot branch" + run: "git push -f --set-upstream origin $BRANCH_NAME" + # Install Black + - name: "Install Python Black" + run: "pip install black" + # This step installs Deno, which is a new Javascript runtime that improves on Node. Can be used for an optional postprocessing step + - name: "Setup deno" + uses: "denoland/setup-deno@main" + with: + deno-version: "v1.10.x" + # The Flat Action step. We fetch the data in the http_url and save it as downloaded_filename + - name: "Fetch data" + uses: "githubocto/flat@v3" + with: + http_url: "https://www.iana.org/assignments/protocol-numbers/protocol-numbers-1.csv" + downloaded_filename: "./netutils/data_files/protocol_number_mappings.py" + postprocess: "./flat_postprocess/protocol_number_postprocess.ts" + pr_creation: + runs-on: "ubuntu-latest" + needs: "data_gathering" + steps: + # Checkout repo + - name: "Check out code" + uses: "actions/checkout@v2" + with: + ref: "PROTO_NUM_Updates" + # Create PR from branch created above into develop + - name: "Create a Pull Request" + run: "gh pr create -B develop -H PROTO_NUM_Updates --title 'Flatbot PROTOCOL Number File Updates' --body 'Created by Flatbot action'" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/docs/admin/release_notes/version_1.8.md b/docs/admin/release_notes/version_1.8.md new file mode 100755 index 00000000..f3414994 --- /dev/null +++ b/docs/admin/release_notes/version_1.8.md @@ -0,0 +1,31 @@ +# v1.8 Release Notes + +## Release Overview + +- Added support for Python 3.12. +- Added local support of `distutils.version` now that Python 3.12 deprecates disutils. +- Added functions `compare_version_loose` and `compare_version_strict` based on `distutils.version`. +- Added function `paloalto_panos_clean_newlines`. +- Added various lib_mapper updates. +- Added HP Comware parser. + +## [v1.8.0] 2024-04 + +### Added + +- [#483](https://github.com/networktocode/netutils/pull/483) Added support for Python 3.12. +- [#483](https://github.com/networktocode/netutils/pull/483) Added local support of `distutils.version` now that Python 3.12 deprecates disutils. +- [#490](https://github.com/networktocode/netutils/pull/490) Add JunOS and Vyatta to HierConfig mappers. +- [#416](https://github.com/networktocode/netutils/pull/416) Added `paloalto_panos_clean_newlines` function. +- [#467](https://github.com/networktocode/netutils/pull/467) Added HP Comware parser. + +### Changed + +- [#485](https://github.com/networktocode/netutils/pull/485) Changed order of changelog menu. +- [#494](https://github.com/networktocode/netutils/pull/494) Changed protocol number import to be dynamic update via flatbot. +- [#495](https://github.com/networktocode/netutils/pull/495) Changed XR mapping, add tests to ensure always using normalized name, various lib_mapper fixes. + +### Fixed + +- [#496](https://github.com/networktocode/netutils/pull/496) Fixed vyos lib_mapper. +- [#416](https://github.com/networktocode/netutils/pull/416) Fixed for `\n` characters in parsing bug in palo parser. diff --git a/docs/dev/attribution.md b/docs/dev/attribution.md index aabb6b3a..3db21d0d 100644 --- a/docs/dev/attribution.md +++ b/docs/dev/attribution.md @@ -10,6 +10,7 @@ Influencers - [IPCal](https://github.com/ammyblabla/ipcal) - [StackOverflow](https://stackoverflow.com/) - [Python 3 Docs](https://docs.python.org/3/library/) +- [Python distutils version](https://github.com/python/cpython/blob/3.11/Lib/distutils/version.py) In many instances variables and function names were reused, but the code was built from scratch to avoid any potential licensing issues. Functions that were known to be rewritten and their known origin. diff --git a/docs/dev/include_parser_list.md b/docs/dev/include_parser_list.md index 0d70a62c..2c3d0c7d 100644 --- a/docs/dev/include_parser_list.md +++ b/docs/dev/include_parser_list.md @@ -11,6 +11,7 @@ | citrix_netscaler | netutils.config.parser.NetscalerConfigParser | | extreme_netiron | netutils.config.parser.NetironConfigParser | | fortinet_fortios | netutils.config.parser.FortinetConfigParser | +| hp_comware | netutils.config.parser.HPComwareConfigParser | | juniper_junos | netutils.config.parser.JunosConfigParser | | linux | netutils.config.parser.LINUXConfigParser | | mikrotik_routeros | netutils.config.parser.RouterOSConfigParser | diff --git a/docs/user/include_jinja_list.md b/docs/user/include_jinja_list.md index fac72c4a..3b6addc7 100644 --- a/docs/user/include_jinja_list.md +++ b/docs/user/include_jinja_list.md @@ -18,6 +18,7 @@ | find_unordered_cfg_lines | netutils.config.compliance.find_unordered_cfg_lines | | section_config | netutils.config.compliance.section_config | | paloalto_panos_brace_to_set | netutils.config.conversion.paloalto_panos_brace_to_set | +| paloalto_panos_clean_newlines | netutils.config.conversion.paloalto_panos_clean_newlines | | fqdn_to_ip | netutils.dns.fqdn_to_ip | | is_fqdn_resolvable | netutils.dns.is_fqdn_resolvable | | hash_data | netutils.hash.hash_data | @@ -59,6 +60,8 @@ | mac_to_format | netutils.mac.mac_to_format | | mac_to_int | netutils.mac.mac_to_int | | mac_type | netutils.mac.mac_type | +| compare_version_loose | netutils.os_version.compare_version_loose | +| compare_version_strict | netutils.os_version.compare_version_strict | | get_upgrade_path | netutils.os_version.get_upgrade_path | | compare_cisco_type5 | netutils.password.compare_cisco_type5 | | compare_cisco_type7 | netutils.password.compare_cisco_type7 | diff --git a/docs/user/lib_mapper/aerleon.md b/docs/user/lib_mapper/aerleon.md index 663a5964..80affc5f 100644 --- a/docs/user/lib_mapper/aerleon.md +++ b/docs/user/lib_mapper/aerleon.md @@ -2,20 +2,20 @@ | ---------- | -- | ------ | | arista | → | arista_eos | | aruba | → | aruba_aoscx | -| brocade | → | ruckus_fastiron | +| brocade | → | brocade_nos | | cisco | → | cisco_ios | | ciscoasa | → | cisco_asa | | cisconx | → | cisco_nxos | -| ciscoxr | → | cisco_iosxr | +| ciscoxr | → | cisco_xr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | | juniper | → | juniper_junos | -| juniperevo | → | juniper_evo | +| juniperevo | → | juniper_junos | | k8s | → | k8s | -| msmpc | → | juniper_msmpc | +| msmpc | → | juniper_junos | | nsxt | → | vmware_nsxt | | nsxv | → | vmware_nsxv | | openconfig | → | openconfig | @@ -24,7 +24,7 @@ | pcap | → | pcap | | sonic | → | sonic | | speedway | → | speedway | -| srx | → | juniper_srx | -| srxlo | → | juniper_srx | +| srx | → | juniper_junos | +| srxlo | → | juniper_junos | | windows | → | windows | -| windows_advfirewall | → | windows_advfirewall | \ No newline at end of file +| windows_advfirewall | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/aerleon_reverse.md b/docs/user/lib_mapper/aerleon_reverse.md index 03173e19..f433e340 100644 --- a/docs/user/lib_mapper/aerleon_reverse.md +++ b/docs/user/lib_mapper/aerleon_reverse.md @@ -2,30 +2,25 @@ | ---------- | -- | ------ | | arista_eos | → | arista | | aruba_aoscx | → | aruba | -| brocade_fastiron | → | brocade | -| brocade_netiron | → | brocade | +| brocade_nos | → | brocade | | cisco_asa | → | ciscoasa | | cisco_ios | → | cisco | -| cisco_iosxr | → | ciscoxr | | cisco_nxos | → | cisconx | +| cisco_xe | → | cisco | +| cisco_xr | → | ciscoxr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | -| juniper_evo | → | juniperevo | | juniper_junos | → | juniper | -| juniper_msmpc | → | msmpc | -| juniper_srx | → | srxlo | | k8s | → | k8s | | openconfig | → | openconfig | | packetfilter | → | packetfilter | | paloalto_panos | → | paloalto | | pcap | → | pcap | -| ruckus_fastiron | → | brocade | | sonic | → | sonic | | speedway | → | speedway | | vmware_nsxt | → | nsxt | | vmware_nsxv | → | nsxv | -| windows_advfirewall | → | windows_advfirewall | -| windows_ipsec | → | windows | \ No newline at end of file +| windows | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/capirca.md b/docs/user/lib_mapper/capirca.md index c28b13ad..b688adcb 100644 --- a/docs/user/lib_mapper/capirca.md +++ b/docs/user/lib_mapper/capirca.md @@ -2,20 +2,20 @@ | ---------- | -- | ------ | | arista | → | arista_eos | | aruba | → | aruba_aoscx | -| brocade | → | ruckus_fastiron | +| brocade | → | brocade_nos | | cisco | → | cisco_ios | | ciscoasa | → | cisco_asa | | cisconx | → | cisco_nxos | -| ciscoxr | → | cisco_iosxr | +| ciscoxr | → | cisco_xr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | | juniper | → | juniper_junos | -| juniperevo | → | juniper_evo | +| juniperevo | → | juniper_junos | | k8s | → | k8s | -| msmpc | → | juniper_msmpc | +| msmpc | → | juniper_junos | | nsxt | → | vmware_nsxt | | nsxv | → | vmware_nsxv | | openconfig | → | openconfig | @@ -24,7 +24,7 @@ | pcap | → | pcap | | sonic | → | sonic | | speedway | → | speedway | -| srx | → | juniper_srx | -| srxlo | → | juniper_srx | +| srx | → | juniper_junos | +| srxlo | → | juniper_junos | | windows | → | windows | -| windows_advfirewall | → | windows_advfirewall | \ No newline at end of file +| windows_advfirewall | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/capirca_reverse.md b/docs/user/lib_mapper/capirca_reverse.md index 7a829011..73bd3595 100644 --- a/docs/user/lib_mapper/capirca_reverse.md +++ b/docs/user/lib_mapper/capirca_reverse.md @@ -2,30 +2,25 @@ | ---------- | -- | ------ | | arista_eos | → | arista | | aruba_aoscx | → | aruba | -| brocade_fastiron | → | brocade | -| brocade_netiron | → | brocade | +| brocade_nos | → | brocade | | cisco_asa | → | ciscoasa | | cisco_ios | → | cisco | -| cisco_iosxr | → | ciscoxr | | cisco_nxos | → | cisconx | +| cisco_xe | → | cisco | +| cisco_xr | → | ciscoxr | | cloudarmor | → | cloudarmor | | gce | → | gce | | gcp_hf | → | gcp_hf | | ipset | → | ipset | | iptables | → | iptables | -| juniper_evo | → | juniperevo | | juniper_junos | → | juniper | -| juniper_msmpc | → | msmpc | -| juniper_srx | → | srxlo | | k8s | → | k8s | | openconfig | → | openconfig | | packetfilter | → | packetfilter | | paloalto_panos | → | paloalto | | pcap | → | pcap | -| ruckus_fastiron | → | brocade | | sonic | → | sonic | | speedway | → | speedway | | vmware_nsxt | → | nsxt | | vmware_nsxv | → | nsxv | -| windows_advfirewall | → | windows_advfirewall | -| windows_ipsec | → | windows | \ No newline at end of file +| windows | → | windows | \ No newline at end of file diff --git a/docs/user/lib_mapper/forwardnetworks.md b/docs/user/lib_mapper/forwardnetworks.md index 5fbf7f20..da7f3520 100644 --- a/docs/user/lib_mapper/forwardnetworks.md +++ b/docs/user/lib_mapper/forwardnetworks.md @@ -5,10 +5,10 @@ | ASA | → | cisco_asa | | EXTREME_NOS | → | extreme_netiron | | F5 | → | bigip_f5 | -| FORTINET | → | fortinet_fortios | +| FORTINET | → | fortinet | | IOS | → | cisco_ios | | IOS_XE | → | cisco_ios | -| IOS_XR | → | cisco_iosxr | +| IOS_XR | → | cisco_xr | | JUNOS | → | juniper_junos | | LINUX | → | linux | | LINUX_OVS_OFCTL | → | linux | diff --git a/docs/user/lib_mapper/forwardnetworks_reverse.md b/docs/user/lib_mapper/forwardnetworks_reverse.md index d8ce6ba4..06c3d629 100644 --- a/docs/user/lib_mapper/forwardnetworks_reverse.md +++ b/docs/user/lib_mapper/forwardnetworks_reverse.md @@ -5,10 +5,11 @@ | bigip_f5 | → | F5 | | cisco_asa | → | ASA | | cisco_ios | → | IOS | -| cisco_iosxr | → | IOS_XR | | cisco_nxos | → | NXOS | +| cisco_xe | → | IOS | +| cisco_xr | → | IOS_XR | | extreme_netiron | → | EXTREME_NOS | -| fortinet_fortios | → | FORTINET | +| fortinet | → | FORTINET | | juniper_junos | → | JUNOS | | linux | → | LINUX | | netscaler | → | NETSCALER | diff --git a/docs/user/lib_mapper/hierconfig.md b/docs/user/lib_mapper/hierconfig.md index 24ebb3e9..50025c88 100644 --- a/docs/user/lib_mapper/hierconfig.md +++ b/docs/user/lib_mapper/hierconfig.md @@ -3,6 +3,8 @@ | eos | → | arista_eos | | fastiron | → | ruckus_fastiron | | ios | → | cisco_ios | -| iosxe | → | cisco_xe | +| iosxe | → | cisco_ios | | iosxr | → | cisco_xr | -| nxos | → | cisco_nxos | \ No newline at end of file +| junos | → | juniper_junos | +| nxos | → | cisco_nxos | +| vyos | → | vyos | \ No newline at end of file diff --git a/docs/user/lib_mapper/hierconfig_reverse.md b/docs/user/lib_mapper/hierconfig_reverse.md index e0d18b83..8e5133b8 100644 --- a/docs/user/lib_mapper/hierconfig_reverse.md +++ b/docs/user/lib_mapper/hierconfig_reverse.md @@ -3,6 +3,8 @@ | arista_eos | → | eos | | cisco_ios | → | ios | | cisco_nxos | → | nxos | -| cisco_xe | → | iosxe | +| cisco_xe | → | ios | | cisco_xr | → | iosxr | -| ruckus_fastiron | → | fastiron | \ No newline at end of file +| juniper_junos | → | junos | +| ruckus_fastiron | → | fastiron | +| vyos | → | vyos | \ No newline at end of file diff --git a/docs/user/lib_mapper/napalm.md b/docs/user/lib_mapper/napalm.md index 185bff0a..a93f25a5 100644 --- a/docs/user/lib_mapper/napalm.md +++ b/docs/user/lib_mapper/napalm.md @@ -15,4 +15,4 @@ | panos | → | paloalto_panos | | ros | → | mikrotik_routeros | | sros | → | nokia_sros | -| vyos | → | brocade_vyos | \ No newline at end of file +| vyos | → | vyos | \ No newline at end of file diff --git a/docs/user/lib_mapper/napalm_reverse.md b/docs/user/lib_mapper/napalm_reverse.md index 67811a1c..f4c3a937 100644 --- a/docs/user/lib_mapper/napalm_reverse.md +++ b/docs/user/lib_mapper/napalm_reverse.md @@ -3,16 +3,16 @@ | arista_eos | → | eos | | aruba_aoscx | → | aoscx | | bigip_f5 | → | f5 | -| brocade_vyos | → | vyos | | cisco_asa | → | asa | | cisco_ios | → | ios | | cisco_nxos | → | nxos | | cisco_wlc | → | cisco_wlc_ssh | -| cisco_xe | → | cisco_ios | +| cisco_xe | → | ios | | cisco_xr | → | iosxr | | fortinet | → | fortios | | huawei | → | huawei_vrp | | juniper_junos | → | junos | | mikrotik_routeros | → | ros | | nokia_sros | → | sros | -| paloalto_panos | → | panos | \ No newline at end of file +| paloalto_panos | → | panos | +| vyos | → | vyos | \ No newline at end of file diff --git a/docs/user/lib_mapper/netmiko.md b/docs/user/lib_mapper/netmiko.md index 36610fbf..cda9d14a 100644 --- a/docs/user/lib_mapper/netmiko.md +++ b/docs/user/lib_mapper/netmiko.md @@ -13,6 +13,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -57,9 +58,9 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | +| f5_linux | → | bigip_f5 | +| f5_ltm | → | bigip_f5 | +| f5_tmsh | → | bigip_f5 | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/netmiko_reverse.md b/docs/user/lib_mapper/netmiko_reverse.md index 9a9bd6c4..5c775b89 100644 --- a/docs/user/lib_mapper/netmiko_reverse.md +++ b/docs/user/lib_mapper/netmiko_reverse.md @@ -13,6 +13,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -57,9 +58,6 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/netutilsparser.md b/docs/user/lib_mapper/netutilsparser.md index cea138aa..4f76423a 100644 --- a/docs/user/lib_mapper/netutilsparser.md +++ b/docs/user/lib_mapper/netutilsparser.md @@ -10,7 +10,8 @@ | cisco_nxos | → | cisco_nxos | | citrix_netscaler | → | citrix_netscaler | | extreme_netiron | → | extreme_netiron | -| fortinet_fortios | → | fortinet_fortios | +| fortinet_fortios | → | fortinet | +| hp_comware | → | hp_comware | | juniper_junos | → | juniper_junos | | linux | → | linux | | mikrotik_routeros | → | mikrotik_routeros | diff --git a/docs/user/lib_mapper/netutilsparser_reverse.md b/docs/user/lib_mapper/netutilsparser_reverse.md index 7db2c9b3..fb8b24b1 100644 --- a/docs/user/lib_mapper/netutilsparser_reverse.md +++ b/docs/user/lib_mapper/netutilsparser_reverse.md @@ -7,10 +7,12 @@ | cisco_asa | → | cisco_asa | | cisco_ios | → | cisco_ios | | cisco_nxos | → | cisco_nxos | +| cisco_xe | → | cisco_ios | | cisco_xr | → | cisco_iosxr | | citrix_netscaler | → | citrix_netscaler | | extreme_netiron | → | extreme_netiron | -| fortinet_fortios | → | fortinet_fortios | +| fortinet | → | fortinet_fortios | +| hp_comware | → | hp_comware | | juniper_junos | → | juniper_junos | | linux | → | linux | | mikrotik_routeros | → | mikrotik_routeros | diff --git a/docs/user/lib_mapper/ntctemplates.md b/docs/user/lib_mapper/ntctemplates.md index 61524043..500c4ca6 100644 --- a/docs/user/lib_mapper/ntctemplates.md +++ b/docs/user/lib_mapper/ntctemplates.md @@ -14,6 +14,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -58,9 +59,9 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | +| f5_linux | → | bigip_f5 | +| f5_ltm | → | bigip_f5 | +| f5_tmsh | → | bigip_f5 | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/ntctemplates_reverse.md b/docs/user/lib_mapper/ntctemplates_reverse.md index e5d2ff86..2dfae971 100644 --- a/docs/user/lib_mapper/ntctemplates_reverse.md +++ b/docs/user/lib_mapper/ntctemplates_reverse.md @@ -14,6 +14,7 @@ | aruba_procurve | → | aruba_procurve | | avaya_ers | → | avaya_ers | | avaya_vsp | → | avaya_vsp | +| bigip_f5 | → | bigip_f5 | | broadcom_icos | → | broadcom_icos | | brocade_fastiron | → | brocade_fastiron | | brocade_fos | → | brocade_fos | @@ -58,9 +59,6 @@ | extreme_vdx | → | extreme_vdx | | extreme_vsp | → | extreme_vsp | | extreme_wing | → | extreme_wing | -| f5_linux | → | f5_linux | -| f5_ltm | → | f5_ltm | -| f5_tmsh | → | f5_tmsh | | flexvnf | → | flexvnf | | fortinet | → | fortinet | | generic | → | generic | diff --git a/docs/user/lib_mapper/pyats.md b/docs/user/lib_mapper/pyats.md index 1ee1d38c..d6d35b56 100644 --- a/docs/user/lib_mapper/pyats.md +++ b/docs/user/lib_mapper/pyats.md @@ -1,7 +1,7 @@ | PYATS | | NORMALIZED | | ---------- | -- | ------ | | asa | → | cisco_asa | -| bigip | → | f5_tmsh | +| bigip | → | bigip_f5 | | dnac | → | cisco_dnac | | ios | → | cisco_ios | | iosxe | → | cisco_ios | diff --git a/docs/user/lib_mapper/pyats_reverse.md b/docs/user/lib_mapper/pyats_reverse.md index dddad0bb..3128e3d4 100644 --- a/docs/user/lib_mapper/pyats_reverse.md +++ b/docs/user/lib_mapper/pyats_reverse.md @@ -1,5 +1,6 @@ | NORMALIZED | | PYATS | | ---------- | -- | ------ | +| bigip_f5 | → | bigip | | cisco_asa | → | asa | | cisco_dnac | → | dnac | | cisco_ios | → | iosxe | @@ -7,7 +8,6 @@ | cisco_viptella | → | viptela | | cisco_xe | → | iosxe | | cisco_xr | → | iosxr | -| f5_tmsh | → | bigip | | juniper_junos | → | junos | | linux | → | linux | | nokia_sros | → | sros | \ No newline at end of file diff --git a/docs/user/lib_mapper/pyntc.md b/docs/user/lib_mapper/pyntc.md index e6bdde4f..7b06e2af 100644 --- a/docs/user/lib_mapper/pyntc.md +++ b/docs/user/lib_mapper/pyntc.md @@ -5,5 +5,5 @@ | cisco_asa_ssh | → | cisco_asa | | cisco_ios_ssh | → | cisco_ios | | cisco_nxos_nxapi | → | cisco_nxos | -| f5_tmos_icontrol | → | f5_tmsh | +| f5_tmos_icontrol | → | bigip_f5 | | juniper_junos_netconf | → | juniper_junos | \ No newline at end of file diff --git a/docs/user/lib_mapper/pyntc_reverse.md b/docs/user/lib_mapper/pyntc_reverse.md index 80691ee5..eb362eb8 100644 --- a/docs/user/lib_mapper/pyntc_reverse.md +++ b/docs/user/lib_mapper/pyntc_reverse.md @@ -1,10 +1,10 @@ | NORMALIZED | | PYNTC | | ---------- | -- | ------ | | arista_eos | → | arista_eos_eapi | +| bigip_f5 | → | f5_tmos_icontrol | | cisco_asa | → | cisco_asa_ssh | | cisco_ios | → | cisco_ios_ssh | | cisco_nxos | → | cisco_nxos_nxapi | | cisco_wlc | → | cisco_aireos_ssh | | cisco_xe | → | cisco_ios_ssh | -| f5_tmsh | → | f5_tmos_icontrol | | juniper_junos | → | juniper_junos_netconf | \ No newline at end of file diff --git a/docs/user/lib_mapper/scrapli_reverse.md b/docs/user/lib_mapper/scrapli_reverse.md index ffb981a7..68833359 100644 --- a/docs/user/lib_mapper/scrapli_reverse.md +++ b/docs/user/lib_mapper/scrapli_reverse.md @@ -4,5 +4,6 @@ | aruba_aoscx | → | aruba_aoscx | | cisco_ios | → | cisco_iosxe | | cisco_nxos | → | cisco_nxos | +| cisco_xe | → | cisco_iosxe | | cisco_xr | → | cisco_iosxr | | juniper_junos | → | juniper_junos | \ No newline at end of file diff --git a/flat_postprocess/protocol_number_postprocess.py b/flat_postprocess/protocol_number_postprocess.py new file mode 100644 index 00000000..54f50a44 --- /dev/null +++ b/flat_postprocess/protocol_number_postprocess.py @@ -0,0 +1,38 @@ +"""Python code used to postprocess Flat github action data related to Protocol mappings.""" +import csv +import os +import sys +from urllib.request import urlopen + + +if __name__ == "__main__": + if len(sys.argv) == 2: + URL = "https://www.iana.org/assignments/protocol-numbers/protocol-numbers-1.csv" + oui_textfile = urlopen(URL).read().decode("utf-8") # nosec: pylint: disable=consider-using-with + with open(sys.argv[1], "w", encoding="utf-8") as proto_mappings: + proto_mappings.write(oui_textfile) + + protocol_mapping = {} + reverse_mapping = {} + with open(sys.argv[1], encoding="utf-8") as file: + next(file) + reader = csv.reader(file) + for row in reader: + number = row[0] + name = row[1] + if not number.isnumeric(): + continue + if not name: + continue + name = name.replace(" (deprecated)", "") + protocol_mapping[name] = int(number) + reverse_mapping[int(number)] = name + + with open(sys.argv[1], "w", encoding="utf-8") as proto_mappings: + proto_mappings.write('"""Dictionary object to store Protocol Number."""\n') + proto_mappings.write("from typing import Dict\n") + proto_mappings.write(f"PROTO_NAME_TO_NUM: Dict[str, int] = {protocol_mapping}") + proto_mappings.write("\n") + proto_mappings.write(f"PROTO_NUM_TO_NAME: Dict[int, str] = {reverse_mapping}") + + os.system(f"black {sys.argv[1]}") # nosec diff --git a/flat_postprocess/protocol_number_postprocess.ts b/flat_postprocess/protocol_number_postprocess.ts new file mode 100644 index 00000000..75862cb9 --- /dev/null +++ b/flat_postprocess/protocol_number_postprocess.ts @@ -0,0 +1,7 @@ +// Forwards the execution to the python script +const py_run = Deno.run({ + // Run `python ./flat_postprocess/protocol_number_postprocess.py netutils/data_files/protocol_number_mappings.py` to test locally. + cmd: ["python", "./flat_postprocess/protocol_number_postprocess.py"].concat(Deno.args), +}); + +await py_run.status(); diff --git a/mkdocs.yml b/mkdocs.yml index 8c11f1c3..abd07488 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -117,16 +117,17 @@ nav: - Uninstall: "admin/uninstall.md" - Release Notes: - "admin/release_notes/index.md" - - v0.1: "admin/release_notes/version_0.1.md" - - v0.2: "admin/release_notes/version_0.2.md" - - v1.0: "admin/release_notes/version_1.0.md" - - v1.1: "admin/release_notes/version_1.1.md" - - v1.2: "admin/release_notes/version_1.2.md" - - v1.3: "admin/release_notes/version_1.3.md" - - v1.4: "admin/release_notes/version_1.4.md" - - v1.5: "admin/release_notes/version_1.5.md" - - v1.6: "admin/release_notes/version_1.6.md" + - v1.8: "admin/release_notes/version_1.8.md" - v1.7: "admin/release_notes/version_1.7.md" + - v1.6: "admin/release_notes/version_1.6.md" + - v1.5: "admin/release_notes/version_1.5.md" + - v1.4: "admin/release_notes/version_1.4.md" + - v1.3: "admin/release_notes/version_1.3.md" + - v1.2: "admin/release_notes/version_1.2.md" + - v1.1: "admin/release_notes/version_1.1.md" + - v1.0: "admin/release_notes/version_1.0.md" + - v0.2: "admin/release_notes/version_0.2.md" + - v0.1: "admin/release_notes/version_0.1.md" - Developer Guide: - Extending the Library: "dev/extending.md" - Contributing to the Library: "dev/contributing.md" diff --git a/netutils/_private/version.py b/netutils/_private/version.py new file mode 100644 index 00000000..d4413c42 --- /dev/null +++ b/netutils/_private/version.py @@ -0,0 +1,358 @@ +# pylint: disable=deprecated-module,missing-class-docstring,invalid-name,protected-access,consider-using-f-string,no-else-return,attribute-defined-outside-init,no-member +# pylint: disable=super-init-not-called,inconsistent-return-statements,no-else-continue,raise-missing-from,too-many-branches,missing-function-docstring,too-many-return-statements +# type: ignore + +# +# distutils/version.py, taken from: https://github.com/python/cpython/blob/3.11/Lib/distutils/version.py +# +# Implements multiple version numbering conventions for the +# Python Module Distribution Utilities. +# +# $Id$ +# + +"""Provides classes to represent module version numbers (one class for each style of version numbering). + +There are currently two such classes implemented: StrictVersion and LooseVersion. + +Every version number class implements the following interface: + * the 'parse' method takes a string and parses it to some internal + representation; if the string is an invalid version number, + 'parse' raises a ValueError exception + * the class constructor takes an optional string argument which, + if supplied, is passed to 'parse' + * __str__ reconstructs the string that was passed to 'parse' (or + an equivalent string -- ie. one that will generate an equivalent + version number instance) + * __repr__ generates Python code to recreate the version number instance + * _cmp compares the current instance with either another instance + of the same class or a string (which will be parsed to an instance + of the same class, thus must follow the same rules) +""" + +import re + + +class Version: + """Abstract base class for version numbering classes. + + Just provides constructor (__init__) and reproducer (__repr__), because those + seem to be the same for all version numbering classes; and route + rich comparisons to _cmp. + """ + + def __init__(self, vstring=None): + """__init__ method from Python core.""" + if vstring: + self.parse(vstring) + + def __repr__(self): + """__repr__ method from Python core.""" + return "%s ('%s')" % (self.__class__.__name__, str(self)) + + def __eq__(self, other): + """__eq__ method from Python core.""" + c = self._cmp(other) + if c is NotImplemented: + return c + return c == 0 + + def __lt__(self, other): + """__lt__ method from Python core.""" + c = self._cmp(other) + if c is NotImplemented: + return c + return c < 0 + + def __le__(self, other): + """__le__ method from Python core.""" + c = self._cmp(other) + if c is NotImplemented: + return c + return c <= 0 + + def __gt__(self, other): + """__gt__ method from Python core.""" + c = self._cmp(other) + if c is NotImplemented: + return c + return c > 0 + + def __ge__(self, other): + """__ge__ method from Python core.""" + c = self._cmp(other) + if c is NotImplemented: + return c + return c >= 0 + + +# Interface for version-number classes -- must be implemented +# by the following classes (the concrete ones -- Version should +# be treated as an abstract class). +# __init__ (string) - create and take same action as 'parse' +# (string parameter is optional) +# parse (string) - convert a string representation to whatever +# internal representation is appropriate for +# this style of version numbering +# __str__ (self) - convert back to a string; should be very similar +# (if not identical to) the string supplied to parse +# __repr__ (self) - generate Python code to recreate +# the instance +# _cmp (self, other) - compare two version numbers ('other' may +# be an unparsed version string, or another +# instance of your version class) + + +class StrictVersion(Version): + """Version numbering for anal retentives and software idealists. + + Implements the standard interface for version number classes as + described above. A version number consists of two or three + dot-separated numeric components, with an optional "pre-release" tag + on the end. The pre-release tag consists of the letter 'a' or 'b' + followed by a number. If the numeric components of two version + numbers are equal, then one with a pre-release tag will always + be deemed earlier (lesser) than one without. + + The following are valid version numbers (shown in the order that + would be obtained by sorting according to the supplied cmp function): + + 0.4 0.4.0 (these two are equivalent) + 0.4.1 + 0.5a1 + 0.5b3 + 0.5 + 0.9.6 + 1.0 + 1.0.4a3 + 1.0.4b1 + 1.0.4 + + The following are examples of invalid version numbers: + + 1 + 2.7.2.2 + 1.3.a4 + 1.3pl1 + 1.3c4 + + The rationale for this version numbering system will be explained + in the distutils documentation. + """ + + version_re = re.compile(r"^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$", re.VERBOSE | re.ASCII) + + def parse(self, vstring): + """Parse method from Python core.""" + match = self.version_re.match(vstring) + if not match: + raise ValueError("invalid version number '%s'" % vstring) + + (major, minor, patch, prerelease, prerelease_num) = match.group(1, 2, 4, 5, 6) + + if patch: + self.version = tuple(map(int, [major, minor, patch])) + else: + self.version = tuple(map(int, [major, minor])) + (0,) + + if prerelease: + self.prerelease = (prerelease[0], int(prerelease_num)) + else: + self.prerelease = None + + def __str__(self): + """__str__ method from Python core.""" + if self.version[2] == 0: + vstring = ".".join(map(str, self.version[0:2])) + else: + vstring = ".".join(map(str, self.version)) + + if self.prerelease: + vstring = vstring + self.prerelease[0] + str(self.prerelease[1]) + + return vstring + + def _cmp(self, other): + """_cmp method from Python core.""" + if isinstance(other, str): + other = StrictVersion(other) + elif not isinstance(other, StrictVersion): + return NotImplemented + + if self.version != other.version: + # numeric versions don't match + # prerelease stuff doesn't matter + if self.version < other.version: + return -1 + else: + return 1 + + # have to compare prerelease + # case 1: neither has prerelease; they're equal + # case 2: self has prerelease, other doesn't; other is greater + # case 3: self doesn't have prerelease, other does: self is greater + # case 4: both have prerelease: must compare them! + + if not self.prerelease and not other.prerelease: + return 0 + elif self.prerelease and not other.prerelease: + return -1 + elif not self.prerelease and other.prerelease: + return 1 + elif self.prerelease and other.prerelease: + if self.prerelease == other.prerelease: + return 0 + elif self.prerelease < other.prerelease: + return -1 + else: + return 1 + raise ValueError("Should not ever get here") + + +# end class StrictVersion + + +# The rules according to Greg Stein: +# 1) a version number has 1 or more numbers separated by a period or by +# sequences of letters. If only periods, then these are compared +# left-to-right to determine an ordering. +# 2) sequences of letters are part of the tuple for comparison and are +# compared lexicographically +# 3) recognize the numeric components may have leading zeroes +# +# The LooseVersion class below implements these rules: a version number +# string is split up into a tuple of integer and string components, and +# comparison is a simple tuple comparison. This means that version +# numbers behave in a predictable and obvious way, but a way that might +# not necessarily be how people *want* version numbers to behave. There +# wouldn't be a problem if people could stick to purely numeric version +# numbers: just split on period and compare the numbers as tuples. +# However, people insist on putting letters into their version numbers; +# the most common purpose seems to be: +# - indicating a "pre-release" version +# ('alpha', 'beta', 'a', 'b', 'pre', 'p') +# - indicating a post-release patch ('p', 'pl', 'patch') +# but of course this can't cover all version number schemes, and there's +# no way to know what a programmer means without asking him. +# +# The problem is what to do with letters (and other non-numeric +# characters) in a version number. The current implementation does the +# obvious and predictable thing: keep them as strings and compare +# lexically within a tuple comparison. This has the desired effect if +# an appended letter sequence implies something "post-release": +# eg. "0.99" < "0.99pl14" < "1.0", and "5.001" < "5.001m" < "5.002". +# +# However, if letters in a version number imply a pre-release version, +# the "obvious" thing isn't correct. Eg. you would expect that +# "1.5.1" < "1.5.2a2" < "1.5.2", but under the tuple/lexical comparison +# implemented here, this just isn't so. +# +# Two possible solutions come to mind. The first is to tie the +# comparison algorithm to a particular set of semantic rules, as has +# been done in the StrictVersion class above. This works great as long +# as everyone can go along with bondage and discipline. Hopefully a +# (large) subset of Python module programmers will agree that the +# particular flavour of bondage and discipline provided by StrictVersion +# provides enough benefit to be worth using, and will submit their +# version numbering scheme to its domination. The free-thinking +# anarchists in the lot will never give in, though, and something needs +# to be done to accommodate them. +# +# Perhaps a "moderately strict" version class could be implemented that +# lets almost anything slide (syntactically), and makes some heuristic +# assumptions about non-digits in version number strings. This could +# sink into special-case-hell, though; if I was as talented and +# idiosyncratic as Larry Wall, I'd go ahead and implement a class that +# somehow knows that "1.2.1" < "1.2.2a2" < "1.2.2" < "1.2.2pl3", and is +# just as happy dealing with things like "2g6" and "1.13++". I don't +# think I'm smart enough to do it right though. +# +# In any case, I've coded the test suite for this module (see +# ../test/test_version.py) specifically to fail on things like comparing +# "1.2a2" and "1.2". That's not because the *code* is doing anything +# wrong, it's because the simple, obvious design doesn't match my +# complicated, hairy expectations for real-world version numbers. It +# would be a snap to fix the test suite to say, "Yep, LooseVersion does +# the Right Thing" (ie. the code matches the conception). But I'd rather +# have a conception that matches common notions about version numbers. + + +class LooseVersion(Version): + """Version numbering for anarchists and software realists. + + Implements the standard interface for version number classes as + described above. A version number consists of a series of numbers, + separated by either periods or strings of letters. When comparing + version numbers, the numeric components will be compared + numerically, and the alphabetic components lexically. The following + are all valid version numbers, in no particular order: + + 1.5.1 + 1.5.2b2 + 161 + 3.10a + 8.02 + 3.4j + 1996.07.12 + 3.2.pl0 + 3.1.1.6 + 2g6 + 11g + 0.960923 + 2.2beta29 + 1.13++ + 5.5.kw + 2.0b1pl0 + + In fact, there is no such thing as an invalid version number under + this scheme; the rules for comparison are simple and predictable, + but may not always give the results you want (for some definition + of "want"). + """ + + component_re = re.compile(r"(\d+ | [a-z]+ | \.)", re.VERBOSE) + + def __init__(self, vstring=None): + """__init__ method from Python core.""" + if vstring: + self.parse(vstring) + + def parse(self, vstring): + """Parse method from Python core.""" + # I've given up on thinking I can reconstruct the version string + # from the parsed tuple -- so I just store the string here for + # use by __str__ + self.vstring = vstring + components = [x for x in self.component_re.split(vstring) if x and x != "."] + for i, obj in enumerate(components): + try: + components[i] = int(obj) + except ValueError: + pass + + self.version = components + + def __str__(self): + """__str__ method from Python core.""" + return self.vstring + + def __repr__(self): + """__repr__ method from Python core.""" + return "LooseVersion ('%s')" % str(self) + + def _cmp(self, other): + """_cmp method from Python core.""" + if isinstance(other, str): + other = LooseVersion(other) + elif not isinstance(other, LooseVersion): + return NotImplemented + + if self.version == other.version: + return 0 + if self.version < other.version: + return -1 + if self.version > other.version: + return 1 + + +# end class LooseVersion diff --git a/netutils/config/compliance.py b/netutils/config/compliance.py index beda32ef..e85ae2e4 100644 --- a/netutils/config/compliance.py +++ b/netutils/config/compliance.py @@ -18,6 +18,7 @@ "citrix_netscaler": parser.NetscalerConfigParser, "extreme_netiron": parser.NetironConfigParser, "fortinet_fortios": parser.FortinetConfigParser, + "hp_comware": parser.HPComwareConfigParser, "juniper_junos": parser.JunosConfigParser, "linux": parser.LINUXConfigParser, "mikrotik_routeros": parser.RouterOSConfigParser, diff --git a/netutils/config/conversion.py b/netutils/config/conversion.py index f9fab300..dd3caff2 100644 --- a/netutils/config/conversion.py +++ b/netutils/config/conversion.py @@ -1,5 +1,6 @@ """Configuration conversion methods for different network operating systems.""" +import re import typing as t from netutils.config.utils import _open_file_config @@ -9,6 +10,119 @@ } +def paloalto_panos_clean_newlines(cfg: str) -> str: + r"""Takes in the configuration and replaces any inappropriate newline characters with a space. + + Args: + cfg: Configuration as a string. + + Returns: + str: Cleaned configuration as a string + + Examples: + >>> from netutils.config.conversion import paloalto_panos_clean_newlines + >>> config = ''' + ... config { + ... syslog { + ... Traffic_Syslog { + ... server { + ... splunk { + ... transport UDP; + ... port 514; + ... format BSD; + ... server 1.1.1.1; + ... facility LOG_USER; + ... } + ... graylog { + ... transport UDP; + ... port 514; + ... format BSD; + ... server 2.2.2.2; + ... facility LOG_USER; + ... } + ... } + ... format { + ... config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags + ... Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail"; + ... system "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial cs3Label=Virtual System cs3=$vsys fname=$object flexString2Label=Module flexString2=$module msg=$opaque externalId=$seqno cat=$eventid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + ... threat "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... traffic "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsReceived=$pkts_received PanOSPacketsSent=$pkts_sent start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed cs2Label=URL Category cs2=$category externalId=$seqno reason=$session_end_reason PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cat=$action_source PanOSActionFlags=$actionflags PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel"; + ... url "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno requestContext=$contenttype cat=$threatid fileId=$pcap_id requestMethod=$http_method requestClientApplication=$user_agent PanOSXForwarderfor=$xff PanOSReferer=$referer PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... data "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... wildfire "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid filePath=$cloud fileId=$pcap_id fileHash=$filedigest fileType=$filetype suid=$sender msg=$subject duid=$recipient oldFileId=$reportid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... tunnel "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=Log Action cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action externalId=$seqno PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time cs2Label=Tunnel Type cs2=$tunnel flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsSent=$pkts_sent PanOSPacketsReceived=$pkts_received flexNumber2Label=Maximum Encapsulation flexNumber2=$max_encap cfp1Label=Unknown Protocol cfp1=$unknown_proto cfp2Label=Strict Checking cfp2=$strict_check PanOSTunnelFragment=$tunnel_fragment cfp3Label=Sessions Created cfp3=$sessions_created cfp4Label=Sessions Closed cfp4=$sessions_closed reason=$session_end_reason cat=$action_source start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed"; + ... auth "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Server Profile cs1=$serverprofile cs2Label=Normalize User cs2=$normalize_user cs3Label=Virtual System cs3=$vsys cs4Label=Authentication Policy cs4=$authpolicy cs5Label=Client Type cs5=$clienttype cs6Label=Log Action cs6=$logset fname=$object cn1Label=Factor Number cn1=$factorno cn2Label=Authentication ID cn2=$authid src=$ip cnt=$repeatcnt duser=$user flexString2Label=Vendor flexString2=$vendor msg=$event externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags PanOSDesc=$desc + ... "; + ... userid "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Factor Type cs1=$factortype cs3Label=Virtual System cs3=$vsys cs4Label=Data Source Name cs4=$datasourcename cs5Label=Data Source cs5=$datasource cs6Label=Data Source Type cs6=$datasourcetype cn1Label=Factor Number cn1=$factorno cn2Label=Virtual System ID cn2=$vsys_id cn3Label=Timeout Threshold cn3=$timeout src=$ip spt=$beginport dpt=$endport cnt=$repeatcnt duser=$user externalId=$seqno cat=$eventid end=$factorcompletiontime PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + ... hip-match "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$matchtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial suser=$srcuser cs3Label=Virtual System cs3=$vsys shost=$machinename src=$src cnt=$repeatcnt externalId=$seqno cat=$matchname start=$cef-formatted-time_generated cs2Label=Operating System cs2=$os PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id c6a2Label=IPv6 Source Address c6a2=$srcipv6"; + ... correlation "CEF:0|Palo Alto Networks|PAN-OS|8.0|$category|$type|$severity|rt=$cef-formatted-receive_time deviceExternalId=$serial start=$cef-formatted-time_generated src=$src suser=$srcuser cs3Label=Virtual System cs3=$vsys severity=$severity PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id fname=$object_name cn3Label=Object ID cn3=$object_id msg=$evidence"; + ... escaping { + ... escaped-characters \=; + ... escape-character \; + ... } + ... } + ... } + ... } + ... }''' + >>> paloalto_panos_clean_newlines(cfg=config) == \ + ... ''' + ... config { + ... syslog { + ... Traffic_Syslog { + ... server { + ... splunk { + ... transport UDP; + ... port 514; + ... format BSD; + ... server 1.1.1.1; + ... facility LOG_USER; + ... } + ... graylog { + ... transport UDP; + ... port 514; + ... format BSD; + ... server 2.2.2.2; + ... facility LOG_USER; + ... } + ... } + ... format { + ... config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail"; + ... system "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial cs3Label=Virtual System cs3=$vsys fname=$object flexString2Label=Module flexString2=$module msg=$opaque externalId=$seqno cat=$eventid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + ... threat "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... traffic "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsReceived=$pkts_received PanOSPacketsSent=$pkts_sent start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed cs2Label=URL Category cs2=$category externalId=$seqno reason=$session_end_reason PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cat=$action_source PanOSActionFlags=$actionflags PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel"; + ... url "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno requestContext=$contenttype cat=$threatid fileId=$pcap_id requestMethod=$http_method requestClientApplication=$user_agent PanOSXForwarderfor=$xff PanOSReferer=$referer PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... data "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... wildfire "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid filePath=$cloud fileId=$pcap_id fileHash=$filedigest fileType=$filetype suid=$sender msg=$subject duid=$recipient oldFileId=$reportid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + ... tunnel "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=Log Action cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action externalId=$seqno PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time cs2Label=Tunnel Type cs2=$tunnel flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsSent=$pkts_sent PanOSPacketsReceived=$pkts_received flexNumber2Label=Maximum Encapsulation flexNumber2=$max_encap cfp1Label=Unknown Protocol cfp1=$unknown_proto cfp2Label=Strict Checking cfp2=$strict_check PanOSTunnelFragment=$tunnel_fragment cfp3Label=Sessions Created cfp3=$sessions_created cfp4Label=Sessions Closed cfp4=$sessions_closed reason=$session_end_reason cat=$action_source start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed"; + ... auth "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Server Profile cs1=$serverprofile cs2Label=Normalize User cs2=$normalize_user cs3Label=Virtual System cs3=$vsys cs4Label=Authentication Policy cs4=$authpolicy cs5Label=Client Type cs5=$clienttype cs6Label=Log Action cs6=$logset fname=$object cn1Label=Factor Number cn1=$factorno cn2Label=Authentication ID cn2=$authid src=$ip cnt=$repeatcnt duser=$user flexString2Label=Vendor flexString2=$vendor msg=$event externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags PanOSDesc=$desc "; + ... userid "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Factor Type cs1=$factortype cs3Label=Virtual System cs3=$vsys cs4Label=Data Source Name cs4=$datasourcename cs5Label=Data Source cs5=$datasource cs6Label=Data Source Type cs6=$datasourcetype cn1Label=Factor Number cn1=$factorno cn2Label=Virtual System ID cn2=$vsys_id cn3Label=Timeout Threshold cn3=$timeout src=$ip spt=$beginport dpt=$endport cnt=$repeatcnt duser=$user externalId=$seqno cat=$eventid end=$factorcompletiontime PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + ... hip-match "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$matchtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial suser=$srcuser cs3Label=Virtual System cs3=$vsys shost=$machinename src=$src cnt=$repeatcnt externalId=$seqno cat=$matchname start=$cef-formatted-time_generated cs2Label=Operating System cs2=$os PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id c6a2Label=IPv6 Source Address c6a2=$srcipv6"; + ... correlation "CEF:0|Palo Alto Networks|PAN-OS|8.0|$category|$type|$severity|rt=$cef-formatted-receive_time deviceExternalId=$serial start=$cef-formatted-time_generated src=$src suser=$srcuser cs3Label=Virtual System cs3=$vsys severity=$severity PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id fname=$object_name cn3Label=Object ID cn3=$object_id msg=$evidence"; + ... escaping { + ... escaped-characters \=; + ... escape-character \; + ... } + ... } + ... } + ... } + ... }''' + True + """ + paloalto_panos_no_newline_cleanup_match = ["private-key", "public-key", "login-banner"] + paloalto_panos_newline_regex = re.compile( + r"\w+?-?\w+\s\"(?:[^\"\\]|\\.)*\n(?:[^\"\\]|\\.)*\";$", re.MULTILINE | re.DOTALL + ) + + newlines_cleaned_cfg = paloalto_panos_newline_regex.sub( + lambda match: match.group().replace("\n", " ") + if not any(substring in match.group() for substring in paloalto_panos_no_newline_cleanup_match) + else match.group(), + cfg, + ) + + return newlines_cleaned_cfg + + def paloalto_panos_brace_to_set(cfg: str, cfg_type: str = "file") -> str: r"""Convert Palo Alto Brace format configuration to set format. @@ -60,13 +174,15 @@ def paloalto_panos_brace_to_set(cfg: str, cfg_type: str = "file") -> str: if cfg_type not in ["file", "string"]: raise ValueError("The variable `cfg_type` must be either `file` or `string`.") if cfg_type == "file": - cfg_list = _open_file_config(cfg).splitlines() + cfg_raw = _open_file_config(cfg) + cfg_list = paloalto_panos_clean_newlines(cfg=cfg_raw).splitlines() else: - cfg_list = cfg.splitlines() + cfg_raw = paloalto_panos_clean_newlines(cfg=cfg) + cfg_list = cfg_raw.splitlines() for i, line in enumerate(cfg_list): line = line.strip() - if line.endswith(";") and not line.endswith('";'): + if line.endswith(";") and not line.startswith('";'): line = line.split(";", 1)[0] line = "".join(str(s) for s in stack) + line line = line.split("config ", 1)[1] diff --git a/netutils/config/parser.py b/netutils/config/parser.py index c54b41e0..3ee3f496 100644 --- a/netutils/config/parser.py +++ b/netutils/config/parser.py @@ -1612,3 +1612,102 @@ def config_lines_only(self) -> str: config_lines.append(line) return "\n".join(config_lines) + + +class HPEConfigParser(BaseSpaceConfigParser): + """HPE Implementation of ConfigParser Class.""" + + regex_banner = re.compile(r"^header\s(\w+)\s+(?P\^C|\S?)") + + def __init__(self, config: str): + """Initialize the HPEConfigParser object.""" + self.delimiter = "" + self._banner_end: t.Optional[str] = None + super(HPEConfigParser, self).__init__(config) + + def _build_banner(self, config_line: str) -> t.Optional[str]: + """ + Builds a banner configuration based on the given config_line. + + Args: + config_line (str): The configuration line to process. + + Returns: + Optional[str]: The next configuration line, or None if there are no more lines. + + Raises: + ValueError: If the banner end cannot be parsed. + """ + if self.is_banner_one_line(config_line): + self._update_config_lines(config_line) + try: + return next(self.generator_config) + except StopIteration: + return None + self._update_config_lines(config_line) + self._current_parents += (config_line,) + banner_config = [] + for line in self.generator_config: + if not self.is_banner_end(line): + banner_config.append(line) + else: + banner_config.append(line) + line = "\n".join(banner_config) + if line.endswith(self.delimiter): + banner, end, _ = line.rpartition(self.delimiter) + line = banner.rstrip() + end + self._update_config_lines(line) + self._current_parents = self._current_parents[:-1] + try: + return next(self.generator_config) + except StopIteration: + return None + raise ValueError("Unable to parse banner end.") + + def set_delimiter(self, config_line: str) -> None: + """Find delimiter character in banner and set self.delimiter to be it.""" + banner_parsed = self.regex_banner.match(config_line) + if banner_parsed and "banner_delimiter" in banner_parsed.groupdict(): + self.delimiter = banner_parsed.groupdict()["banner_delimiter"] + return None + raise ValueError("Unable to find banner delimiter.") + + def is_banner_one_line(self, config_line: str) -> bool: + """Checks if the given configuration line represents a one-line banner.""" + self.set_delimiter(config_line.strip()) + _, _delimeter, banner = config_line.partition(self.delimiter) + banner_config_start = banner.lstrip(_delimeter) + if _delimeter not in banner_config_start: + return False + return True + + def is_banner_start(self, line: str) -> bool: + """Checks if the given line is the start of a banner.""" + state = super(HPEConfigParser, self).is_banner_start(line) + if state: + self.banner_end = line + return state + + @property + def banner_end(self) -> str: + """Get the banner end.""" + if self._banner_end is None: + raise RuntimeError("Banner end not yet set.") + return self._banner_end + + @banner_end.setter + def banner_end(self, banner_start_line: str) -> None: + """Sets the delimiter for the end of the banner.""" + self.set_delimiter(banner_start_line.strip()) + self._banner_end = self.delimiter + + +class HPComwareConfigParser(HPEConfigParser, BaseSpaceConfigParser): + """HP Comware Implementation of ConfigParser Class.""" + + banner_start: t.List[str] = ["header "] + comment_chars: t.List[str] = ["#"] + + def _build_banner(self, config_line: str) -> t.Optional[str]: + """Build a banner from the given config line.""" + return super(HPComwareConfigParser, self)._build_banner(config_line) diff --git a/netutils/data_files/protocol_number_mappings.py b/netutils/data_files/protocol_number_mappings.py new file mode 100644 index 00000000..f0b4d2d6 --- /dev/null +++ b/netutils/data_files/protocol_number_mappings.py @@ -0,0 +1,292 @@ +"""Dictionary object to store Protocol Number.""" +from typing import Dict + +PROTO_NAME_TO_NUM: Dict[str, int] = { + "HOPOPT": 0, + "ICMP": 1, + "IGMP": 2, + "GGP": 3, + "IPv4": 4, + "ST": 5, + "TCP": 6, + "CBT": 7, + "EGP": 8, + "IGP": 9, + "BBN-RCC-MON": 10, + "NVP-II": 11, + "PUP": 12, + "ARGUS": 13, + "EMCON": 14, + "XNET": 15, + "CHAOS": 16, + "UDP": 17, + "MUX": 18, + "DCN-MEAS": 19, + "HMP": 20, + "PRM": 21, + "XNS-IDP": 22, + "TRUNK-1": 23, + "TRUNK-2": 24, + "LEAF-1": 25, + "LEAF-2": 26, + "RDP": 27, + "IRTP": 28, + "ISO-TP4": 29, + "NETBLT": 30, + "MFE-NSP": 31, + "MERIT-INP": 32, + "DCCP": 33, + "3PC": 34, + "IDPR": 35, + "XTP": 36, + "DDP": 37, + "IDPR-CMTP": 38, + "TP++": 39, + "IL": 40, + "IPv6": 41, + "SDRP": 42, + "IPv6-Route": 43, + "IPv6-Frag": 44, + "IDRP": 45, + "RSVP": 46, + "GRE": 47, + "DSR": 48, + "BNA": 49, + "ESP": 50, + "AH": 51, + "I-NLSP": 52, + "SWIPE": 53, + "NARP": 54, + "Min-IPv4": 55, + "TLSP": 56, + "SKIP": 57, + "IPv6-ICMP": 58, + "IPv6-NoNxt": 59, + "IPv6-Opts": 60, + "CFTP": 62, + "SAT-EXPAK": 64, + "KRYPTOLAN": 65, + "RVD": 66, + "IPPC": 67, + "SAT-MON": 69, + "VISA": 70, + "IPCV": 71, + "CPNX": 72, + "CPHB": 73, + "WSN": 74, + "PVP": 75, + "BR-SAT-MON": 76, + "SUN-ND": 77, + "WB-MON": 78, + "WB-EXPAK": 79, + "ISO-IP": 80, + "VMTP": 81, + "SECURE-VMTP": 82, + "VINES": 83, + "IPTM": 84, + "NSFNET-IGP": 85, + "DGP": 86, + "TCF": 87, + "EIGRP": 88, + "OSPFIGP": 89, + "Sprite-RPC": 90, + "LARP": 91, + "MTP": 92, + "AX.25": 93, + "IPIP": 94, + "MICP": 95, + "SCC-SP": 96, + "ETHERIP": 97, + "ENCAP": 98, + "GMTP": 100, + "IFMP": 101, + "PNNI": 102, + "PIM": 103, + "ARIS": 104, + "SCPS": 105, + "QNX": 106, + "A/N": 107, + "IPComp": 108, + "SNP": 109, + "Compaq-Peer": 110, + "IPX-in-IP": 111, + "VRRP": 112, + "PGM": 113, + "L2TP": 115, + "DDX": 116, + "IATP": 117, + "STP": 118, + "SRP": 119, + "UTI": 120, + "SMP": 121, + "SM": 122, + "PTP": 123, + "ISIS over IPv4": 124, + "FIRE": 125, + "CRTP": 126, + "CRUDP": 127, + "SSCOPMCE": 128, + "IPLT": 129, + "SPS": 130, + "PIPE": 131, + "SCTP": 132, + "FC": 133, + "RSVP-E2E-IGNORE": 134, + "Mobility Header": 135, + "UDPLite": 136, + "MPLS-in-IP": 137, + "manet": 138, + "HIP": 139, + "Shim6": 140, + "WESP": 141, + "ROHC": 142, + "Ethernet": 143, + "AGGFRAG": 144, + "NSH": 145, + "Reserved": 255, +} + +PROTO_NUM_TO_NAME: Dict[int, str] = { + 0: "HOPOPT", + 1: "ICMP", + 2: "IGMP", + 3: "GGP", + 4: "IPv4", + 5: "ST", + 6: "TCP", + 7: "CBT", + 8: "EGP", + 9: "IGP", + 10: "BBN-RCC-MON", + 11: "NVP-II", + 12: "PUP", + 13: "ARGUS", + 14: "EMCON", + 15: "XNET", + 16: "CHAOS", + 17: "UDP", + 18: "MUX", + 19: "DCN-MEAS", + 20: "HMP", + 21: "PRM", + 22: "XNS-IDP", + 23: "TRUNK-1", + 24: "TRUNK-2", + 25: "LEAF-1", + 26: "LEAF-2", + 27: "RDP", + 28: "IRTP", + 29: "ISO-TP4", + 30: "NETBLT", + 31: "MFE-NSP", + 32: "MERIT-INP", + 33: "DCCP", + 34: "3PC", + 35: "IDPR", + 36: "XTP", + 37: "DDP", + 38: "IDPR-CMTP", + 39: "TP++", + 40: "IL", + 41: "IPv6", + 42: "SDRP", + 43: "IPv6-Route", + 44: "IPv6-Frag", + 45: "IDRP", + 46: "RSVP", + 47: "GRE", + 48: "DSR", + 49: "BNA", + 50: "ESP", + 51: "AH", + 52: "I-NLSP", + 53: "SWIPE", + 54: "NARP", + 55: "Min-IPv4", + 56: "TLSP", + 57: "SKIP", + 58: "IPv6-ICMP", + 59: "IPv6-NoNxt", + 60: "IPv6-Opts", + 62: "CFTP", + 64: "SAT-EXPAK", + 65: "KRYPTOLAN", + 66: "RVD", + 67: "IPPC", + 69: "SAT-MON", + 70: "VISA", + 71: "IPCV", + 72: "CPNX", + 73: "CPHB", + 74: "WSN", + 75: "PVP", + 76: "BR-SAT-MON", + 77: "SUN-ND", + 78: "WB-MON", + 79: "WB-EXPAK", + 80: "ISO-IP", + 81: "VMTP", + 82: "SECURE-VMTP", + 83: "VINES", + 84: "IPTM", + 85: "NSFNET-IGP", + 86: "DGP", + 87: "TCF", + 88: "EIGRP", + 89: "OSPFIGP", + 90: "Sprite-RPC", + 91: "LARP", + 92: "MTP", + 93: "AX.25", + 94: "IPIP", + 95: "MICP", + 96: "SCC-SP", + 97: "ETHERIP", + 98: "ENCAP", + 100: "GMTP", + 101: "IFMP", + 102: "PNNI", + 103: "PIM", + 104: "ARIS", + 105: "SCPS", + 106: "QNX", + 107: "A/N", + 108: "IPComp", + 109: "SNP", + 110: "Compaq-Peer", + 111: "IPX-in-IP", + 112: "VRRP", + 113: "PGM", + 115: "L2TP", + 116: "DDX", + 117: "IATP", + 118: "STP", + 119: "SRP", + 120: "UTI", + 121: "SMP", + 122: "SM", + 123: "PTP", + 124: "ISIS over IPv4", + 125: "FIRE", + 126: "CRTP", + 127: "CRUDP", + 128: "SSCOPMCE", + 129: "IPLT", + 130: "SPS", + 131: "PIPE", + 132: "SCTP", + 133: "FC", + 134: "RSVP-E2E-IGNORE", + 135: "Mobility Header", + 136: "UDPLite", + 137: "MPLS-in-IP", + 138: "manet", + 139: "HIP", + 140: "Shim6", + 141: "WESP", + 142: "ROHC", + 143: "Ethernet", + 144: "AGGFRAG", + 145: "NSH", + 255: "Reserved", +} diff --git a/netutils/lib_mapper.py b/netutils/lib_mapper.py index bd0816d1..3ca6b1cd 100644 --- a/netutils/lib_mapper.py +++ b/netutils/lib_mapper.py @@ -4,249 +4,243 @@ import typing as t # AERLEON | Normalized -AERLEON_LIB_MAPPER = { +AERLEON_LIB_MAPPER: t.Dict[str, str] = { "arista": "arista_eos", "aruba": "aruba_aoscx", - "brocade": "ruckus_fastiron", + "brocade": "brocade_nos", "cisco": "cisco_ios", "ciscoasa": "cisco_asa", "cisconx": "cisco_nxos", - "ciscoxr": "cisco_iosxr", + "ciscoxr": "cisco_xr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper": "juniper_junos", - "juniperevo": "juniper_evo", + "juniperevo": "juniper_junos", # no reverse "k8s": "k8s", - "msmpc": "juniper_msmpc", + "msmpc": "juniper_junos", # no reverse + "nsxt": "vmware_nsxt", + "nsxv": "vmware_nsxv", "openconfig": "openconfig", - "pcap": "pcap", "packetfilter": "packetfilter", - "speedway": "speedway", - "srx": "juniper_srx", - "srxlo": "juniper_srx", "paloalto": "paloalto_panos", - "nsxv": "vmware_nsxv", - "nsxt": "vmware_nsxt", + "pcap": "pcap", "sonic": "sonic", + "speedway": "speedway", + "srx": "juniper_junos", # no reverse + "srxlo": "juniper_junos", # no reverse "windows": "windows", - "windows_advfirewall": "windows_advfirewall", + "windows_advfirewall": "windows", # no reverse } # Normalized | AERLEON -AERLEON_LIB_MAPPER_REVERSE = { +AERLEON_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista", "aruba_aoscx": "aruba", - "brocade_fastiron": "brocade", - "brocade_netiron": "brocade", - "cisco_ios": "cisco", + "brocade_nos": "brocade", "cisco_asa": "ciscoasa", + "cisco_ios": "cisco", "cisco_nxos": "cisconx", - "cisco_iosxr": "ciscoxr", + "cisco_xe": "cisco", + "cisco_xr": "ciscoxr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper_junos": "juniper", - "juniper_evo": "juniperevo", - "juniper_msmpc": "msmpc", - "juniper_srx": "srxlo", "k8s": "k8s", "openconfig": "openconfig", "packetfilter": "packetfilter", "paloalto_panos": "paloalto", "pcap": "pcap", - "ruckus_fastiron": "brocade", - "vmware_nsxv": "nsxv", - "vmware_nsxt": "nsxt", - "speedway": "speedway", "sonic": "sonic", - "windows_ipsec": "windows", - "windows_advfirewall": "windows_advfirewall", + "speedway": "speedway", + "vmware_nsxt": "nsxt", + "vmware_nsxv": "nsxv", + "windows": "windows", } # CAPIRCA | Normalized -CAPIRCA_LIB_MAPPER = { +CAPIRCA_LIB_MAPPER: t.Dict[str, str] = { "arista": "arista_eos", "aruba": "aruba_aoscx", - "brocade": "ruckus_fastiron", + "brocade": "brocade_nos", "cisco": "cisco_ios", "ciscoasa": "cisco_asa", "cisconx": "cisco_nxos", - "ciscoxr": "cisco_iosxr", + "ciscoxr": "cisco_xr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper": "juniper_junos", - "juniperevo": "juniper_evo", + "juniperevo": "juniper_junos", # no reverse "k8s": "k8s", - "msmpc": "juniper_msmpc", + "msmpc": "juniper_junos", + "nsxt": "vmware_nsxt", + "nsxv": "vmware_nsxv", "openconfig": "openconfig", - "pcap": "pcap", "packetfilter": "packetfilter", - "speedway": "speedway", - "srx": "juniper_srx", - "srxlo": "juniper_srx", "paloalto": "paloalto_panos", - "nsxv": "vmware_nsxv", - "nsxt": "vmware_nsxt", + "pcap": "pcap", "sonic": "sonic", + "speedway": "speedway", + "srx": "juniper_junos", # no reverse + "srxlo": "juniper_junos", # no reverse "windows": "windows", - "windows_advfirewall": "windows_advfirewall", + "windows_advfirewall": "windows", # no reverse } # Normalized | CAPIRCA -CAPIRCA_LIB_MAPPER_REVERSE = { +CAPIRCA_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista", "aruba_aoscx": "aruba", - "brocade_fastiron": "brocade", - "brocade_netiron": "brocade", - "cisco_ios": "cisco", + "brocade_nos": "brocade", "cisco_asa": "ciscoasa", + "cisco_ios": "cisco", "cisco_nxos": "cisconx", - "cisco_iosxr": "ciscoxr", + "cisco_xe": "cisco", + "cisco_xr": "ciscoxr", "cloudarmor": "cloudarmor", "gce": "gce", "gcp_hf": "gcp_hf", "ipset": "ipset", "iptables": "iptables", "juniper_junos": "juniper", - "juniper_evo": "juniperevo", - "juniper_msmpc": "msmpc", - "juniper_srx": "srxlo", "k8s": "k8s", "openconfig": "openconfig", "packetfilter": "packetfilter", "paloalto_panos": "paloalto", "pcap": "pcap", - "ruckus_fastiron": "brocade", - "vmware_nsxv": "nsxv", - "vmware_nsxt": "nsxt", - "speedway": "speedway", "sonic": "sonic", - "windows_ipsec": "windows", - "windows_advfirewall": "windows_advfirewall", + "speedway": "speedway", + "vmware_nsxt": "nsxt", + "vmware_nsxv": "nsxv", + "windows": "windows", } - -_NETMIKO_LIB_MAPPER: t.Dict[str, t.Dict[str, str]] = { - "a10": {}, - "accedian": {}, - "adtran_os": {}, - "alcatel_aos": {}, - "alcatel_sros": {}, - "apresia_aeos": {}, - "arista_eos": {}, - "aruba_os": {}, - "aruba_osswitch": {}, - "aruba_procurve": {}, - "avaya_ers": {}, - "avaya_vsp": {}, - "allied_telesis_awplus": {}, - "broadcom_icos": {}, - "brocade_fos": {}, - "brocade_fastiron": {}, - "brocade_netiron": {}, - "brocade_nos": {}, - "brocade_vdx": {}, - "brocade_vyos": {}, - "checkpoint_gaia": {}, - "calix_b6": {}, - "centec_os": {}, - "ciena_saos": {}, - "cisco_asa": {}, - "cisco_ftd": {}, - "cisco_ios": {}, - "cisco_nxos": {}, - "cisco_s300": {}, - "cisco_tp": {}, - "cisco_wlc": {}, - "cisco_xe": {}, - "cisco_xr": {}, - "cloudgenix_ion": {}, - "coriant": {}, - "dell_dnos9": {}, - "dell_force10": {}, - "dell_os6": {}, - "dell_os9": {}, - "dell_os10": {}, - "dell_powerconnect": {}, - "dell_isilon": {}, - "dlink_ds": {}, - "endace": {}, - "eltex": {}, - "eltex_esr": {}, - "enterasys": {}, - "ericsson_ipos": {}, - "extreme": {}, - "extreme_ers": {}, - "extreme_exos": {}, - "extreme_netiron": {}, - "extreme_nos": {}, - "extreme_slx": {}, - "extreme_vdx": {}, - "extreme_vsp": {}, - "extreme_wing": {}, - "f5_ltm": {}, - "f5_tmsh": {}, - "f5_linux": {}, - "flexvnf": {}, - "fortinet": {}, - "generic": {}, - "generic_termserver": {}, - "hp_comware": {}, - "hp_procurve": {}, - "huawei": {}, - "huawei_smartax": {}, - "huawei_olt": {}, - "huawei_vrpv8": {}, - "ipinfusion_ocnos": {}, - "juniper": {}, - "juniper_junos": {}, - "juniper_screenos": {}, - "keymile": {}, - "keymile_nos": {}, - "linux": {}, - "mikrotik_routeros": {}, - "mikrotik_switchos": {}, - "mellanox": {}, - "mellanox_mlnxos": {}, - "mrv_lx": {}, - "mrv_optiswitch": {}, - "netapp_cdot": {}, - "netgear_prosafe": {}, - "netscaler": {}, - "nokia_sros": {}, - "oneaccess_oneos": {}, - "ovs_linux": {}, - "paloalto_panos": {}, - "pluribus": {}, - "quanta_mesh": {}, - "rad_etx": {}, - "raisecom_roap": {}, - "ruckus_fastiron": {}, - "ruijie_os": {}, - "sixwind_os": {}, - "sophos_sfos": {}, - "tplink_jetstream": {}, - "ubiquiti_edge": {}, - "ubiquiti_edgerouter": {}, - "ubiquiti_edgeswitch": {}, - "ubiquiti_unifiswitch": {}, - "vyatta_vyos": {}, - "vyos": {}, - "watchguard_fireware": {}, - "zte_zxros": {}, - "yamaha": {}, +# Normalized | Netmiko +NETMIKO_LIB_MAPPER: t.Dict[str, str] = { + "a10": "a10", + "accedian": "accedian", + "adtran_os": "adtran_os", + "alcatel_aos": "alcatel_aos", + "alcatel_sros": "alcatel_sros", + "allied_telesis_awplus": "allied_telesis_awplus", + "apresia_aeos": "apresia_aeos", + "arista_eos": "arista_eos", + "aruba_os": "aruba_os", + "aruba_osswitch": "aruba_osswitch", + "aruba_procurve": "aruba_procurve", + "avaya_ers": "avaya_ers", + "avaya_vsp": "avaya_vsp", + "bigip_f5": "bigip_f5", # not in netmiko + "broadcom_icos": "broadcom_icos", + "brocade_fastiron": "brocade_fastiron", + "brocade_fos": "brocade_fos", + "brocade_netiron": "brocade_netiron", + "brocade_nos": "brocade_nos", + "brocade_vdx": "brocade_vdx", + "brocade_vyos": "brocade_vyos", + "calix_b6": "calix_b6", + "centec_os": "centec_os", + "checkpoint_gaia": "checkpoint_gaia", + "ciena_saos": "ciena_saos", + "cisco_asa": "cisco_asa", + "cisco_ftd": "cisco_ftd", + "cisco_ios": "cisco_ios", + "cisco_nxos": "cisco_nxos", + "cisco_s300": "cisco_s300", + "cisco_tp": "cisco_tp", + "cisco_wlc": "cisco_wlc", + "cisco_xe": "cisco_xe", + "cisco_xr": "cisco_xr", + "cloudgenix_ion": "cloudgenix_ion", + "coriant": "coriant", + "dell_dnos9": "dell_dnos9", + "dell_force10": "dell_force10", + "dell_isilon": "dell_isilon", + "dell_os10": "dell_os10", + "dell_os6": "dell_os6", + "dell_os9": "dell_os9", + "dell_powerconnect": "dell_powerconnect", + "dlink_ds": "dlink_ds", + "eltex": "eltex", + "eltex_esr": "eltex_esr", + "endace": "endace", + "enterasys": "enterasys", + "ericsson_ipos": "ericsson_ipos", + "extreme": "extreme", + "extreme_ers": "extreme_ers", + "extreme_exos": "extreme_exos", + "extreme_netiron": "extreme_netiron", + "extreme_nos": "extreme_nos", + "extreme_slx": "extreme_slx", + "extreme_vdx": "extreme_vdx", + "extreme_vsp": "extreme_vsp", + "extreme_wing": "extreme_wing", + "f5_linux": "bigip_f5", # no reverse + "f5_ltm": "bigip_f5", # no reverse + "f5_tmsh": "bigip_f5", # no reverse + "flexvnf": "flexvnf", + "fortinet": "fortinet", + "generic": "generic", + "generic_termserver": "generic_termserver", + "hp_comware": "hp_comware", + "hp_procurve": "hp_procurve", + "huawei": "huawei", + "huawei_olt": "huawei_olt", + "huawei_smartax": "huawei_smartax", + "huawei_vrpv8": "huawei_vrpv8", + "ipinfusion_ocnos": "ipinfusion_ocnos", + "juniper": "juniper", + "juniper_junos": "juniper_junos", + "juniper_screenos": "juniper_screenos", + "keymile": "keymile", + "keymile_nos": "keymile_nos", + "linux": "linux", + "mellanox": "mellanox", + "mellanox_mlnxos": "mellanox_mlnxos", + "mikrotik_routeros": "mikrotik_routeros", + "mikrotik_switchos": "mikrotik_switchos", + "mrv_lx": "mrv_lx", + "mrv_optiswitch": "mrv_optiswitch", + "netapp_cdot": "netapp_cdot", + "netgear_prosafe": "netgear_prosafe", + "netscaler": "netscaler", + "nokia_sros": "nokia_sros", + "oneaccess_oneos": "oneaccess_oneos", + "ovs_linux": "ovs_linux", + "paloalto_panos": "paloalto_panos", + "pluribus": "pluribus", + "quanta_mesh": "quanta_mesh", + "rad_etx": "rad_etx", + "raisecom_roap": "raisecom_roap", + "ruckus_fastiron": "ruckus_fastiron", + "ruijie_os": "ruijie_os", + "sixwind_os": "sixwind_os", + "sophos_sfos": "sophos_sfos", + "tplink_jetstream": "tplink_jetstream", + "ubiquiti_edge": "ubiquiti_edge", + "ubiquiti_edgerouter": "ubiquiti_edgerouter", + "ubiquiti_edgeswitch": "ubiquiti_edgeswitch", + "ubiquiti_unifiswitch": "ubiquiti_unifiswitch", + "vyatta_vyos": "vyatta_vyos", + "vyos": "vyos", + "watchguard_fireware": "watchguard_fireware", + "yamaha": "yamaha", + "zte_zxros": "zte_zxros", } # netmiko is the base name, so every key is a value, this ensure that. -NETMIKO_LIB_MAPPER = {key: key for key in sorted(_NETMIKO_LIB_MAPPER)} +# Netmiko | Normalized +NETMIKO_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + value: key for key, value in NETMIKO_LIB_MAPPER.items() if key not in ["f5_ltm", "f5_tmsh", "f5_linux"] +} # ntc templates is primarily based on netmiko, so a copy is in order _NTCTEMPLATES_LIB_MAPPER = copy.deepcopy(NETMIKO_LIB_MAPPER) @@ -254,10 +248,19 @@ _NTCTEMPLATES_LIB_MAPPER["huawei_vrp"] = "huawei_vrp" _NTCTEMPLATES_LIB_MAPPER["vmware_nsxv"] = "vmware_nsxv" _NTCTEMPLATES_LIB_MAPPER["watchguard_firebox"] = "watchguard_firebox" -NTCTEMPLATES_LIB_MAPPER = {key: _NTCTEMPLATES_LIB_MAPPER[key] for key in sorted(_NTCTEMPLATES_LIB_MAPPER)} + +# NTCTemplates | Normalized +NTCTEMPLATES_LIB_MAPPER: t.Dict[str, str] = { + key: _NTCTEMPLATES_LIB_MAPPER[key] for key in sorted(_NTCTEMPLATES_LIB_MAPPER) +} +# Normalized | NTCTemplates +NTCTEMPLATES_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + value: key for key, value in NTCTEMPLATES_LIB_MAPPER.items() if key not in ["f5_ltm", "f5_tmsh", "f5_linux"] +} + # NAPALM | Normalized -NAPALM_LIB_MAPPER = { +NAPALM_LIB_MAPPER: t.Dict[str, str] = { "aoscx": "aruba_aoscx", "asa": "cisco_asa", "cisco_wlc_ssh": "cisco_wlc", @@ -269,26 +272,26 @@ "iosxr": "cisco_xr", "junos": "juniper_junos", "nxos": "cisco_nxos", - "nxos_ssh": "cisco_nxos", + "nxos_ssh": "cisco_nxos", # no reverse "panos": "paloalto_panos", "ros": "mikrotik_routeros", "sros": "nokia_sros", - "vyos": "brocade_vyos", + "vyos": "vyos", } # PYTNC | Normalized -PYNTC_LIB_MAPPER = { +PYNTC_LIB_MAPPER: t.Dict[str, str] = { "arista_eos_eapi": "arista_eos", "cisco_aireos_ssh": "cisco_wlc", "cisco_asa_ssh": "cisco_asa", "cisco_ios_ssh": "cisco_ios", "cisco_nxos_nxapi": "cisco_nxos", - "f5_tmos_icontrol": "f5_tmsh", + "f5_tmos_icontrol": "bigip_f5", "juniper_junos_netconf": "juniper_junos", } # Ansible | Normalized -ANSIBLE_LIB_MAPPER = { +ANSIBLE_LIB_MAPPER: t.Dict[str, str] = { "a10.acos_axapi.a10": "a10", "arista.eos.eos": "arista_eos", "arubanetworks.aoscx": "aruba_aoscx", @@ -323,9 +326,9 @@ } # PYATS | Normalized -PYATS_LIB_MAPPER = { +PYATS_LIB_MAPPER: t.Dict[str, str] = { "asa": "cisco_asa", - "bigip": "f5_tmsh", + "bigip": "bigip_f5", "dnac": "cisco_dnac", "ios": "cisco_ios", "iosxe": "cisco_ios", @@ -338,7 +341,7 @@ } # SCRAPLI | Normalized -SCRAPLI_LIB_MAPPER = { +SCRAPLI_LIB_MAPPER: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "cisco_iosxe": "cisco_ios", @@ -348,17 +351,19 @@ } # HIERCONFIG | Normalized -HIERCONFIG_LIB_MAPPER = { +HIERCONFIG_LIB_MAPPER: t.Dict[str, str] = { "eos": "arista_eos", "fastiron": "ruckus_fastiron", "ios": "cisco_ios", - "iosxe": "cisco_xe", + "iosxe": "cisco_ios", # no reverse "iosxr": "cisco_xr", + "junos": "juniper_junos", "nxos": "cisco_nxos", + "vyos": "vyos", } # Netutils Parser | Normalized -NETUTILSPARSER_LIB_MAPPER = { +NETUTILSPARSER_LIB_MAPPER: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "bigip_f5": "bigip_f5", @@ -369,7 +374,8 @@ "cisco_nxos": "cisco_nxos", "citrix_netscaler": "citrix_netscaler", "extreme_netiron": "extreme_netiron", - "fortinet_fortios": "fortinet_fortios", + "fortinet_fortios": "fortinet", + "hp_comware": "hp_comware", "juniper_junos": "juniper_junos", "linux": "linux", "mikrotik_routeros": "mikrotik_routeros", @@ -382,69 +388,69 @@ } # Forward Networks Parser | Normalized -FORWARDNETWORKS_LIB_MAPPER = { +FORWARDNETWORKS_LIB_MAPPER: t.Dict[str, str] = { "ARISTA_EOS": "arista_eos", "ARUBA_SWITCH": "aruba_aoscx", "ASA": "cisco_asa", "EXTREME_NOS": "extreme_netiron", - "FORTINET": "fortinet_fortios", "F5": "bigip_f5", + "FORTINET": "fortinet", "IOS": "cisco_ios", - "IOS_XE": "cisco_ios", - "IOS_XR": "cisco_iosxr", + "IOS_XE": "cisco_ios", # no reverse + "IOS_XR": "cisco_xr", "JUNOS": "juniper_junos", "LINUX": "linux", - "LINUX_OVS_OFCTL": "linux", + "LINUX_OVS_OFCTL": "linux", # no reverse "NETSCALER": "netscaler", "NXOS": "cisco_nxos", "PAN_OS": "paloalto_panos", - "SRX": "juniper_junos", + "SRX": "juniper_junos", # no reverse } # Normalized | NAPALM -NAPALM_LIB_MAPPER_REVERSE = { +NAPALM_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "eos", "aruba_aoscx": "aoscx", "bigip_f5": "f5", - "brocade_vyos": "vyos", "cisco_asa": "asa", "cisco_ios": "ios", "cisco_nxos": "nxos", "cisco_wlc": "cisco_wlc_ssh", + "cisco_xe": "ios", # no reverse "cisco_xr": "iosxr", - "cisco_xe": "cisco_ios", "fortinet": "fortios", "huawei": "huawei_vrp", "juniper_junos": "junos", "mikrotik_routeros": "ros", "nokia_sros": "sros", "paloalto_panos": "panos", + "vyos": "vyos", } # Normalized | PYTNC -PYNTC_LIB_MAPPER_REVERSE = { +PYNTC_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista_eos_eapi", + "bigip_f5": "f5_tmos_icontrol", "cisco_asa": "cisco_asa_ssh", "cisco_ios": "cisco_ios_ssh", - "cisco_xe": "cisco_ios_ssh", "cisco_nxos": "cisco_nxos_nxapi", "cisco_wlc": "cisco_aireos_ssh", - "f5_tmsh": "f5_tmos_icontrol", + "cisco_xe": "cisco_ios_ssh", # no reverse "juniper_junos": "juniper_junos_netconf", } # Normalized | ANSIBLE -ANSIBLE_LIB_MAPPER_REVERSE = { +ANSIBLE_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "a10": "a10.acos_axapi.a10", "arista_eos": "arista.eos.eos", "aruba_aoscx": "arubanetworks.aoscx", "bigip_f5": "f5networks.f5_bigip.bigip", "ciena_saos": "ciena.saos6.saos6", "cisco_asa": "cisco.asa.asa", - "cisco_xe": "cisco.ios.ios", "cisco_ios": "cisco.ios.ios", "cisco_meraki": "cisco.meraki.meraki", "cisco_nxos": "cisco.nxos.nxos", + "cisco_xe": "cisco.ios.ios", # no reverse "cisco_xr": "cisco.iosxr.iosxr", "dell_os10": "dellemc.os10.0s10", "dell_os6": "dellemc.os6.os6", @@ -470,42 +476,45 @@ } # Normalized | PYATS -PYATS_LIB_MAPPER_REVERSE = { +PYATS_LIB_MAPPER_REVERSE: t.Dict[str, str] = { + "bigip_f5": "bigip", "cisco_asa": "asa", "cisco_dnac": "dnac", "cisco_ios": "iosxe", "cisco_nxos": "nxos", - "cisco_xe": "iosxe", "cisco_viptella": "viptela", + "cisco_xe": "iosxe", # no reverse "cisco_xr": "iosxr", - "f5_tmsh": "bigip", "juniper_junos": "junos", "linux": "linux", "nokia_sros": "sros", } # Normalized | Scrapli -SCRAPLI_LIB_MAPPER_REVERSE = { +SCRAPLI_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "cisco_ios": "cisco_iosxe", "cisco_nxos": "cisco_nxos", + "cisco_xe": "cisco_iosxe", "cisco_xr": "cisco_iosxr", "juniper_junos": "juniper_junos", } # Normalized | HIERCONFIG -HIERCONFIG_LIB_MAPPER_REVERSE = { +HIERCONFIG_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "eos", "cisco_ios": "ios", "cisco_nxos": "nxos", - "cisco_xe": "iosxe", + "cisco_xe": "ios", "cisco_xr": "iosxr", + "juniper_junos": "junos", "ruckus_fastiron": "fastiron", + "vyos": "vyos", } # Normalized | Netutils Parser -NETUTILSPARSER_LIB_MAPPER_REVERSE = { +NETUTILSPARSER_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "arista_eos", "aruba_aoscx": "aruba_aoscx", "bigip_f5": "bigip_f5", @@ -513,10 +522,12 @@ "cisco_asa": "cisco_asa", "cisco_ios": "cisco_ios", "cisco_nxos": "cisco_nxos", + "cisco_xe": "cisco_ios", "cisco_xr": "cisco_iosxr", "citrix_netscaler": "citrix_netscaler", "extreme_netiron": "extreme_netiron", - "fortinet_fortios": "fortinet_fortios", + "fortinet": "fortinet_fortios", + "hp_comware": "hp_comware", "juniper_junos": "juniper_junos", "linux": "linux", "mikrotik_routeros": "mikrotik_routeros", @@ -529,40 +540,51 @@ } # Normalized | Forward Networks Parser -FORWARDNETWORKS_LIB_MAPPER_REVERSE = { +FORWARDNETWORKS_LIB_MAPPER_REVERSE: t.Dict[str, str] = { "arista_eos": "ARISTA_EOS", "aruba_aoscx": "ARUBA_SWITCH", "bigip_f5": "F5", "cisco_asa": "ASA", "cisco_ios": "IOS", - "cisco_iosxr": "IOS_XR", "cisco_nxos": "NXOS", + "cisco_xe": "IOS", + "cisco_xr": "IOS_XR", "extreme_netiron": "EXTREME_NOS", - "fortinet_fortios": "FORTINET", + "fortinet": "FORTINET", "juniper_junos": "JUNOS", "linux": "LINUX", "netscaler": "NETSCALER", "paloalto_panos": "PAN_OS", } -# Deep copy the reverse, where there is no actual translation happening. -NETMIKO_LIB_MAPPER_REVERSE = copy.deepcopy(NETMIKO_LIB_MAPPER) -NTCTEMPLATES_LIB_MAPPER_REVERSE = copy.deepcopy(NTCTEMPLATES_LIB_MAPPER) - - # Deep copy the reverse, where there is no actual translation happening with special # consideration for OS's not in netmiko. _MAIN_LIB_MAPPER = copy.deepcopy(NETMIKO_LIB_MAPPER) _MAIN_LIB_MAPPER["aruba_aoscx"] = "aruba_aoscx" +_MAIN_LIB_MAPPER["cisco_aireos"] = "cisco_aireos" _MAIN_LIB_MAPPER["cisco_dnac"] = "cisco_dnac" _MAIN_LIB_MAPPER["cisco_meraki"] = "cisco_meraki" _MAIN_LIB_MAPPER["cisco_viptella"] = "cisco_viptella" +_MAIN_LIB_MAPPER["citrix_netscaler"] = "citrix_netscaler" +_MAIN_LIB_MAPPER["cloudarmor"] = "cloudarmor" +_MAIN_LIB_MAPPER["gce"] = "gce" +_MAIN_LIB_MAPPER["gcp_hf"] = "gcp_hf" _MAIN_LIB_MAPPER["huawei_vrp"] = "huawei_vrp" +_MAIN_LIB_MAPPER["ipset"] = "ipset" +_MAIN_LIB_MAPPER["iptables"] = "iptables" +_MAIN_LIB_MAPPER["k8s"] = "k8s" _MAIN_LIB_MAPPER["lenovo_cnos"] = "lenovo_cnos" _MAIN_LIB_MAPPER["lenovo_enos"] = "lenovo_enos" +_MAIN_LIB_MAPPER["openconfig"] = "openconfig" +_MAIN_LIB_MAPPER["packetfilter"] = "packetfilter" +_MAIN_LIB_MAPPER["pcap"] = "pcap" +_MAIN_LIB_MAPPER["speedway"] = "speedway" _MAIN_LIB_MAPPER["ruckus_icx"] = "ruckus_icx" _MAIN_LIB_MAPPER["ruckus_smartzone"] = "ruckus_smartzone" _MAIN_LIB_MAPPER["sonic"] = "sonic" +_MAIN_LIB_MAPPER["ubiquiti_airos"] = "ubiquiti_airos" _MAIN_LIB_MAPPER["vmware_nsxv"] = "vmware_nsxv" +_MAIN_LIB_MAPPER["vmware_nsxt"] = "vmware_nsxt" _MAIN_LIB_MAPPER["watchguard_firebox"] = "watchguard_firebox" -MAIN_LIB_MAPPER = {key: _MAIN_LIB_MAPPER[key] for key in sorted(_MAIN_LIB_MAPPER)} +_MAIN_LIB_MAPPER["windows"] = "windows" +MAIN_LIB_MAPPER: t.Dict[str, str] = {key: _MAIN_LIB_MAPPER[key] for key in sorted(_MAIN_LIB_MAPPER)} diff --git a/netutils/os_version.py b/netutils/os_version.py index 09268de9..1fb5da6a 100644 --- a/netutils/os_version.py +++ b/netutils/os_version.py @@ -1,13 +1,10 @@ """Functions for working with OS Versions.""" import typing as t -from distutils.version import LooseVersion # pylint: disable=deprecated-module +from netutils._private.version import LooseVersion, StrictVersion # type: ignore -def get_upgrade_path( - current_version: str, - target_version: str, - firmware_list: t.List[str], -) -> t.List[str]: + +def get_upgrade_path(current_version: str, target_version: str, firmware_list: t.List[str]) -> t.List[str]: """Utility to return the upgrade path from the current to target firmware version. Returns: @@ -47,3 +44,86 @@ def get_upgrade_path( upgrade_path.append(target_version) return upgrade_path + + +def _compare_version(current_version: str, comparison: str, target_version: str, version_type: str) -> bool: + # Convert version strings to Version objects for comparison + if version_type == "loose": + current_ver_obj = LooseVersion(current_version) + target_ver_obj = LooseVersion(target_version) + elif version_type == "strict": + current_ver_obj = StrictVersion(current_version) + target_ver_obj = StrictVersion(target_version) + + # Perform the comparison based on the comparison operation + if comparison == "<": + return bool(current_ver_obj < target_ver_obj) + if comparison == "<=": + return bool(current_ver_obj <= target_ver_obj) + if comparison == "==": + return bool(current_ver_obj == target_ver_obj) + if comparison == "!=": + return bool(current_ver_obj != target_ver_obj) + if comparison == ">": + return bool(current_ver_obj > target_ver_obj) + if comparison == ">=": + return bool(current_ver_obj >= target_ver_obj) + raise ValueError(f"Invalid comparison operator: {comparison}") + + +def compare_version_loose(current_version: str, comparison: str, target_version: str) -> bool: + """ + Compares two version strings using the specified comparison operation, based on LooseVersion. + + Args: + current_version (str): The current version string to compare. + comparison (str): The comparison operation as a string (<, <=, ==, !=, >, >=). + target_version (str): The target version string to compare against. + + Returns: + bool: The result of the comparison. + + Raises: + ValueError: If there is an invalid comparison. + TypeError: If not a valid version. + + Example: + >>> from netutils.os_version import compare_version_loose + >>> compare_version_loose("3.3.3a", "==", "3.3.3a") + True + >>> compare_version_loose("3.3.2", "<=", "3.3.3") + True + >>> compare_version_loose("3.3.2", ">=", "3.3.3") + False + >>> + """ + return _compare_version(current_version, comparison, target_version, "loose") + + +def compare_version_strict(current_version: str, comparison: str, target_version: str) -> bool: + """ + Compares two version strings using the specified comparison operation, based on LooseVersion. + + Args: + current_version (str): The current version string to compare. + comparison (str): The comparison operation as a string (<, <=, ==, !=, >, >=). + target_version (str): The target version string to compare against. + + Returns: + bool: The result of the comparison. + + Raises: + ValueError: If there is an invalid comparison. + ValueError: If not a valid version. + + Example: + >>> from netutils.os_version import compare_version_strict + >>> compare_version_strict("3.3.3", "==", "3.3.3") + True + >>> compare_version_strict("3.3.2", "<=", "3.3.3") + True + >>> compare_version_strict("3.3.2", ">=", "3.3.3") + False + >>> + """ + return _compare_version(current_version, comparison, target_version, "strict") diff --git a/netutils/protocol_mapper.py b/netutils/protocol_mapper.py index 74f9ea28..4f3bceef 100644 --- a/netutils/protocol_mapper.py +++ b/netutils/protocol_mapper.py @@ -2,6 +2,10 @@ import typing as t from netutils.constants import PROTOCOLS +from netutils.data_files.protocol_number_mappings import ( # noqa: F401 # pylint:disable=unused-import + PROTO_NAME_TO_NUM, + PROTO_NUM_TO_NAME, +) def _number_to_name_mapper(proto: str) -> t.Dict[int, str]: @@ -46,134 +50,3 @@ def _number_to_name_mapper(proto: str) -> t.Dict[int, str]: # DCCP port name to number mapping DCCP_NAME_TO_NUM = {value: key for (key, value) in DCCP_NUM_TO_NAME.items()} - -"""Mappers used to take protocol number-->name and vice-versa. Number needed for test command, name needed for test command if querying by application-id.""" - -# Protocol mapping based on https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml. -PROTO_NAME_TO_NUM = { - "ICMP": 1, - "IGMP": 2, - "GGP": 3, - "TCP": 6, - "CBT": 7, - "EGP": 8, - "IGP": 9, - "BBN-RCC-MON": 10, - "NVP-II": 11, - "PUP": 12, - "EMCON": 14, - "XNET": 15, - "CHAOS": 16, - "UDP": 17, - "MUX": 18, - "DCN-MEAS": 19, - "HMP": 20, - "PRM": 21, - "XNS-IDP": 22, - "TRUNK-1": 23, - "TRUNK-2": 24, - "LEAF-1": 25, - "LEAF-2": 26, - "RDP": 27, - "IRTP": 28, - "ISO-TP4": 29, - "NETBLT": 30, - "MFE-NSP": 31, - "MERIT-INP": 32, - "DCCP": 33, - "3PC": 34, - "IDPR": 35, - "XTP": 36, - "DDP": 37, - "IDPR-CMTP": 38, - "TP++": 39, - "IL": 40, - "SDRP": 42, - "IDRP": 45, - "RSVP": 46, - "GRE": 47, - "DSR": 48, - "BNA": 49, - "ESP": 50, - "AH": 51, - "I-NLSP": 52, - "NARP": 54, - "MOBILE": 55, - "TLSP": 56, - "SKIP": 57, - "CFTP": 62, - "SAT-EXPAK": 64, - "KRYPTOLAN": 65, - "RVD": 66, - "IPPC": 67, - "SAT-MON": 69, - "VISA": 70, - "IPCV": 71, - "CPNX": 72, - "CPHB": 73, - "WSN": 74, - "PVP": 75, - "BR-SAT-MON": 76, - "SUN-ND": 77, - "WB-MON": 78, - "WB-EXPAK": 79, - "ISO-IP": 80, - "VMTP": 81, - "SECURE-VMTP": 82, - "VINES": 83, - "TTP": 84, - "NSFNET-IGP": 85, - "DGP": 86, - "TCF": 87, - "EIGRP": 88, - "OSPFIGP": 89, - "Sprite-RPC": 90, - "LARP": 91, - "MTP": 92, - "AX.25": 93, - "IPIP": 94, - "SCC-SP": 96, - "ETHERIP": 97, - "ENCAP": 98, - "GMTP": 100, - "IFMP": 101, - "PNNI": 102, - "PIM": 103, - "ARIS": 104, - "SCPS": 105, - "QNX": 106, - "A/N": 107, - "IPComp": 108, - "SNP": 109, - "Compaq-Peer": 110, - "IPX-in-IP": 111, - "PGM": 113, - "L2TP": 115, - "DDX": 116, - "IATP": 117, - "STP": 118, - "SRP": 119, - "UTI": 120, - "SMP": 121, - "SM": 122, - "PTP": 123, - "FIRE": 125, - "CRTP": 126, - "CRUDP": 127, - "SSCOPMCE": 128, - "IPLT": 129, - "SPS": 130, - "PIPE": 131, - "SCTP": 132, - "FC": 133, - "RSVP-E2E-IGNORE": 134, - "UDPLite": 136, - "manet": 138, - "HIP": 139, - "WESP": 141, - "ROHC": 142, - "Ethernet": 143, -} - -# Reverse the key value pair for reverse lookup. -PROTO_NUM_TO_NAME = {value: key for (key, value) in PROTO_NAME_TO_NUM.items()} diff --git a/netutils/utils.py b/netutils/utils.py index 4f163da7..602324e2 100644 --- a/netutils/utils.py +++ b/netutils/utils.py @@ -86,7 +86,10 @@ "uptime_seconds_to_string": "time.uptime_seconds_to_string", "uptime_string_to_seconds": "time.uptime_string_to_seconds", "get_napalm_getters": "lib_helpers.get_napalm_getters", + "paloalto_panos_clean_newlines": "config.conversion.paloalto_panos_clean_newlines", "paloalto_panos_brace_to_set": "config.conversion.paloalto_panos_brace_to_set", + "compare_version_loose": "os_version.compare_version_loose", + "compare_version_strict": "os_version.compare_version_strict", "get_upgrade_path": "os_version.get_upgrade_path", "hash_data": "hash.hash_data", "get_ips_sorted": "ip.get_ips_sorted", diff --git a/poetry.lock b/poetry.lock index 9130579b..6e6a72d6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,23 +1,18 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "astroid" -version = "2.15.6" +version = "3.1.0" description = "An abstract syntax tree for Python with inference support." optional = false -python-versions = ">=3.7.2" +python-versions = ">=3.8.0" files = [ - {file = "astroid-2.15.6-py3-none-any.whl", hash = "sha256:389656ca57b6108f939cf5d2f9a2a825a3be50ba9d589670f393236e0a03b91c"}, - {file = "astroid-2.15.6.tar.gz", hash = "sha256:903f024859b7c7687d7a7f3a3f73b17301f8e42dfd9cc9df9d4418172d3e2dbd"}, + {file = "astroid-3.1.0-py3-none-any.whl", hash = "sha256:951798f922990137ac090c53af473db7ab4e70c770e6d7fae0cec59f74411819"}, + {file = "astroid-3.1.0.tar.gz", hash = "sha256:ac248253bfa4bd924a0de213707e7ebeeb3138abeb48d798784ead1e56d419d4"}, ] [package.dependencies] -lazy-object-proxy = ">=1.4.0" typing-extensions = {version = ">=4.0.0", markers = "python_version < \"3.11\""} -wrapt = [ - {version = ">=1.11,<2", markers = "python_version < \"3.11\""}, - {version = ">=1.14,<2", markers = "python_version >= \"3.11\""}, -] [[package]] name = "astunparse" @@ -533,19 +528,19 @@ test = ["pytest (>=6)"] [[package]] name = "flake8" -version = "5.0.4" +version = "7.0.0" description = "the modular source code checker: pep8 pyflakes and co" optional = false -python-versions = ">=3.6.1" +python-versions = ">=3.8.1" files = [ - {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, - {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, + {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, + {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, ] [package.dependencies] mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.9.0,<2.10.0" -pyflakes = ">=2.5.0,<2.6.0" +pycodestyle = ">=2.11.0,<2.12.0" +pyflakes = ">=3.2.0,<3.3.0" [[package]] name = "future" @@ -783,51 +778,6 @@ six = "*" transitions = "*" yamlordereddictloader = "*" -[[package]] -name = "lazy-object-proxy" -version = "1.9.0" -description = "A fast and thorough lazy object proxy." -optional = false -python-versions = ">=3.7" -files = [ - {file = "lazy-object-proxy-1.9.0.tar.gz", hash = "sha256:659fb5809fa4629b8a1ac5106f669cfc7bef26fbb389dda53b3e010d1ac4ebae"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b40387277b0ed2d0602b8293b94d7257e17d1479e257b4de114ea11a8cb7f2d7"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e8c6cfb338b133fbdbc5cfaa10fe3c6aeea827db80c978dbd13bc9dd8526b7d4"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:721532711daa7db0d8b779b0bb0318fa87af1c10d7fe5e52ef30f8eff254d0cd"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:66a3de4a3ec06cd8af3f61b8e1ec67614fbb7c995d02fa224813cb7afefee701"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:1aa3de4088c89a1b69f8ec0dcc169aa725b0ff017899ac568fe44ddc1396df46"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-win32.whl", hash = "sha256:f0705c376533ed2a9e5e97aacdbfe04cecd71e0aa84c7c0595d02ef93b6e4455"}, - {file = "lazy_object_proxy-1.9.0-cp310-cp310-win_amd64.whl", hash = "sha256:ea806fd4c37bf7e7ad82537b0757999264d5f70c45468447bb2b91afdbe73a6e"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:946d27deaff6cf8452ed0dba83ba38839a87f4f7a9732e8f9fd4107b21e6ff07"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:79a31b086e7e68b24b99b23d57723ef7e2c6d81ed21007b6281ebcd1688acb0a"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f699ac1c768270c9e384e4cbd268d6e67aebcfae6cd623b4d7c3bfde5a35db59"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bfb38f9ffb53b942f2b5954e0f610f1e721ccebe9cce9025a38c8ccf4a5183a4"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:189bbd5d41ae7a498397287c408617fe5c48633e7755287b21d741f7db2706a9"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-win32.whl", hash = "sha256:81fc4d08b062b535d95c9ea70dbe8a335c45c04029878e62d744bdced5141586"}, - {file = "lazy_object_proxy-1.9.0-cp311-cp311-win_amd64.whl", hash = "sha256:f2457189d8257dd41ae9b434ba33298aec198e30adf2dcdaaa3a28b9994f6adb"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:d9e25ef10a39e8afe59a5c348a4dbf29b4868ab76269f81ce1674494e2565a6e"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cbf9b082426036e19c6924a9ce90c740a9861e2bdc27a4834fd0a910742ac1e8"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9f5fa4a61ce2438267163891961cfd5e32ec97a2c444e5b842d574251ade27d2"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:8fa02eaab317b1e9e03f69aab1f91e120e7899b392c4fc19807a8278a07a97e8"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:e7c21c95cae3c05c14aafffe2865bbd5e377cfc1348c4f7751d9dc9a48ca4bda"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-win32.whl", hash = "sha256:f12ad7126ae0c98d601a7ee504c1122bcef553d1d5e0c3bfa77b16b3968d2734"}, - {file = "lazy_object_proxy-1.9.0-cp37-cp37m-win_amd64.whl", hash = "sha256:edd20c5a55acb67c7ed471fa2b5fb66cb17f61430b7a6b9c3b4a1e40293b1671"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:2d0daa332786cf3bb49e10dc6a17a52f6a8f9601b4cf5c295a4f85854d61de63"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9cd077f3d04a58e83d04b20e334f678c2b0ff9879b9375ed107d5d07ff160171"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:660c94ea760b3ce47d1855a30984c78327500493d396eac4dfd8bd82041b22be"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:212774e4dfa851e74d393a2370871e174d7ff0ebc980907723bb67d25c8a7c30"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f0117049dd1d5635bbff65444496c90e0baa48ea405125c088e93d9cf4525b11"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-win32.whl", hash = "sha256:0a891e4e41b54fd5b8313b96399f8b0e173bbbfc03c7631f01efbe29bb0bcf82"}, - {file = "lazy_object_proxy-1.9.0-cp38-cp38-win_amd64.whl", hash = "sha256:9990d8e71b9f6488e91ad25f322898c136b008d87bf852ff65391b004da5e17b"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9e7551208b2aded9c1447453ee366f1c4070602b3d932ace044715d89666899b"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5f83ac4d83ef0ab017683d715ed356e30dd48a93746309c8f3517e1287523ef4"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7322c3d6f1766d4ef1e51a465f47955f1e8123caee67dd641e67d539a534d006"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:18b78ec83edbbeb69efdc0e9c1cb41a3b1b1ed11ddd8ded602464c3fc6020494"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:09763491ce220c0299688940f8dc2c5d05fd1f45af1e42e636b2e8b2303e4382"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-win32.whl", hash = "sha256:9090d8e53235aa280fc9239a86ae3ea8ac58eff66a705fa6aa2ec4968b95c821"}, - {file = "lazy_object_proxy-1.9.0-cp39-cp39-win_amd64.whl", hash = "sha256:db1c1722726f47e10e0b5fdbf15ac3b8adb58c091d12b3ab713965795036985f"}, -] - [[package]] name = "lxml" version = "4.9.3" @@ -1020,16 +970,6 @@ files = [ {file = "MarkupSafe-2.1.3-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:5bbe06f8eeafd38e5d0a4894ffec89378b6c6a625ff57e3028921f8ff59318ac"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win32.whl", hash = "sha256:dd15ff04ffd7e05ffcb7fe79f1b98041b8ea30ae9234aed2a9168b5797c3effb"}, {file = "MarkupSafe-2.1.3-cp311-cp311-win_amd64.whl", hash = "sha256:134da1eca9ec0ae528110ccc9e48041e0828d79f24121a1a146161103c76e686"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:f698de3fd0c4e6972b92290a45bd9b1536bffe8c6759c62471efaa8acb4c37bc"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:aa57bd9cf8ae831a362185ee444e15a93ecb2e344c8e52e4d721ea3ab6ef1823"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ffcc3f7c66b5f5b7931a5aa68fc9cecc51e685ef90282f4a82f0f5e9b704ad11"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:47d4f1c5f80fc62fdd7777d0d40a2e9dda0a05883ab11374334f6c4de38adffd"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1f67c7038d560d92149c060157d623c542173016c4babc0c1913cca0564b9939"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:9aad3c1755095ce347e26488214ef77e0485a3c34a50c5a5e2471dff60b9dd9c"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:14ff806850827afd6b07a5f32bd917fb7f45b046ba40c57abdb636674a8b559c"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8f9293864fe09b8149f0cc42ce56e3f0e54de883a9de90cd427f191c346eb2e1"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-win32.whl", hash = "sha256:715d3562f79d540f251b99ebd6d8baa547118974341db04f5ad06d5ea3eb8007"}, - {file = "MarkupSafe-2.1.3-cp312-cp312-win_amd64.whl", hash = "sha256:1b8dd8c3fd14349433c79fa8abeb573a55fc0fdd769133baac1f5e07abf54aeb"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:8e254ae696c88d98da6555f5ace2279cf7cd5b3f52be2b5cf97feafe883b58d2"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cb0932dc158471523c9637e807d9bfb93e06a95cbf010f1a38b98623b929ef2b"}, {file = "MarkupSafe-2.1.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9402b03f1a1b4dc4c19845e5c749e3ab82d5078d16a2a4c2cd2df62d57bb0707"}, @@ -1502,13 +1442,13 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "pycodestyle" -version = "2.9.1" +version = "2.11.1" description = "Python style guide checker" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, - {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, + {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, + {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, ] [[package]] @@ -1558,13 +1498,13 @@ test = ["coverage", "mock"] [[package]] name = "pyflakes" -version = "2.5.0" +version = "3.2.0" description = "passive checker of Python programs" optional = false -python-versions = ">=3.6" +python-versions = ">=3.8" files = [ - {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, - {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, + {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, + {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, ] [[package]] @@ -1583,23 +1523,24 @@ plugins = ["importlib-metadata"] [[package]] name = "pylint" -version = "2.17.5" +version = "3.1.0" description = "python code static checker" optional = false -python-versions = ">=3.7.2" +python-versions = ">=3.8.0" files = [ - {file = "pylint-2.17.5-py3-none-any.whl", hash = "sha256:73995fb8216d3bed149c8d51bba25b2c52a8251a2c8ac846ec668ce38fab5413"}, - {file = "pylint-2.17.5.tar.gz", hash = "sha256:f7b601cbc06fef7e62a754e2b41294c2aa31f1cb659624b9a85bcba29eaf8252"}, + {file = "pylint-3.1.0-py3-none-any.whl", hash = "sha256:507a5b60953874766d8a366e8e8c7af63e058b26345cfcb5f91f89d987fd6b74"}, + {file = "pylint-3.1.0.tar.gz", hash = "sha256:6a69beb4a6f63debebaab0a3477ecd0f559aa726af4954fc948c51f7a2549e23"}, ] [package.dependencies] -astroid = ">=2.15.6,<=2.17.0-dev0" +astroid = ">=3.1.0,<=3.2.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = [ {version = ">=0.2", markers = "python_version < \"3.11\""}, - {version = ">=0.3.6", markers = "python_version >= \"3.11\""}, + {version = ">=0.3.7", markers = "python_version >= \"3.12\""}, + {version = ">=0.3.6", markers = "python_version >= \"3.11\" and python_version < \"3.12\""}, ] -isort = ">=4.2.5,<6" +isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" mccabe = ">=0.6,<0.8" platformdirs = ">=2.2.0" tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} @@ -1759,7 +1700,6 @@ files = [ {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:69b023b2b4daa7548bcfbd4aa3da05b3a74b772db9e23b982788168117739938"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:81e0b275a9ecc9c0c0c07b4b90ba548307583c125f54d5b6946cfee6360c733d"}, {file = "PyYAML-6.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ba336e390cd8e4d1739f42dfe9bb83a3cc2e80f567d8805e11b46f4a943f5515"}, - {file = "PyYAML-6.0.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:326c013efe8048858a6d312ddd31d56e468118ad4cdeda36c719bf5bb6192290"}, {file = "PyYAML-6.0.1-cp310-cp310-win32.whl", hash = "sha256:bd4af7373a854424dabd882decdc5579653d7868b8fb26dc7d0e99f823aa5924"}, {file = "PyYAML-6.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:fd1592b3fdf65fff2ad0004b5e363300ef59ced41c2e6b3a99d4089fa8c5435d"}, {file = "PyYAML-6.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6965a7bc3cf88e5a1c3bd2e0b5c22f8d677dc88a455344035f03399034eb3007"}, @@ -1767,15 +1707,8 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:42f8152b8dbc4fe7d96729ec2b99c7097d656dc1213a3229ca5383f973a5ed6d"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:062582fca9fabdd2c8b54a3ef1c978d786e0f6b3a1510e0ac93ef59e0ddae2bc"}, {file = "PyYAML-6.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d2b04aac4d386b172d5b9692e2d2da8de7bfb6c387fa4f801fbf6fb2e6ba4673"}, - {file = "PyYAML-6.0.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:e7d73685e87afe9f3b36c799222440d6cf362062f78be1013661b00c5c6f678b"}, {file = "PyYAML-6.0.1-cp311-cp311-win32.whl", hash = "sha256:1635fd110e8d85d55237ab316b5b011de701ea0f29d07611174a1b42f1444741"}, {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, - {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, - {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, - {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, - {file = "PyYAML-6.0.1-cp312-cp312-win_amd64.whl", hash = "sha256:0d3304d8c0adc42be59c5f8a4d9e3d7379e6955ad754aa9d6ab7a398b59dd1df"}, {file = "PyYAML-6.0.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:50550eb667afee136e9a77d6dc71ae76a44df8b3e51e41b77f6de2932bfe0f47"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1fe35611261b29bd1de0070f0b2f47cb6ff71fa6595c077e42bd0c419fa27b98"}, {file = "PyYAML-6.0.1-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:704219a11b772aea0d8ecd7058d0082713c3562b4e271b849ad7dc4a5c90c13c"}, @@ -1792,7 +1725,6 @@ files = [ {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a0cd17c15d3bb3fa06978b4e8958dcdc6e0174ccea823003a106c7d4d7899ac5"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:28c119d996beec18c05208a8bd78cbe4007878c6dd15091efb73a30e90539696"}, {file = "PyYAML-6.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7e07cbde391ba96ab58e532ff4803f79c4129397514e1413a7dc761ccd755735"}, - {file = "PyYAML-6.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:49a183be227561de579b4a36efbb21b3eab9651dd81b1858589f796549873dd6"}, {file = "PyYAML-6.0.1-cp38-cp38-win32.whl", hash = "sha256:184c5108a2aca3c5b3d3bf9395d50893a7ab82a38004c8f61c258d4428e80206"}, {file = "PyYAML-6.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:1e2722cc9fbb45d9b87631ac70924c11d3a401b2d7f410cc0e3bbf249f2dca62"}, {file = "PyYAML-6.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:9eb6caa9a297fc2c2fb8862bc5370d0303ddba53ba97e71f08023b6cd73d16a8"}, @@ -1800,7 +1732,6 @@ files = [ {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5773183b6446b2c99bb77e77595dd486303b4faab2b086e7b17bc6bef28865f6"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b786eecbdf8499b9ca1d697215862083bd6d2a99965554781d0d8d1ad31e13a0"}, {file = "PyYAML-6.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bc1bf2925a1ecd43da378f4db9e4f799775d6367bdb94671027b73b393a7c42c"}, - {file = "PyYAML-6.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:04ac92ad1925b2cff1db0cfebffb6ffc43457495c9b3c39d3fcae417d7125dc5"}, {file = "PyYAML-6.0.1-cp39-cp39-win32.whl", hash = "sha256:faca3bdcf85b2fc05d06ff3fbc1f83e1391b3e724afa3feba7d13eeab355484c"}, {file = "PyYAML-6.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:510c9deebc5c0225e8c96813043e62b680ba2f9c50a08d3724c7f28a747d1486"}, {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, @@ -1852,99 +1783,104 @@ rpds-py = ">=0.7.0" [[package]] name = "regex" -version = "2023.8.8" +version = "2023.12.25" description = "Alternative regular expression module, to replace re." optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "regex-2023.8.8-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:88900f521c645f784260a8d346e12a1590f79e96403971241e64c3a265c8ecdb"}, - {file = "regex-2023.8.8-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:3611576aff55918af2697410ff0293d6071b7e00f4b09e005d614686ac4cd57c"}, - {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b8a0ccc8f2698f120e9e5742f4b38dc944c38744d4bdfc427616f3a163dd9de5"}, - {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c662a4cbdd6280ee56f841f14620787215a171c4e2d1744c9528bed8f5816c96"}, - {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cf0633e4a1b667bfe0bb10b5e53fe0d5f34a6243ea2530eb342491f1adf4f739"}, - {file = "regex-2023.8.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:551ad543fa19e94943c5b2cebc54c73353ffff08228ee5f3376bd27b3d5b9800"}, - {file = "regex-2023.8.8-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54de2619f5ea58474f2ac211ceea6b615af2d7e4306220d4f3fe690c91988a61"}, - {file = "regex-2023.8.8-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:5ec4b3f0aebbbe2fc0134ee30a791af522a92ad9f164858805a77442d7d18570"}, - {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:3ae646c35cb9f820491760ac62c25b6d6b496757fda2d51be429e0e7b67ae0ab"}, - {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:ca339088839582d01654e6f83a637a4b8194d0960477b9769d2ff2cfa0fa36d2"}, - {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:d9b6627408021452dcd0d2cdf8da0534e19d93d070bfa8b6b4176f99711e7f90"}, - {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:bd3366aceedf274f765a3a4bc95d6cd97b130d1dda524d8f25225d14123c01db"}, - {file = "regex-2023.8.8-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7aed90a72fc3654fba9bc4b7f851571dcc368120432ad68b226bd593f3f6c0b7"}, - {file = "regex-2023.8.8-cp310-cp310-win32.whl", hash = "sha256:80b80b889cb767cc47f31d2b2f3dec2db8126fbcd0cff31b3925b4dc6609dcdb"}, - {file = "regex-2023.8.8-cp310-cp310-win_amd64.whl", hash = "sha256:b82edc98d107cbc7357da7a5a695901b47d6eb0420e587256ba3ad24b80b7d0b"}, - {file = "regex-2023.8.8-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:1e7d84d64c84ad97bf06f3c8cb5e48941f135ace28f450d86af6b6512f1c9a71"}, - {file = "regex-2023.8.8-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:ce0f9fbe7d295f9922c0424a3637b88c6c472b75eafeaff6f910494a1fa719ef"}, - {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:06c57e14ac723b04458df5956cfb7e2d9caa6e9d353c0b4c7d5d54fcb1325c46"}, - {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e7a9aaa5a1267125eef22cef3b63484c3241aaec6f48949b366d26c7250e0357"}, - {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:9b7408511fca48a82a119d78a77c2f5eb1b22fe88b0d2450ed0756d194fe7a9a"}, - {file = "regex-2023.8.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:14dc6f2d88192a67d708341f3085df6a4f5a0c7b03dec08d763ca2cd86e9f559"}, - {file = "regex-2023.8.8-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:48c640b99213643d141550326f34f0502fedb1798adb3c9eb79650b1ecb2f177"}, - {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:0085da0f6c6393428bf0d9c08d8b1874d805bb55e17cb1dfa5ddb7cfb11140bf"}, - {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:964b16dcc10c79a4a2be9f1273fcc2684a9eedb3906439720598029a797b46e6"}, - {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:7ce606c14bb195b0e5108544b540e2c5faed6843367e4ab3deb5c6aa5e681208"}, - {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:40f029d73b10fac448c73d6eb33d57b34607f40116e9f6e9f0d32e9229b147d7"}, - {file = "regex-2023.8.8-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3b8e6ea6be6d64104d8e9afc34c151926f8182f84e7ac290a93925c0db004bfd"}, - {file = "regex-2023.8.8-cp311-cp311-win32.whl", hash = "sha256:942f8b1f3b223638b02df7df79140646c03938d488fbfb771824f3d05fc083a8"}, - {file = "regex-2023.8.8-cp311-cp311-win_amd64.whl", hash = "sha256:51d8ea2a3a1a8fe4f67de21b8b93757005213e8ac3917567872f2865185fa7fb"}, - {file = "regex-2023.8.8-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:e951d1a8e9963ea51efd7f150450803e3b95db5939f994ad3d5edac2b6f6e2b4"}, - {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:704f63b774218207b8ccc6c47fcef5340741e5d839d11d606f70af93ee78e4d4"}, - {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:22283c769a7b01c8ac355d5be0715bf6929b6267619505e289f792b01304d898"}, - {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:91129ff1bb0619bc1f4ad19485718cc623a2dc433dff95baadbf89405c7f6b57"}, - {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de35342190deb7b866ad6ba5cbcccb2d22c0487ee0cbb251efef0843d705f0d4"}, - {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b993b6f524d1e274a5062488a43e3f9f8764ee9745ccd8e8193df743dbe5ee61"}, - {file = "regex-2023.8.8-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:3026cbcf11d79095a32d9a13bbc572a458727bd5b1ca332df4a79faecd45281c"}, - {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:293352710172239bf579c90a9864d0df57340b6fd21272345222fb6371bf82b3"}, - {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:d909b5a3fff619dc7e48b6b1bedc2f30ec43033ba7af32f936c10839e81b9217"}, - {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_ppc64le.whl", hash = "sha256:3d370ff652323c5307d9c8e4c62efd1956fb08051b0e9210212bc51168b4ff56"}, - {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_s390x.whl", hash = "sha256:b076da1ed19dc37788f6a934c60adf97bd02c7eea461b73730513921a85d4235"}, - {file = "regex-2023.8.8-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:e9941a4ada58f6218694f382e43fdd256e97615db9da135e77359da257a7168b"}, - {file = "regex-2023.8.8-cp36-cp36m-win32.whl", hash = "sha256:a8c65c17aed7e15a0c824cdc63a6b104dfc530f6fa8cb6ac51c437af52b481c7"}, - {file = "regex-2023.8.8-cp36-cp36m-win_amd64.whl", hash = "sha256:aadf28046e77a72f30dcc1ab185639e8de7f4104b8cb5c6dfa5d8ed860e57236"}, - {file = "regex-2023.8.8-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:423adfa872b4908843ac3e7a30f957f5d5282944b81ca0a3b8a7ccbbfaa06103"}, - {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4ae594c66f4a7e1ea67232a0846649a7c94c188d6c071ac0210c3e86a5f92109"}, - {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e51c80c168074faa793685656c38eb7a06cbad7774c8cbc3ea05552d615393d8"}, - {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:09b7f4c66aa9d1522b06e31a54f15581c37286237208df1345108fcf4e050c18"}, - {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2e73e5243af12d9cd6a9d6a45a43570dbe2e5b1cdfc862f5ae2b031e44dd95a8"}, - {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:941460db8fe3bd613db52f05259c9336f5a47ccae7d7def44cc277184030a116"}, - {file = "regex-2023.8.8-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:f0ccf3e01afeb412a1a9993049cb160d0352dba635bbca7762b2dc722aa5742a"}, - {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:2e9216e0d2cdce7dbc9be48cb3eacb962740a09b011a116fd7af8c832ab116ca"}, - {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:5cd9cd7170459b9223c5e592ac036e0704bee765706445c353d96f2890e816c8"}, - {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:4873ef92e03a4309b3ccd8281454801b291b689f6ad45ef8c3658b6fa761d7ac"}, - {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:239c3c2a339d3b3ddd51c2daef10874410917cd2b998f043c13e2084cb191684"}, - {file = "regex-2023.8.8-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:1005c60ed7037be0d9dea1f9c53cc42f836188227366370867222bda4c3c6bd7"}, - {file = "regex-2023.8.8-cp37-cp37m-win32.whl", hash = "sha256:e6bd1e9b95bc5614a7a9c9c44fde9539cba1c823b43a9f7bc11266446dd568e3"}, - {file = "regex-2023.8.8-cp37-cp37m-win_amd64.whl", hash = "sha256:9a96edd79661e93327cfeac4edec72a4046e14550a1d22aa0dd2e3ca52aec921"}, - {file = "regex-2023.8.8-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f2181c20ef18747d5f4a7ea513e09ea03bdd50884a11ce46066bb90fe4213675"}, - {file = "regex-2023.8.8-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a2ad5add903eb7cdde2b7c64aaca405f3957ab34f16594d2b78d53b8b1a6a7d6"}, - {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9233ac249b354c54146e392e8a451e465dd2d967fc773690811d3a8c240ac601"}, - {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:920974009fb37b20d32afcdf0227a2e707eb83fe418713f7a8b7de038b870d0b"}, - {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:cd2b6c5dfe0929b6c23dde9624483380b170b6e34ed79054ad131b20203a1a63"}, - {file = "regex-2023.8.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:96979d753b1dc3b2169003e1854dc67bfc86edf93c01e84757927f810b8c3c93"}, - {file = "regex-2023.8.8-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2ae54a338191e1356253e7883d9d19f8679b6143703086245fb14d1f20196be9"}, - {file = "regex-2023.8.8-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:2162ae2eb8b079622176a81b65d486ba50b888271302190870b8cc488587d280"}, - {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:c884d1a59e69e03b93cf0dfee8794c63d7de0ee8f7ffb76e5f75be8131b6400a"}, - {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:cf9273e96f3ee2ac89ffcb17627a78f78e7516b08f94dc435844ae72576a276e"}, - {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:83215147121e15d5f3a45d99abeed9cf1fe16869d5c233b08c56cdf75f43a504"}, - {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:3f7454aa427b8ab9101f3787eb178057c5250478e39b99540cfc2b889c7d0586"}, - {file = "regex-2023.8.8-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:f0640913d2c1044d97e30d7c41728195fc37e54d190c5385eacb52115127b882"}, - {file = "regex-2023.8.8-cp38-cp38-win32.whl", hash = "sha256:0c59122ceccb905a941fb23b087b8eafc5290bf983ebcb14d2301febcbe199c7"}, - {file = "regex-2023.8.8-cp38-cp38-win_amd64.whl", hash = "sha256:c12f6f67495ea05c3d542d119d270007090bad5b843f642d418eb601ec0fa7be"}, - {file = "regex-2023.8.8-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:82cd0a69cd28f6cc3789cc6adeb1027f79526b1ab50b1f6062bbc3a0ccb2dbc3"}, - {file = "regex-2023.8.8-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:bb34d1605f96a245fc39790a117ac1bac8de84ab7691637b26ab2c5efb8f228c"}, - {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:987b9ac04d0b38ef4f89fbc035e84a7efad9cdd5f1e29024f9289182c8d99e09"}, - {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:9dd6082f4e2aec9b6a0927202c85bc1b09dcab113f97265127c1dc20e2e32495"}, - {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:7eb95fe8222932c10d4436e7a6f7c99991e3fdd9f36c949eff16a69246dee2dc"}, - {file = "regex-2023.8.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7098c524ba9f20717a56a8d551d2ed491ea89cbf37e540759ed3b776a4f8d6eb"}, - {file = "regex-2023.8.8-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:4b694430b3f00eb02c594ff5a16db30e054c1b9589a043fe9174584c6efa8033"}, - {file = "regex-2023.8.8-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:b2aeab3895d778155054abea5238d0eb9a72e9242bd4b43f42fd911ef9a13470"}, - {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:988631b9d78b546e284478c2ec15c8a85960e262e247b35ca5eaf7ee22f6050a"}, - {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:67ecd894e56a0c6108ec5ab1d8fa8418ec0cff45844a855966b875d1039a2e34"}, - {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:14898830f0a0eb67cae2bbbc787c1a7d6e34ecc06fbd39d3af5fe29a4468e2c9"}, - {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:f2200e00b62568cfd920127782c61bc1c546062a879cdc741cfcc6976668dfcf"}, - {file = "regex-2023.8.8-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:9691a549c19c22d26a4f3b948071e93517bdf86e41b81d8c6ac8a964bb71e5a6"}, - {file = "regex-2023.8.8-cp39-cp39-win32.whl", hash = "sha256:6ab2ed84bf0137927846b37e882745a827458689eb969028af8032b1b3dac78e"}, - {file = "regex-2023.8.8-cp39-cp39-win_amd64.whl", hash = "sha256:5543c055d8ec7801901e1193a51570643d6a6ab8751b1f7dd9af71af467538bb"}, - {file = "regex-2023.8.8.tar.gz", hash = "sha256:fcbdc5f2b0f1cd0f6a56cdb46fe41d2cce1e644e3b68832f3eeebc5fb0f7712e"}, + {file = "regex-2023.12.25-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:0694219a1d54336fd0445ea382d49d36882415c0134ee1e8332afd1529f0baa5"}, + {file = "regex-2023.12.25-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:b014333bd0217ad3d54c143de9d4b9a3ca1c5a29a6d0d554952ea071cff0f1f8"}, + {file = "regex-2023.12.25-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d865984b3f71f6d0af64d0d88f5733521698f6c16f445bb09ce746c92c97c586"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1e0eabac536b4cc7f57a5f3d095bfa557860ab912f25965e08fe1545e2ed8b4c"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c25a8ad70e716f96e13a637802813f65d8a6760ef48672aa3502f4c24ea8b400"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a9b6d73353f777630626f403b0652055ebfe8ff142a44ec2cf18ae470395766e"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9cc99d6946d750eb75827cb53c4371b8b0fe89c733a94b1573c9dd16ea6c9e4"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:88d1f7bef20c721359d8675f7d9f8e414ec5003d8f642fdfd8087777ff7f94b5"}, + {file = "regex-2023.12.25-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cb3fe77aec8f1995611f966d0c656fdce398317f850d0e6e7aebdfe61f40e1cd"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:7aa47c2e9ea33a4a2a05f40fcd3ea36d73853a2aae7b4feab6fc85f8bf2c9704"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:df26481f0c7a3f8739fecb3e81bc9da3fcfae34d6c094563b9d4670b047312e1"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:c40281f7d70baf6e0db0c2f7472b31609f5bc2748fe7275ea65a0b4601d9b392"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:d94a1db462d5690ebf6ae86d11c5e420042b9898af5dcf278bd97d6bda065423"}, + {file = "regex-2023.12.25-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ba1b30765a55acf15dce3f364e4928b80858fa8f979ad41f862358939bdd1f2f"}, + {file = "regex-2023.12.25-cp310-cp310-win32.whl", hash = "sha256:150c39f5b964e4d7dba46a7962a088fbc91f06e606f023ce57bb347a3b2d4630"}, + {file = "regex-2023.12.25-cp310-cp310-win_amd64.whl", hash = "sha256:09da66917262d9481c719599116c7dc0c321ffcec4b1f510c4f8a066f8768105"}, + {file = "regex-2023.12.25-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:1b9d811f72210fa9306aeb88385b8f8bcef0dfbf3873410413c00aa94c56c2b6"}, + {file = "regex-2023.12.25-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d902a43085a308cef32c0d3aea962524b725403fd9373dea18110904003bac97"}, + {file = "regex-2023.12.25-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:d166eafc19f4718df38887b2bbe1467a4f74a9830e8605089ea7a30dd4da8887"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c7ad32824b7f02bb3c9f80306d405a1d9b7bb89362d68b3c5a9be53836caebdb"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:636ba0a77de609d6510235b7f0e77ec494d2657108f777e8765efc060094c98c"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0fda75704357805eb953a3ee15a2b240694a9a514548cd49b3c5124b4e2ad01b"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f72cbae7f6b01591f90814250e636065850c5926751af02bb48da94dfced7baa"}, + {file = "regex-2023.12.25-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:db2a0b1857f18b11e3b0e54ddfefc96af46b0896fb678c85f63fb8c37518b3e7"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:7502534e55c7c36c0978c91ba6f61703faf7ce733715ca48f499d3dbbd7657e0"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:e8c7e08bb566de4faaf11984af13f6bcf6a08f327b13631d41d62592681d24fe"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:283fc8eed679758de38fe493b7d7d84a198b558942b03f017b1f94dda8efae80"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:f44dd4d68697559d007462b0a3a1d9acd61d97072b71f6d1968daef26bc744bd"}, + {file = "regex-2023.12.25-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:67d3ccfc590e5e7197750fcb3a2915b416a53e2de847a728cfa60141054123d4"}, + {file = "regex-2023.12.25-cp311-cp311-win32.whl", hash = "sha256:68191f80a9bad283432385961d9efe09d783bcd36ed35a60fb1ff3f1ec2efe87"}, + {file = "regex-2023.12.25-cp311-cp311-win_amd64.whl", hash = "sha256:7d2af3f6b8419661a0c421584cfe8aaec1c0e435ce7e47ee2a97e344b98f794f"}, + {file = "regex-2023.12.25-cp312-cp312-macosx_10_9_universal2.whl", hash = "sha256:8a0ccf52bb37d1a700375a6b395bff5dd15c50acb745f7db30415bae3c2b0715"}, + {file = "regex-2023.12.25-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:c3c4a78615b7762740531c27cf46e2f388d8d727d0c0c739e72048beb26c8a9d"}, + {file = "regex-2023.12.25-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:ad83e7545b4ab69216cef4cc47e344d19622e28aabec61574b20257c65466d6a"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7a635871143661feccce3979e1727c4e094f2bdfd3ec4b90dfd4f16f571a87a"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d498eea3f581fbe1b34b59c697512a8baef88212f92e4c7830fcc1499f5b45a5"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:43f7cd5754d02a56ae4ebb91b33461dc67be8e3e0153f593c509e21d219c5060"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:51f4b32f793812714fd5307222a7f77e739b9bc566dc94a18126aba3b92b98a3"}, + {file = "regex-2023.12.25-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ba99d8077424501b9616b43a2d208095746fb1284fc5ba490139651f971d39d9"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:4bfc2b16e3ba8850e0e262467275dd4d62f0d045e0e9eda2bc65078c0110a11f"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_i686.whl", hash = "sha256:8c2c19dae8a3eb0ea45a8448356ed561be843b13cbc34b840922ddf565498c1c"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_ppc64le.whl", hash = "sha256:60080bb3d8617d96f0fb7e19796384cc2467447ef1c491694850ebd3670bc457"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_s390x.whl", hash = "sha256:b77e27b79448e34c2c51c09836033056a0547aa360c45eeeb67803da7b0eedaf"}, + {file = "regex-2023.12.25-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:518440c991f514331f4850a63560321f833979d145d7d81186dbe2f19e27ae3d"}, + {file = "regex-2023.12.25-cp312-cp312-win32.whl", hash = "sha256:e2610e9406d3b0073636a3a2e80db05a02f0c3169b5632022b4e81c0364bcda5"}, + {file = "regex-2023.12.25-cp312-cp312-win_amd64.whl", hash = "sha256:cc37b9aeebab425f11f27e5e9e6cf580be7206c6582a64467a14dda211abc232"}, + {file = "regex-2023.12.25-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:da695d75ac97cb1cd725adac136d25ca687da4536154cdc2815f576e4da11c69"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d126361607b33c4eb7b36debc173bf25d7805847346dd4d99b5499e1fef52bc7"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4719bb05094d7d8563a450cf8738d2e1061420f79cfcc1fa7f0a44744c4d8f73"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:5dd58946bce44b53b06d94aa95560d0b243eb2fe64227cba50017a8d8b3cd3e2"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:22a86d9fff2009302c440b9d799ef2fe322416d2d58fc124b926aa89365ec482"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:2aae8101919e8aa05ecfe6322b278f41ce2994c4a430303c4cd163fef746e04f"}, + {file = "regex-2023.12.25-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:e692296c4cc2873967771345a876bcfc1c547e8dd695c6b89342488b0ea55cd8"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:263ef5cc10979837f243950637fffb06e8daed7f1ac1e39d5910fd29929e489a"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:d6f7e255e5fa94642a0724e35406e6cb7001c09d476ab5fce002f652b36d0c39"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:88ad44e220e22b63b0f8f81f007e8abbb92874d8ced66f32571ef8beb0643b2b"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:3a17d3ede18f9cedcbe23d2daa8a2cd6f59fe2bf082c567e43083bba3fb00347"}, + {file = "regex-2023.12.25-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d15b274f9e15b1a0b7a45d2ac86d1f634d983ca40d6b886721626c47a400bf39"}, + {file = "regex-2023.12.25-cp37-cp37m-win32.whl", hash = "sha256:ed19b3a05ae0c97dd8f75a5d8f21f7723a8c33bbc555da6bbe1f96c470139d3c"}, + {file = "regex-2023.12.25-cp37-cp37m-win_amd64.whl", hash = "sha256:a6d1047952c0b8104a1d371f88f4ab62e6275567d4458c1e26e9627ad489b445"}, + {file = "regex-2023.12.25-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:b43523d7bc2abd757119dbfb38af91b5735eea45537ec6ec3a5ec3f9562a1c53"}, + {file = "regex-2023.12.25-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:efb2d82f33b2212898f1659fb1c2e9ac30493ac41e4d53123da374c3b5541e64"}, + {file = "regex-2023.12.25-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b7fca9205b59c1a3d5031f7e64ed627a1074730a51c2a80e97653e3e9fa0d415"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:086dd15e9435b393ae06f96ab69ab2d333f5d65cbe65ca5a3ef0ec9564dfe770"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e81469f7d01efed9b53740aedd26085f20d49da65f9c1f41e822a33992cb1590"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:34e4af5b27232f68042aa40a91c3b9bb4da0eeb31b7632e0091afc4310afe6cb"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9852b76ab558e45b20bf1893b59af64a28bd3820b0c2efc80e0a70a4a3ea51c1"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ff100b203092af77d1a5a7abe085b3506b7eaaf9abf65b73b7d6905b6cb76988"}, + {file = "regex-2023.12.25-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:cc038b2d8b1470364b1888a98fd22d616fba2b6309c5b5f181ad4483e0017861"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:094ba386bb5c01e54e14434d4caabf6583334090865b23ef58e0424a6286d3dc"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:5cd05d0f57846d8ba4b71d9c00f6f37d6b97d5e5ef8b3c3840426a475c8f70f4"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:9aa1a67bbf0f957bbe096375887b2505f5d8ae16bf04488e8b0f334c36e31360"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:98a2636994f943b871786c9e82bfe7883ecdaba2ef5df54e1450fa9869d1f756"}, + {file = "regex-2023.12.25-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:37f8e93a81fc5e5bd8db7e10e62dc64261bcd88f8d7e6640aaebe9bc180d9ce2"}, + {file = "regex-2023.12.25-cp38-cp38-win32.whl", hash = "sha256:d78bd484930c1da2b9679290a41cdb25cc127d783768a0369d6b449e72f88beb"}, + {file = "regex-2023.12.25-cp38-cp38-win_amd64.whl", hash = "sha256:b521dcecebc5b978b447f0f69b5b7f3840eac454862270406a39837ffae4e697"}, + {file = "regex-2023.12.25-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:f7bc09bc9c29ebead055bcba136a67378f03d66bf359e87d0f7c759d6d4ffa31"}, + {file = "regex-2023.12.25-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:e14b73607d6231f3cc4622809c196b540a6a44e903bcfad940779c80dffa7be7"}, + {file = "regex-2023.12.25-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:9eda5f7a50141291beda3edd00abc2d4a5b16c29c92daf8d5bd76934150f3edc"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc6bb9aa69aacf0f6032c307da718f61a40cf970849e471254e0e91c56ffca95"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:298dc6354d414bc921581be85695d18912bea163a8b23cac9a2562bbcd5088b1"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2f4e475a80ecbd15896a976aa0b386c5525d0ed34d5c600b6d3ebac0a67c7ddf"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:531ac6cf22b53e0696f8e1d56ce2396311254eb806111ddd3922c9d937151dae"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:22f3470f7524b6da61e2020672df2f3063676aff444db1daa283c2ea4ed259d6"}, + {file = "regex-2023.12.25-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl", hash = "sha256:89723d2112697feaa320c9d351e5f5e7b841e83f8b143dba8e2d2b5f04e10923"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:0ecf44ddf9171cd7566ef1768047f6e66975788258b1c6c6ca78098b95cf9a3d"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:905466ad1702ed4acfd67a902af50b8db1feeb9781436372261808df7a2a7bca"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:4558410b7a5607a645e9804a3e9dd509af12fb72b9825b13791a37cd417d73a5"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:7e316026cc1095f2a3e8cc012822c99f413b702eaa2ca5408a513609488cb62f"}, + {file = "regex-2023.12.25-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3b1de218d5375cd6ac4b5493e0b9f3df2be331e86520f23382f216c137913d20"}, + {file = "regex-2023.12.25-cp39-cp39-win32.whl", hash = "sha256:11a963f8e25ab5c61348d090bf1b07f1953929c13bd2309a0662e9ff680763c9"}, + {file = "regex-2023.12.25-cp39-cp39-win_amd64.whl", hash = "sha256:e693e233ac92ba83a87024e1d32b5f9ab15ca55ddd916d878146f4e3406b5c91"}, + {file = "regex-2023.12.25.tar.gz", hash = "sha256:29171aa128da69afdf4bde412d5bedc335f2ca8fcfe4489038577d05f16181e5"}, ] [[package]] @@ -2360,90 +2296,6 @@ files = [ [package.extras] test = ["pytest (>=6.0.0)", "setuptools (>=65)"] -[[package]] -name = "wrapt" -version = "1.15.0" -description = "Module for decorators, wrappers and monkey patching." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" -files = [ - {file = "wrapt-1.15.0-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:ca1cccf838cd28d5a0883b342474c630ac48cac5df0ee6eacc9c7290f76b11c1"}, - {file = "wrapt-1.15.0-cp27-cp27m-manylinux1_i686.whl", hash = "sha256:e826aadda3cae59295b95343db8f3d965fb31059da7de01ee8d1c40a60398b29"}, - {file = "wrapt-1.15.0-cp27-cp27m-manylinux1_x86_64.whl", hash = "sha256:5fc8e02f5984a55d2c653f5fea93531e9836abbd84342c1d1e17abc4a15084c2"}, - {file = "wrapt-1.15.0-cp27-cp27m-manylinux2010_i686.whl", hash = "sha256:96e25c8603a155559231c19c0349245eeb4ac0096fe3c1d0be5c47e075bd4f46"}, - {file = "wrapt-1.15.0-cp27-cp27m-manylinux2010_x86_64.whl", hash = "sha256:40737a081d7497efea35ab9304b829b857f21558acfc7b3272f908d33b0d9d4c"}, - {file = "wrapt-1.15.0-cp27-cp27mu-manylinux1_i686.whl", hash = "sha256:f87ec75864c37c4c6cb908d282e1969e79763e0d9becdfe9fe5473b7bb1e5f09"}, - {file = "wrapt-1.15.0-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:1286eb30261894e4c70d124d44b7fd07825340869945c79d05bda53a40caa079"}, - {file = "wrapt-1.15.0-cp27-cp27mu-manylinux2010_i686.whl", hash = "sha256:493d389a2b63c88ad56cdc35d0fa5752daac56ca755805b1b0c530f785767d5e"}, - {file = "wrapt-1.15.0-cp27-cp27mu-manylinux2010_x86_64.whl", hash = "sha256:58d7a75d731e8c63614222bcb21dd992b4ab01a399f1f09dd82af17bbfc2368a"}, - {file = "wrapt-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:21f6d9a0d5b3a207cdf7acf8e58d7d13d463e639f0c7e01d82cdb671e6cb7923"}, - {file = "wrapt-1.15.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:ce42618f67741d4697684e501ef02f29e758a123aa2d669e2d964ff734ee00ee"}, - {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:41d07d029dd4157ae27beab04d22b8e261eddfc6ecd64ff7000b10dc8b3a5727"}, - {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:54accd4b8bc202966bafafd16e69da9d5640ff92389d33d28555c5fd4f25ccb7"}, - {file = "wrapt-1.15.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2fbfbca668dd15b744418265a9607baa970c347eefd0db6a518aaf0cfbd153c0"}, - {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:76e9c727a874b4856d11a32fb0b389afc61ce8aaf281ada613713ddeadd1cfec"}, - {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:e20076a211cd6f9b44a6be58f7eeafa7ab5720eb796975d0c03f05b47d89eb90"}, - {file = "wrapt-1.15.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:a74d56552ddbde46c246b5b89199cb3fd182f9c346c784e1a93e4dc3f5ec9975"}, - {file = "wrapt-1.15.0-cp310-cp310-win32.whl", hash = "sha256:26458da5653aa5b3d8dc8b24192f574a58984c749401f98fff994d41d3f08da1"}, - {file = "wrapt-1.15.0-cp310-cp310-win_amd64.whl", hash = "sha256:75760a47c06b5974aa5e01949bf7e66d2af4d08cb8c1d6516af5e39595397f5e"}, - {file = "wrapt-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:ba1711cda2d30634a7e452fc79eabcadaffedf241ff206db2ee93dd2c89a60e7"}, - {file = "wrapt-1.15.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:56374914b132c702aa9aa9959c550004b8847148f95e1b824772d453ac204a72"}, - {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a89ce3fd220ff144bd9d54da333ec0de0399b52c9ac3d2ce34b569cf1a5748fb"}, - {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3bbe623731d03b186b3d6b0d6f51865bf598587c38d6f7b0be2e27414f7f214e"}, - {file = "wrapt-1.15.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3abbe948c3cbde2689370a262a8d04e32ec2dd4f27103669a45c6929bcdbfe7c"}, - {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:b67b819628e3b748fd3c2192c15fb951f549d0f47c0449af0764d7647302fda3"}, - {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:7eebcdbe3677e58dd4c0e03b4f2cfa346ed4049687d839adad68cc38bb559c92"}, - {file = "wrapt-1.15.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:74934ebd71950e3db69960a7da29204f89624dde411afbfb3b4858c1409b1e98"}, - {file = "wrapt-1.15.0-cp311-cp311-win32.whl", hash = "sha256:bd84395aab8e4d36263cd1b9308cd504f6cf713b7d6d3ce25ea55670baec5416"}, - {file = "wrapt-1.15.0-cp311-cp311-win_amd64.whl", hash = "sha256:a487f72a25904e2b4bbc0817ce7a8de94363bd7e79890510174da9d901c38705"}, - {file = "wrapt-1.15.0-cp35-cp35m-manylinux1_i686.whl", hash = "sha256:4ff0d20f2e670800d3ed2b220d40984162089a6e2c9646fdb09b85e6f9a8fc29"}, - {file = "wrapt-1.15.0-cp35-cp35m-manylinux1_x86_64.whl", hash = "sha256:9ed6aa0726b9b60911f4aed8ec5b8dd7bf3491476015819f56473ffaef8959bd"}, - {file = "wrapt-1.15.0-cp35-cp35m-manylinux2010_i686.whl", hash = "sha256:896689fddba4f23ef7c718279e42f8834041a21342d95e56922e1c10c0cc7afb"}, - {file = "wrapt-1.15.0-cp35-cp35m-manylinux2010_x86_64.whl", hash = "sha256:75669d77bb2c071333417617a235324a1618dba66f82a750362eccbe5b61d248"}, - {file = "wrapt-1.15.0-cp35-cp35m-win32.whl", hash = "sha256:fbec11614dba0424ca72f4e8ba3c420dba07b4a7c206c8c8e4e73f2e98f4c559"}, - {file = "wrapt-1.15.0-cp35-cp35m-win_amd64.whl", hash = "sha256:fd69666217b62fa5d7c6aa88e507493a34dec4fa20c5bd925e4bc12fce586639"}, - {file = "wrapt-1.15.0-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:b0724f05c396b0a4c36a3226c31648385deb6a65d8992644c12a4963c70326ba"}, - {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bbeccb1aa40ab88cd29e6c7d8585582c99548f55f9b2581dfc5ba68c59a85752"}, - {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:38adf7198f8f154502883242f9fe7333ab05a5b02de7d83aa2d88ea621f13364"}, - {file = "wrapt-1.15.0-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:578383d740457fa790fdf85e6d346fda1416a40549fe8db08e5e9bd281c6a475"}, - {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_aarch64.whl", hash = "sha256:a4cbb9ff5795cd66f0066bdf5947f170f5d63a9274f99bdbca02fd973adcf2a8"}, - {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_i686.whl", hash = "sha256:af5bd9ccb188f6a5fdda9f1f09d9f4c86cc8a539bd48a0bfdc97723970348418"}, - {file = "wrapt-1.15.0-cp36-cp36m-musllinux_1_1_x86_64.whl", hash = "sha256:b56d5519e470d3f2fe4aa7585f0632b060d532d0696c5bdfb5e8319e1d0f69a2"}, - {file = "wrapt-1.15.0-cp36-cp36m-win32.whl", hash = "sha256:77d4c1b881076c3ba173484dfa53d3582c1c8ff1f914c6461ab70c8428b796c1"}, - {file = "wrapt-1.15.0-cp36-cp36m-win_amd64.whl", hash = "sha256:077ff0d1f9d9e4ce6476c1a924a3332452c1406e59d90a2cf24aeb29eeac9420"}, - {file = "wrapt-1.15.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5c5aa28df055697d7c37d2099a7bc09f559d5053c3349b1ad0c39000e611d317"}, - {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3a8564f283394634a7a7054b7983e47dbf39c07712d7b177b37e03f2467a024e"}, - {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:780c82a41dc493b62fc5884fb1d3a3b81106642c5c5c78d6a0d4cbe96d62ba7e"}, - {file = "wrapt-1.15.0-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e169e957c33576f47e21864cf3fc9ff47c223a4ebca8960079b8bd36cb014fd0"}, - {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:b02f21c1e2074943312d03d243ac4388319f2456576b2c6023041c4d57cd7019"}, - {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:f2e69b3ed24544b0d3dbe2c5c0ba5153ce50dcebb576fdc4696d52aa22db6034"}, - {file = "wrapt-1.15.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d787272ed958a05b2c86311d3a4135d3c2aeea4fc655705f074130aa57d71653"}, - {file = "wrapt-1.15.0-cp37-cp37m-win32.whl", hash = "sha256:02fce1852f755f44f95af51f69d22e45080102e9d00258053b79367d07af39c0"}, - {file = "wrapt-1.15.0-cp37-cp37m-win_amd64.whl", hash = "sha256:abd52a09d03adf9c763d706df707c343293d5d106aea53483e0ec8d9e310ad5e"}, - {file = "wrapt-1.15.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:cdb4f085756c96a3af04e6eca7f08b1345e94b53af8921b25c72f096e704e145"}, - {file = "wrapt-1.15.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:230ae493696a371f1dbffaad3dafbb742a4d27a0afd2b1aecebe52b740167e7f"}, - {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:63424c681923b9f3bfbc5e3205aafe790904053d42ddcc08542181a30a7a51bd"}, - {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d6bcbfc99f55655c3d93feb7ef3800bd5bbe963a755687cbf1f490a71fb7794b"}, - {file = "wrapt-1.15.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c99f4309f5145b93eca6e35ac1a988f0dc0a7ccf9ccdcd78d3c0adf57224e62f"}, - {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b130fe77361d6771ecf5a219d8e0817d61b236b7d8b37cc045172e574ed219e6"}, - {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:96177eb5645b1c6985f5c11d03fc2dbda9ad24ec0f3a46dcce91445747e15094"}, - {file = "wrapt-1.15.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:d5fe3e099cf07d0fb5a1e23d399e5d4d1ca3e6dfcbe5c8570ccff3e9208274f7"}, - {file = "wrapt-1.15.0-cp38-cp38-win32.whl", hash = "sha256:abd8f36c99512755b8456047b7be10372fca271bf1467a1caa88db991e7c421b"}, - {file = "wrapt-1.15.0-cp38-cp38-win_amd64.whl", hash = "sha256:b06fa97478a5f478fb05e1980980a7cdf2712015493b44d0c87606c1513ed5b1"}, - {file = "wrapt-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:2e51de54d4fb8fb50d6ee8327f9828306a959ae394d3e01a1ba8b2f937747d86"}, - {file = "wrapt-1.15.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:0970ddb69bba00670e58955f8019bec4a42d1785db3faa043c33d81de2bf843c"}, - {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:76407ab327158c510f44ded207e2f76b657303e17cb7a572ffe2f5a8a48aa04d"}, - {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:cd525e0e52a5ff16653a3fc9e3dd827981917d34996600bbc34c05d048ca35cc"}, - {file = "wrapt-1.15.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9d37ac69edc5614b90516807de32d08cb8e7b12260a285ee330955604ed9dd29"}, - {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:078e2a1a86544e644a68422f881c48b84fef6d18f8c7a957ffd3f2e0a74a0d4a"}, - {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:2cf56d0e237280baed46f0b5316661da892565ff58309d4d2ed7dba763d984b8"}, - {file = "wrapt-1.15.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:7dc0713bf81287a00516ef43137273b23ee414fe41a3c14be10dd95ed98a2df9"}, - {file = "wrapt-1.15.0-cp39-cp39-win32.whl", hash = "sha256:46ed616d5fb42f98630ed70c3529541408166c22cdfd4540b88d5f21006b0eff"}, - {file = "wrapt-1.15.0-cp39-cp39-win_amd64.whl", hash = "sha256:eef4d64c650f33347c1f9266fa5ae001440b232ad9b98f1f43dfe7a79435c0a6"}, - {file = "wrapt-1.15.0-py3-none-any.whl", hash = "sha256:64b1df0f83706b4ef4cfb4fb0e4c2669100fd7ecacfb59e091fad300d4e04640"}, - {file = "wrapt-1.15.0.tar.gz", hash = "sha256:d06730c6aed78cee4126234cf2d071e01b44b915e725a6cb439a879ec9754a3a"}, -] - [[package]] name = "yamllint" version = "1.32.0" @@ -2496,4 +2348,4 @@ optionals = ["jsonschema", "napalm"] [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "edbe4200862a8ff8d2c55b57de0a0c7b1b58acbe0275bea2d1444bc2059c1728" +content-hash = "450d6722c6146d1680a5c710f1085d19f064d7392dc7a10f0b77fbda0b1dacc1" diff --git a/pyproject.toml b/pyproject.toml index 8303125a..bc41038e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "netutils" -version = "1.7.0" +version = "1.8.0" description = "Common helper functions useful in network automation." authors = ["Network to Code, LLC "] license = "Apache-2.0" @@ -17,6 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] include = [ "LICENSE", @@ -37,8 +38,8 @@ bandit = "*" black = "*" coverage = "*" invoke = "*" -flake8 = "*" -pylint = "*" +flake8 = {version = "^7.0", python = ">=3.8.1,<4.0"} +pylint = "^3.0.0" pytest = "*" pyyaml = "*" pydocstyle = "*" @@ -54,7 +55,7 @@ mkdocs-python-classy = "0.1.3" [tool.black] line-length = 120 -target-version = ['py38', 'py39', 'py310', 'py311'] +target-version = ['py38', 'py39', 'py310', 'py311', 'py312'] include = '\.pyi?$' exclude = ''' ( @@ -104,7 +105,7 @@ testpaths = "tests/" addopts = "-vv --doctest-modules -p no:warnings --ignore-glob='*mock*'" [tool.mypy] -python_version = 3.11 +python_version = 3.12 ignore_errors = false disallow_untyped_calls = true disallow_untyped_defs = true diff --git a/tasks.py b/tasks.py index 045025af..c614d147 100644 --- a/tasks.py +++ b/tasks.py @@ -1,7 +1,6 @@ """Tasks for use with Invoke.""" import os import sys -from distutils.util import strtobool # pylint: disable=W0402 from invoke import task @@ -24,14 +23,20 @@ def is_truthy(arg): """ if isinstance(arg, bool): return arg - return bool(strtobool(arg)) + + val = str(arg).lower() + if val in ("y", "yes", "t", "true", "on", "1"): + return True + if val in ("n", "no", "f", "false", "off", "0"): + return False + raise ValueError(f"Invalid truthy value: `{arg}`") PYPROJECT_CONFIG = toml.load("pyproject.toml") TOOL_CONFIG = PYPROJECT_CONFIG["tool"]["poetry"] # Can be set to a separate Python version to be used for launching or building image -PYTHON_VER = os.getenv("PYTHON_VER", "3.11") +PYTHON_VER = os.getenv("PYTHON_VER", "3.12") # Name of the docker image/image IMAGE_NAME = os.getenv("IMAGE_NAME", TOOL_CONFIG["name"]) # Tag for the image @@ -264,7 +269,7 @@ def tests(context, local=INVOKE_LOCAL): @task def clean_container(context): """Remove stopped containers that source for image `netutils:`.""" - exec_cmd = """docker container rm $(docker container ls -a | grep -E "^\S+\s+netutils:" | awk 'NR>1 {print $1}')""" # noqa: W605 # pylint:disable=anomalous-backslash-in-string + exec_cmd = r"""docker container rm $(docker container ls -a | grep -E "^\S+\s+netutils:" | awk 'NR>1 {print $1}')""" run_cmd(context, exec_cmd, local=True) diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_backup.txt b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_backup.txt new file mode 100644 index 00000000..993f26c5 --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_backup.txt @@ -0,0 +1,5 @@ +# +header motd "my banner" +# +hwtacacs nas-ip 1.1.1.1 +# diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_feature.py b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_feature.py new file mode 100644 index 00000000..bb0194de --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_feature.py @@ -0,0 +1,3 @@ +features = [ + {"name": "header", "ordered": True, "section": ["header "]}, +] diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_intended.txt b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_intended.txt new file mode 100644 index 00000000..ebf7bba1 --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_intended.txt @@ -0,0 +1,9 @@ +# +header motd ^C +=================================================== +* GOOD DATA LINE 1 +* BAD DATA LINE 2 +==================================================^C +# +hwtacacs nas-ip 1.1.1.4 +# diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_received.json b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_received.json new file mode 100644 index 00000000..4d90cfc4 --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_bad_banner_received.json @@ -0,0 +1,12 @@ +{ + "header": { + "compliant": false, + "missing": "header motd ^C\n===================================================\n* GOOD DATA LINE 1\n* BAD DATA LINE 2\n==================================================^C", + "extra": "header motd \"my banner\"", + "cannot_parse": true, + "unordered_compliant": false, + "ordered_compliant": false, + "actual": "header motd \"my banner\"", + "intended": "header motd ^C\n===================================================\n* GOOD DATA LINE 1\n* BAD DATA LINE 2\n==================================================^C" + } +} \ No newline at end of file diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_backup.txt b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_backup.txt new file mode 100644 index 00000000..a22b6f11 --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_backup.txt @@ -0,0 +1,48 @@ +sysname HP-JKT-01 +# +dhcp enable +dhcp server forbidden-ip 10.10.10.1 10.10.10.100 +dhcp server always-broadcast +# +dhcp server ip-pool CKP + gateway-list 10.10.10.1 + domain-name intra.data.co.id + expired day 30 + netbios-type b-node +# +bgp 65330 + router-id 10.10.10.254 + graceful-restart + graceful-restart timer restart 120 + graceful-restart timer wait-for-rib 360 + peer 10.20.240.1 description ***Point to Point Connection** + peer 10.20.240.1 ebgp-max-hop 10 + peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx== + address-family ipv4 unicast + balance 4 + peer 10.30.240.1 enable + peer 10.30.240.1 route-policy P2P-FirstTry import + peer 10.30.240.1 route-policy P2P-FirstTry export +# +snmp-agent +snmp-agent local-engineid 8000XXX123456789AB503C00000001 +snmp-agent community read RO +snmp-agent community read read +snmp-agent community read ro +# +acl advanced name HPE + rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0 + rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0 + rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0 +# +header motd # +=================================================== + +!!! WARNING !!! +system monitoring for law enforcement and other +purpose. Unauthorized use of this machine may +subject you to criminal prosecution and penalties + +==================================================# +# +return diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_feature.py b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_feature.py new file mode 100644 index 00000000..f7a12528 --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_feature.py @@ -0,0 +1,7 @@ +features = [ + {"name": "bgp", "ordered": True, "section": ["bgp "]}, + {"name": "snmp-agent", "ordered": True, "section": ["snmp-server "]}, + {"name": "dhcp", "ordered": False, "section": ["dhcp "]}, + {"name": "header", "ordered": True, "section": ["header "]}, + {"name": "acl", "ordered": True, "section": ["acl "]}, +] diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_intended.txt b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_intended.txt new file mode 100644 index 00000000..031f465a --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_intended.txt @@ -0,0 +1,48 @@ +sysname HP-JKT-01 +# +dhcp enable +dhcp server forbidden-ip 10.10.10.1 10.10.10.100 +dhcp server always-broadcast +# +dhcp server ip-pool CKP + gateway-list 10.10.10.1 + domain-name intra.data.co.id + expired day 30 + netbios-type b-node +# +bgp 65330 + router-id 10.10.10.254 + graceful-restart + graceful-restart timer restart 120 + graceful-restart timer wait-for-rib 360 + peer 10.20.240.1 description ***Point to Point Connection** + peer 10.20.240.1 ebgp-max-hop 10 + peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx== + address-family ipv4 unicast + balance 4 + peer 10.30.240.1 enable + peer 10.30.240.1 route-policy P2P-FirstTry import + peer 10.30.240.1 route-policy P2P-FirstTry export +# +snmp-agent +snmp-agent local-engineid 8000XXX123456789AB503C00000001 +snmp-agent community read RO +snmp-agent community read read +snmp-agent community read ro +# +acl advanced name HPE + rule 1 permit source 10.180.60.254 0 destination 10.1.0.249 0 + rule 2 permit source 10.180.60.0 0.0.0.127 destination 10.1.4.62 0 + rule 3 permit source 10.180.60.0 0.0.0.127 destination 10.2.4.62 0 +# +header motd # +=================================================== + +!!! WARNING !!! +system monitoring for law enforcement and other +purpose. Unauthorized use of this machine may +subject you to criminal prosecution and penalties + +==================================================# +# +return diff --git a/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_received.json b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_received.json new file mode 100644 index 00000000..8e20a2c1 --- /dev/null +++ b/tests/unit/mock/config/compliance/compliance/hp_comware/hp_comware_basic_received.json @@ -0,0 +1,52 @@ +{ + "bgp": { + "compliant": true, + "missing": "", + "extra": "", + "cannot_parse": true, + "unordered_compliant": true, + "ordered_compliant": true, + "actual": "bgp 65330\n router-id 10.10.10.254\n graceful-restart\n graceful-restart timer restart 120\n graceful-restart timer wait-for-rib 360\n peer 10.20.240.1 description ***Point to Point Connection**\n peer 10.20.240.1 ebgp-max-hop 10\n peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx==\n address-family ipv4 unicast\n balance 4\n peer 10.30.240.1 enable\n peer 10.30.240.1 route-policy P2P-FirstTry import\n peer 10.30.240.1 route-policy P2P-FirstTry export", + "intended": "bgp 65330\n router-id 10.10.10.254\n graceful-restart\n graceful-restart timer restart 120\n graceful-restart timer wait-for-rib 360\n peer 10.20.240.1 description ***Point to Point Connection**\n peer 10.20.240.1 ebgp-max-hop 10\n peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx==\n address-family ipv4 unicast\n balance 4\n peer 10.30.240.1 enable\n peer 10.30.240.1 route-policy P2P-FirstTry import\n peer 10.30.240.1 route-policy P2P-FirstTry export" + }, + "snmp-agent": { + "compliant": true, + "missing": "", + "extra": "", + "cannot_parse": true, + "unordered_compliant": true, + "ordered_compliant": true, + "actual": "", + "intended": "" + }, + "dhcp": { + "compliant": true, + "missing": "", + "extra": "", + "cannot_parse": true, + "unordered_compliant": true, + "ordered_compliant": true, + "actual": "dhcp enable\ndhcp server forbidden-ip 10.10.10.1 10.10.10.100\ndhcp server always-broadcast\ndhcp server ip-pool CKP\n gateway-list 10.10.10.1\n domain-name intra.data.co.id\n expired day 30\n netbios-type b-node", + "intended": "dhcp enable\ndhcp server forbidden-ip 10.10.10.1 10.10.10.100\ndhcp server always-broadcast\ndhcp server ip-pool CKP\n gateway-list 10.10.10.1\n domain-name intra.data.co.id\n expired day 30\n netbios-type b-node" + }, + "header": { + "compliant": true, + "missing": "", + "extra": "", + "cannot_parse": true, + "unordered_compliant": true, + "ordered_compliant": true, + "actual": "header motd #\n===================================================\n!!! WARNING !!!\nsystem monitoring for law enforcement and other\npurpose. Unauthorized use of this machine may\nsubject you to criminal prosecution and penalties\n==================================================#", + "intended": "header motd #\n===================================================\n!!! WARNING !!!\nsystem monitoring for law enforcement and other\npurpose. Unauthorized use of this machine may\nsubject you to criminal prosecution and penalties\n==================================================#" + }, + "acl": { + "compliant": false, + "missing": "acl advanced name HPE\n rule 1 permit source 10.180.60.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.60.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.60.0 0.0.0.127 destination 10.2.4.62 0", + "extra": "acl advanced name HPE\n rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0", + "cannot_parse": true, + "unordered_compliant": false, + "ordered_compliant": false, + "actual": "acl advanced name HPE\n rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0", + "intended": "acl advanced name HPE\n rule 1 permit source 10.180.60.254 0 destination 10.1.0.249 0\n rule 2 permit source 10.180.60.0 0.0.0.127 destination 10.1.4.62 0\n rule 3 permit source 10.180.60.0 0.0.0.127 destination 10.2.4.62 0" + } +} \ No newline at end of file diff --git a/tests/unit/mock/config/parser/base/hp_comware/hp_comware_received.py b/tests/unit/mock/config/parser/base/hp_comware/hp_comware_received.py new file mode 100644 index 00000000..f35bd04c --- /dev/null +++ b/tests/unit/mock/config/parser/base/hp_comware/hp_comware_received.py @@ -0,0 +1,67 @@ +from netutils.config.parser import ConfigLine + +data = [ + ConfigLine(config_line="sysname HP-JKT-01", parents=()), + ConfigLine(config_line="dhcp enable", parents=()), + ConfigLine(config_line="dhcp server forbidden-ip 10.10.10.1 10.10.10.100", parents=()), + ConfigLine(config_line="dhcp server always-broadcast", parents=()), + ConfigLine(config_line="dhcp server ip-pool CKP", parents=()), + ConfigLine(config_line=" gateway-list 10.10.10.1", parents=("dhcp server ip-pool CKP",)), + ConfigLine(config_line=" domain-name intra.data.co.id", parents=("dhcp server ip-pool CKP",)), + ConfigLine(config_line=" expired day 30", parents=("dhcp server ip-pool CKP",)), + ConfigLine(config_line=" netbios-type b-node", parents=("dhcp server ip-pool CKP",)), + ConfigLine(config_line="bgp 65330", parents=()), + ConfigLine(config_line=" router-id 10.10.10.254", parents=("bgp 65330",)), + ConfigLine(config_line=" graceful-restart", parents=("bgp 65330",)), + ConfigLine(config_line=" graceful-restart timer restart 120", parents=("bgp 65330",)), + ConfigLine(config_line=" graceful-restart timer wait-for-rib 360", parents=("bgp 65330",)), + ConfigLine(config_line=" peer 10.20.240.1 description ***Point to Point Connection**", parents=("bgp 65330",)), + ConfigLine(config_line=" peer 10.20.240.1 ebgp-max-hop 10", parents=("bgp 65330",)), + ConfigLine( + config_line=" peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx==", + parents=("bgp 65330",), + ), + ConfigLine( + config_line=" address-family ipv4 unicast", + parents=("bgp 65330", " peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx=="), + ), + ConfigLine( + config_line=" balance 4", + parents=("bgp 65330", " peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx=="), + ), + ConfigLine( + config_line=" peer 10.30.240.1 enable", + parents=("bgp 65330", " peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx=="), + ), + ConfigLine( + config_line=" peer 10.30.240.1 route-policy P2P-FirstTry import", + parents=("bgp 65330", " peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx=="), + ), + ConfigLine( + config_line=" peer 10.30.240.1 route-policy P2P-FirstTry export", + parents=("bgp 65330", " peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx=="), + ), + ConfigLine(config_line="snmp-agent", parents=()), + ConfigLine(config_line="snmp-agent local-engineid 8000XXX123456789AB503C00000001", parents=()), + ConfigLine(config_line="snmp-agent community read RO", parents=()), + ConfigLine(config_line="snmp-agent community read read", parents=()), + ConfigLine(config_line="snmp-agent community read ro", parents=()), + ConfigLine(config_line="acl advanced name HPE", parents=()), + ConfigLine( + config_line=" rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0", parents=("acl advanced name HPE",) + ), + ConfigLine( + config_line=" rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0", + parents=("acl advanced name HPE",), + ), + ConfigLine( + config_line=" rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0", + parents=("acl advanced name HPE",), + ), + ConfigLine(config_line="header motd #", parents=()), + ConfigLine( + config_line="===================================================\n!!! WARNING !!!\nsystem monitoring for law enforcement and other\npurpose. Unauthorized use of this machine may\nsubject you to criminal prosecution and penalties\n==================================================#", + parents=("header motd #",), + ), + ConfigLine(config_line="return", parents=()), +] diff --git a/tests/unit/mock/config/parser/base/hp_comware/hp_comware_sent.txt b/tests/unit/mock/config/parser/base/hp_comware/hp_comware_sent.txt new file mode 100644 index 00000000..a22b6f11 --- /dev/null +++ b/tests/unit/mock/config/parser/base/hp_comware/hp_comware_sent.txt @@ -0,0 +1,48 @@ +sysname HP-JKT-01 +# +dhcp enable +dhcp server forbidden-ip 10.10.10.1 10.10.10.100 +dhcp server always-broadcast +# +dhcp server ip-pool CKP + gateway-list 10.10.10.1 + domain-name intra.data.co.id + expired day 30 + netbios-type b-node +# +bgp 65330 + router-id 10.10.10.254 + graceful-restart + graceful-restart timer restart 120 + graceful-restart timer wait-for-rib 360 + peer 10.20.240.1 description ***Point to Point Connection** + peer 10.20.240.1 ebgp-max-hop 10 + peer 10.30.240.1 password cipher $x$x$xxxxxxxxxxxxxxxxxxxxxxxxxxxx/xxxxxxxxxxxx== + address-family ipv4 unicast + balance 4 + peer 10.30.240.1 enable + peer 10.30.240.1 route-policy P2P-FirstTry import + peer 10.30.240.1 route-policy P2P-FirstTry export +# +snmp-agent +snmp-agent local-engineid 8000XXX123456789AB503C00000001 +snmp-agent community read RO +snmp-agent community read read +snmp-agent community read ro +# +acl advanced name HPE + rule 1 permit source 10.180.50.254 0 destination 10.1.0.249 0 + rule 2 permit source 10.180.50.0 0.0.0.127 destination 10.1.4.62 0 + rule 3 permit source 10.180.50.0 0.0.0.127 destination 10.2.4.62 0 +# +header motd # +=================================================== + +!!! WARNING !!! +system monitoring for law enforcement and other +purpose. Unauthorized use of this machine may +subject you to criminal prosecution and penalties + +==================================================# +# +return diff --git a/tests/unit/mock/config/sanitize/paloalto_panos/panos_clean_sanitized.txt b/tests/unit/mock/config/sanitize/paloalto_panos/panos_clean_sanitized.txt new file mode 100644 index 00000000..7f544a6f --- /dev/null +++ b/tests/unit/mock/config/sanitize/paloalto_panos/panos_clean_sanitized.txt @@ -0,0 +1,41 @@ + + config { + syslog { + Traffic_Syslog { + server { + splunk { + transport UDP; + port 514; + format BSD; + server 1.1.1.1; + facility LOG_USER; + } + graylog { + transport UDP; + port 514; + format BSD; + server 2.2.2.2; + facility LOG_USER; + } + } + format { + config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail"; + system "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial cs3Label=Virtual System cs3=$vsys fname=$object flexString2Label=Module flexString2=$module msg=$opaque externalId=$seqno cat=$eventid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + threat "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + traffic "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsReceived=$pkts_received PanOSPacketsSent=$pkts_sent start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed cs2Label=URL Category cs2=$category externalId=$seqno reason=$session_end_reason PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cat=$action_source PanOSActionFlags=$actionflags PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel"; + url "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno requestContext=$contenttype cat=$threatid fileId=$pcap_id requestMethod=$http_method requestClientApplication=$user_agent PanOSXForwarderfor=$xff PanOSReferer=$referer PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + data "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + wildfire "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid filePath=$cloud fileId=$pcap_id fileHash=$filedigest fileType=$filetype suid=$sender msg=$subject duid=$recipient oldFileId=$reportid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + tunnel "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=Log Action cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action externalId=$seqno PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time cs2Label=Tunnel Type cs2=$tunnel flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsSent=$pkts_sent PanOSPacketsReceived=$pkts_received flexNumber2Label=Maximum Encapsulation flexNumber2=$max_encap cfp1Label=Unknown Protocol cfp1=$unknown_proto cfp2Label=Strict Checking cfp2=$strict_check PanOSTunnelFragment=$tunnel_fragment cfp3Label=Sessions Created cfp3=$sessions_created cfp4Label=Sessions Closed cfp4=$sessions_closed reason=$session_end_reason cat=$action_source start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed"; + auth "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Server Profile cs1=$serverprofile cs2Label=Normalize User cs2=$normalize_user cs3Label=Virtual System cs3=$vsys cs4Label=Authentication Policy cs4=$authpolicy cs5Label=Client Type cs5=$clienttype cs6Label=Log Action cs6=$logset fname=$object cn1Label=Factor Number cn1=$factorno cn2Label=Authentication ID cn2=$authid src=$ip cnt=$repeatcnt duser=$user flexString2Label=Vendor flexString2=$vendor msg=$event externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags PanOSDesc=$desc "; + userid "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Factor Type cs1=$factortype cs3Label=Virtual System cs3=$vsys cs4Label=Data Source Name cs4=$datasourcename cs5Label=Data Source cs5=$datasource cs6Label=Data Source Type cs6=$datasourcetype cn1Label=Factor Number cn1=$factorno cn2Label=Virtual System ID cn2=$vsys_id cn3Label=Timeout Threshold cn3=$timeout src=$ip spt=$beginport dpt=$endport cnt=$repeatcnt duser=$user externalId=$seqno cat=$eventid end=$factorcompletiontime PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + hip-match "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$matchtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial suser=$srcuser cs3Label=Virtual System cs3=$vsys shost=$machinename src=$src cnt=$repeatcnt externalId=$seqno cat=$matchname start=$cef-formatted-time_generated cs2Label=Operating System cs2=$os PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id c6a2Label=IPv6 Source Address c6a2=$srcipv6"; + correlation "CEF:0|Palo Alto Networks|PAN-OS|8.0|$category|$type|$severity|rt=$cef-formatted-receive_time deviceExternalId=$serial start=$cef-formatted-time_generated src=$src suser=$srcuser cs3Label=Virtual System cs3=$vsys severity=$severity PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id fname=$object_name cn3Label=Object ID cn3=$object_id msg=$evidence"; + escaping { + escaped-characters \=; + escape-character \; + } + } + } + } + } \ No newline at end of file diff --git a/tests/unit/mock/config/sanitize/paloalto_panos/panos_clean_sent.txt b/tests/unit/mock/config/sanitize/paloalto_panos/panos_clean_sent.txt new file mode 100644 index 00000000..7f544a6f --- /dev/null +++ b/tests/unit/mock/config/sanitize/paloalto_panos/panos_clean_sent.txt @@ -0,0 +1,41 @@ + + config { + syslog { + Traffic_Syslog { + server { + splunk { + transport UDP; + port 514; + format BSD; + server 1.1.1.1; + facility LOG_USER; + } + graylog { + transport UDP; + port 514; + format BSD; + server 2.2.2.2; + facility LOG_USER; + } + } + format { + config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail"; + system "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial cs3Label=Virtual System cs3=$vsys fname=$object flexString2Label=Module flexString2=$module msg=$opaque externalId=$seqno cat=$eventid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + threat "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + traffic "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsReceived=$pkts_received PanOSPacketsSent=$pkts_sent start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed cs2Label=URL Category cs2=$category externalId=$seqno reason=$session_end_reason PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cat=$action_source PanOSActionFlags=$actionflags PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel"; + url "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno requestContext=$contenttype cat=$threatid fileId=$pcap_id requestMethod=$http_method requestClientApplication=$user_agent PanOSXForwarderfor=$xff PanOSReferer=$referer PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + data "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + wildfire "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid filePath=$cloud fileId=$pcap_id fileHash=$filedigest fileType=$filetype suid=$sender msg=$subject duid=$recipient oldFileId=$reportid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + tunnel "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=Log Action cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action externalId=$seqno PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time cs2Label=Tunnel Type cs2=$tunnel flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsSent=$pkts_sent PanOSPacketsReceived=$pkts_received flexNumber2Label=Maximum Encapsulation flexNumber2=$max_encap cfp1Label=Unknown Protocol cfp1=$unknown_proto cfp2Label=Strict Checking cfp2=$strict_check PanOSTunnelFragment=$tunnel_fragment cfp3Label=Sessions Created cfp3=$sessions_created cfp4Label=Sessions Closed cfp4=$sessions_closed reason=$session_end_reason cat=$action_source start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed"; + auth "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Server Profile cs1=$serverprofile cs2Label=Normalize User cs2=$normalize_user cs3Label=Virtual System cs3=$vsys cs4Label=Authentication Policy cs4=$authpolicy cs5Label=Client Type cs5=$clienttype cs6Label=Log Action cs6=$logset fname=$object cn1Label=Factor Number cn1=$factorno cn2Label=Authentication ID cn2=$authid src=$ip cnt=$repeatcnt duser=$user flexString2Label=Vendor flexString2=$vendor msg=$event externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags PanOSDesc=$desc "; + userid "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Factor Type cs1=$factortype cs3Label=Virtual System cs3=$vsys cs4Label=Data Source Name cs4=$datasourcename cs5Label=Data Source cs5=$datasource cs6Label=Data Source Type cs6=$datasourcetype cn1Label=Factor Number cn1=$factorno cn2Label=Virtual System ID cn2=$vsys_id cn3Label=Timeout Threshold cn3=$timeout src=$ip spt=$beginport dpt=$endport cnt=$repeatcnt duser=$user externalId=$seqno cat=$eventid end=$factorcompletiontime PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + hip-match "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$matchtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial suser=$srcuser cs3Label=Virtual System cs3=$vsys shost=$machinename src=$src cnt=$repeatcnt externalId=$seqno cat=$matchname start=$cef-formatted-time_generated cs2Label=Operating System cs2=$os PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id c6a2Label=IPv6 Source Address c6a2=$srcipv6"; + correlation "CEF:0|Palo Alto Networks|PAN-OS|8.0|$category|$type|$severity|rt=$cef-formatted-receive_time deviceExternalId=$serial start=$cef-formatted-time_generated src=$src suser=$srcuser cs3Label=Virtual System cs3=$vsys severity=$severity PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id fname=$object_name cn3Label=Object ID cn3=$object_id msg=$evidence"; + escaping { + escaped-characters \=; + escape-character \; + } + } + } + } + } \ No newline at end of file diff --git a/tests/unit/mock/config/sanitize/paloalto_panos/panos_dirty_sanitized.txt b/tests/unit/mock/config/sanitize/paloalto_panos/panos_dirty_sanitized.txt new file mode 100644 index 00000000..7f544a6f --- /dev/null +++ b/tests/unit/mock/config/sanitize/paloalto_panos/panos_dirty_sanitized.txt @@ -0,0 +1,41 @@ + + config { + syslog { + Traffic_Syslog { + server { + splunk { + transport UDP; + port 514; + format BSD; + server 1.1.1.1; + facility LOG_USER; + } + graylog { + transport UDP; + port 514; + format BSD; + server 2.2.2.2; + facility LOG_USER; + } + } + format { + config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail"; + system "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial cs3Label=Virtual System cs3=$vsys fname=$object flexString2Label=Module flexString2=$module msg=$opaque externalId=$seqno cat=$eventid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + threat "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + traffic "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsReceived=$pkts_received PanOSPacketsSent=$pkts_sent start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed cs2Label=URL Category cs2=$category externalId=$seqno reason=$session_end_reason PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cat=$action_source PanOSActionFlags=$actionflags PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel"; + url "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno requestContext=$contenttype cat=$threatid fileId=$pcap_id requestMethod=$http_method requestClientApplication=$user_agent PanOSXForwarderfor=$xff PanOSReferer=$referer PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + data "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + wildfire "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid filePath=$cloud fileId=$pcap_id fileHash=$filedigest fileType=$filetype suid=$sender msg=$subject duid=$recipient oldFileId=$reportid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + tunnel "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=Log Action cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action externalId=$seqno PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time cs2Label=Tunnel Type cs2=$tunnel flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsSent=$pkts_sent PanOSPacketsReceived=$pkts_received flexNumber2Label=Maximum Encapsulation flexNumber2=$max_encap cfp1Label=Unknown Protocol cfp1=$unknown_proto cfp2Label=Strict Checking cfp2=$strict_check PanOSTunnelFragment=$tunnel_fragment cfp3Label=Sessions Created cfp3=$sessions_created cfp4Label=Sessions Closed cfp4=$sessions_closed reason=$session_end_reason cat=$action_source start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed"; + auth "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Server Profile cs1=$serverprofile cs2Label=Normalize User cs2=$normalize_user cs3Label=Virtual System cs3=$vsys cs4Label=Authentication Policy cs4=$authpolicy cs5Label=Client Type cs5=$clienttype cs6Label=Log Action cs6=$logset fname=$object cn1Label=Factor Number cn1=$factorno cn2Label=Authentication ID cn2=$authid src=$ip cnt=$repeatcnt duser=$user flexString2Label=Vendor flexString2=$vendor msg=$event externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags PanOSDesc=$desc "; + userid "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Factor Type cs1=$factortype cs3Label=Virtual System cs3=$vsys cs4Label=Data Source Name cs4=$datasourcename cs5Label=Data Source cs5=$datasource cs6Label=Data Source Type cs6=$datasourcetype cn1Label=Factor Number cn1=$factorno cn2Label=Virtual System ID cn2=$vsys_id cn3Label=Timeout Threshold cn3=$timeout src=$ip spt=$beginport dpt=$endport cnt=$repeatcnt duser=$user externalId=$seqno cat=$eventid end=$factorcompletiontime PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + hip-match "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$matchtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial suser=$srcuser cs3Label=Virtual System cs3=$vsys shost=$machinename src=$src cnt=$repeatcnt externalId=$seqno cat=$matchname start=$cef-formatted-time_generated cs2Label=Operating System cs2=$os PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id c6a2Label=IPv6 Source Address c6a2=$srcipv6"; + correlation "CEF:0|Palo Alto Networks|PAN-OS|8.0|$category|$type|$severity|rt=$cef-formatted-receive_time deviceExternalId=$serial start=$cef-formatted-time_generated src=$src suser=$srcuser cs3Label=Virtual System cs3=$vsys severity=$severity PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id fname=$object_name cn3Label=Object ID cn3=$object_id msg=$evidence"; + escaping { + escaped-characters \=; + escape-character \; + } + } + } + } + } \ No newline at end of file diff --git a/tests/unit/mock/config/sanitize/paloalto_panos/panos_dirty_sent.txt b/tests/unit/mock/config/sanitize/paloalto_panos/panos_dirty_sent.txt new file mode 100644 index 00000000..85051eac --- /dev/null +++ b/tests/unit/mock/config/sanitize/paloalto_panos/panos_dirty_sent.txt @@ -0,0 +1,42 @@ + + config { + syslog { + Traffic_Syslog { + server { + splunk { + transport UDP; + port 514; + format BSD; + server 1.1.1.1; + facility LOG_USER; + } + graylog { + transport UDP; + port 514; + format BSD; + server 2.2.2.2; + facility LOG_USER; + } + } + format { + config "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$result|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial shost=$host cs3Label=Virtual System cs3=$vsys act=$cmd duser=$admin destinationServiceName=$client msg=$path externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags +Optional: cs1Label=Before Change Detail cs1=$before-change-detail cs2Label=After Change Detail cs2=$after-change-detail"; + system "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial cs3Label=Virtual System cs3=$vsys fname=$object flexString2Label=Module flexString2=$module msg=$opaque externalId=$seqno cat=$eventid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + threat "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + traffic "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsReceived=$pkts_received PanOSPacketsSent=$pkts_sent start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed cs2Label=URL Category cs2=$category externalId=$seqno reason=$session_end_reason PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cat=$action_source PanOSActionFlags=$actionflags PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel"; + url "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno requestContext=$contenttype cat=$threatid fileId=$pcap_id requestMethod=$http_method requestClientApplication=$user_agent PanOSXForwarderfor=$xff PanOSReferer=$referer PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + data "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid fileId=$pcap_id PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + wildfire "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|$number-of-severity|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=LogProfile cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action request=$misc cs2Label=URL Category cs2=$category flexString2Label=Direction flexString2=$direction PanOSActionFlags=$actionflags externalId=$seqno cat=$threatid filePath=$cloud fileId=$pcap_id fileHash=$filedigest fileType=$filetype suid=$sender msg=$subject duid=$recipient oldFileId=$reportid PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSSrcUUID=$src_uuid PanOSDstUUID=$dst_uuid PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time PanOSTunnelType=$tunnel PanOSThreatCategory=$thr_category PanOSContentVer=$contentver"; + tunnel "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial src=$src dst=$dst sourceTranslatedAddress=$natsrc destinationTranslatedAddress=$natdst cs1Label=Rule cs1=$rule suser=$srcuser duser=$dstuser app=$app cs3Label=Virtual System cs3=$vsys cs4Label=Source Zone cs4=$from cs5Label=Destination Zone cs5=$to deviceInboundInterface=$inbound_if deviceOutboundInterface=$outbound_if cs6Label=Log Action cs6=$logset cn1Label=SessionID cn1=$sessionid cnt=$repeatcnt spt=$sport dpt=$dport sourceTranslatedPort=$natsport destinationTranslatedPort=$natdport flexString1Label=Flags flexString1=$flags proto=$proto act=$action externalId=$seqno PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSTunnelID=$tunnelid PanOSMonitorTag=$monitortag PanOSParentSessionID=$parent_session_id PanOSParentStartTime=$parent_start_time cs2Label=Tunnel Type cs2=$tunnel flexNumber1Label=Total bytes flexNumber1=$bytes in=$bytes_sent out=$bytes_received cn2Label=Packets cn2=$packets PanOSPacketsSent=$pkts_sent PanOSPacketsReceived=$pkts_received flexNumber2Label=Maximum Encapsulation flexNumber2=$max_encap cfp1Label=Unknown Protocol cfp1=$unknown_proto cfp2Label=Strict Checking cfp2=$strict_check PanOSTunnelFragment=$tunnel_fragment cfp3Label=Sessions Created cfp3=$sessions_created cfp4Label=Sessions Closed cfp4=$sessions_closed reason=$session_end_reason cat=$action_source start=$cef-formatted-time_generated cn3Label=Elapsed time in seconds cn3=$elapsed"; + auth "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Server Profile cs1=$serverprofile cs2Label=Normalize User cs2=$normalize_user cs3Label=Virtual System cs3=$vsys cs4Label=Authentication Policy cs4=$authpolicy cs5Label=Client Type cs5=$clienttype cs6Label=Log Action cs6=$logset fname=$object cn1Label=Factor Number cn1=$factorno cn2Label=Authentication ID cn2=$authid src=$ip cnt=$repeatcnt duser=$user flexString2Label=Vendor flexString2=$vendor msg=$event externalId=$seqno PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags PanOSDesc=$desc "; + userid "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$subtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial cs1Label=Factor Type cs1=$factortype cs3Label=Virtual System cs3=$vsys cs4Label=Data Source Name cs4=$datasourcename cs5Label=Data Source cs5=$datasource cs6Label=Data Source Type cs6=$datasourcetype cn1Label=Factor Number cn1=$factorno cn2Label=Virtual System ID cn2=$vsys_id cn3Label=Timeout Threshold cn3=$timeout src=$ip spt=$beginport dpt=$endport cnt=$repeatcnt duser=$user externalId=$seqno cat=$eventid end=$factorcompletiontime PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name PanOSActionFlags=$actionflags"; + hip-match "CEF:0|Palo Alto Networks|PAN-OS|$sender_sw_version|$matchtype|$type|1|rt=$cef-formatted-receive_time deviceExternalId=$serial suser=$srcuser cs3Label=Virtual System cs3=$vsys shost=$machinename src=$src cnt=$repeatcnt externalId=$seqno cat=$matchname start=$cef-formatted-time_generated cs2Label=Operating System cs2=$os PanOSActionFlags=$actionflags PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id c6a2Label=IPv6 Source Address c6a2=$srcipv6"; + correlation "CEF:0|Palo Alto Networks|PAN-OS|8.0|$category|$type|$severity|rt=$cef-formatted-receive_time deviceExternalId=$serial start=$cef-formatted-time_generated src=$src suser=$srcuser cs3Label=Virtual System cs3=$vsys severity=$severity PanOSDGl1=$dg_hier_level_1 PanOSDGl2=$dg_hier_level_2 PanOSDGl3=$dg_hier_level_3 PanOSDGl4=$dg_hier_level_4 PanOSVsysName=$vsys_name dvchost=$device_name cn2Label=Virtual System ID cn2=$vsys_id fname=$object_name cn3Label=Object ID cn3=$object_id msg=$evidence"; + escaping { + escaped-characters \=; + escape-character \; + } + } + } + } + } \ No newline at end of file diff --git a/tests/unit/test_lib_mapper.py b/tests/unit/test_lib_mapper.py index 736c95f9..a3fac35a 100644 --- a/tests/unit/test_lib_mapper.py +++ b/tests/unit/test_lib_mapper.py @@ -5,7 +5,20 @@ from netutils import lib_mapper from netutils.config.compliance import parser_map -LIBRARIES = ["ANSIBLE", "NETMIKO", "NTCTEMPLATES", "NAPALM", "PYATS", "PYNTC", "HIERCONFIG", "NETUTILSPARSER"] +LIBRARIES = [ + "AERLEON", + "ANSIBLE", + "CAPIRCA", + "FORWARDNETWORKS", + "HIERCONFIG", + "NETMIKO", + "NETUTILSPARSER", + "NTCTEMPLATES", + "NAPALM", + "PYATS", + "PYNTC", + "SCRAPLI", +] def test_lib_mapper(): @@ -30,13 +43,42 @@ def test_lib_mapper(): @pytest.mark.parametrize("lib", LIBRARIES) def test_lib_mapper_reverse(lib): + """Test that the forward is same as reverse, some accommodations must be made.""" + rev_mapper = getattr(lib_mapper, f"{lib}_LIB_MAPPER_REVERSE").copy() _mapper = getattr(lib_mapper, f"{lib}_LIB_MAPPER").copy() if lib == "NAPALM": _mapper.pop("nxos_ssh") - mapper = dict((v, k) for k, v in _mapper.items()) - rev_mapper = getattr(lib_mapper, f"{lib}_LIB_MAPPER_REVERSE") - if lib in ["ANSIBLE", "NAPALM", "PYATS", "PYNTC"]: + if lib in ["NETMIKO", "NTCTEMPLATES"]: + _mapper.pop("f5_ltm") + _mapper.pop("f5_tmsh") + _mapper.pop("f5_linux") + if lib in [ + "AERLEON", + "ANSIBLE", + "CAPIRCA", + "FORWARDNETWORKS", + "HIERCONFIG", + "NETUTILSPARSER", + "NAPALM", + "PYATS", + "PYNTC", + "SCRAPLI", + ]: rev_mapper.pop("cisco_xe") + if lib in ["HIERCONFIG"]: + _mapper.pop("iosxe") + if lib in ["FORWARDNETWORKS"]: + _mapper.pop("LINUX_OVS_OFCTL") + _mapper.pop("IOS_XE") + _mapper.pop("SRX") + if lib in ["AERLEON", "CAPIRCA"]: + _mapper.pop("juniperevo") + _mapper.pop("srx") + _mapper.pop("srxlo") + _mapper.pop("msmpc") + _mapper.pop("windows_advfirewall") + mapper = dict((v, k) for k, v in _mapper.items()) + assert mapper == rev_mapper @@ -54,3 +96,12 @@ def test_netutils_parser(): """Test that the parser_map in compliance have been added to NETUTILSPARSER lib mappers.""" assert parser_map.keys() == lib_mapper.NETUTILSPARSER_LIB_MAPPER.keys() assert list(parser_map.keys()) == sorted(list(lib_mapper.NETUTILSPARSER_LIB_MAPPER.keys())) + + +@pytest.mark.parametrize("lib", LIBRARIES) +def test_lib_mapper_normalized_name(lib): + """Ensure that MAIN_LIB_MAPPER is kept up to date.""" + for key in getattr(lib_mapper, f"{lib}_LIB_MAPPER_REVERSE").keys(): + assert key in lib_mapper.MAIN_LIB_MAPPER + for value in getattr(lib_mapper, f"{lib}_LIB_MAPPER").values(): + assert value in lib_mapper.MAIN_LIB_MAPPER diff --git a/tests/unit/test_os_versions.py b/tests/unit/test_os_versions.py index e6ee7b22..bc96709e 100755 --- a/tests/unit/test_os_versions.py +++ b/tests/unit/test_os_versions.py @@ -1,13 +1,41 @@ """Test for the lib_helpers definitions.""" import pytest -from netutils.os_version import get_upgrade_path +from netutils import os_version from netutils.constants import UPGRADE_PATHS +LOOSE_VERSION = [ + {"sent": {"current_version": "10.1", "comparison": ">=", "target_version": "10.2"}, "received": False}, + {"sent": {"current_version": "2.0.1", "comparison": "<", "target_version": "2.0.2"}, "received": True}, + {"sent": {"current_version": "1.0", "comparison": "==", "target_version": "1.0"}, "received": True}, + {"sent": {"current_version": "1.2.3", "comparison": "!=", "target_version": "1.2.3"}, "received": False}, + {"sent": {"current_version": "0.9.9", "comparison": ">", "target_version": "0.9.8"}, "received": True}, + {"sent": {"current_version": "3.3.3", "comparison": "<=", "target_version": "3.3.4"}, "received": True}, + {"sent": {"current_version": "2020.01.01", "comparison": ">=", "target_version": "2020.01.01"}, "received": True}, + {"sent": {"current_version": "2020.1.1", "comparison": "==", "target_version": "2020.01.01"}, "received": True}, + {"sent": {"current_version": "2.0.0a", "comparison": "<", "target_version": "2.0.1"}, "received": True}, + {"sent": {"current_version": "1.10", "comparison": ">", "target_version": "1.2"}, "received": True}, + {"sent": {"current_version": "3.3.3b", "comparison": "==", "target_version": "3.3.3b"}, "received": True}, + {"sent": {"current_version": "1.0.0", "comparison": "!=", "target_version": "2.0.0"}, "received": True}, +] + +STRICT_VERSION = [ + {"sent": {"current_version": "10.1", "comparison": ">=", "target_version": "10.2"}, "received": False}, + {"sent": {"current_version": "2.0.1", "comparison": "<", "target_version": "2.0.2"}, "received": True}, + {"sent": {"current_version": "1.0", "comparison": "==", "target_version": "1.0"}, "received": True}, + {"sent": {"current_version": "1.2.3", "comparison": "!=", "target_version": "1.2.3"}, "received": False}, + {"sent": {"current_version": "0.9.9", "comparison": ">", "target_version": "0.9.8"}, "received": True}, + {"sent": {"current_version": "3.3.3", "comparison": "<=", "target_version": "3.3.4"}, "received": True}, + {"sent": {"current_version": "2020.01.01", "comparison": ">=", "target_version": "2020.01.01"}, "received": True}, + {"sent": {"current_version": "1.10", "comparison": ">", "target_version": "1.2"}, "received": True}, + {"sent": {"current_version": "1.0.0", "comparison": "!=", "target_version": "2.0.0"}, "received": True}, +] + + def test_get_upgrade_path(): return_values = ["9.1.15-h1", "10.0.0", "10.0.12", "10.1.0", "10.1.9"] - assert get_upgrade_path("9.1.6", "10.1.9", UPGRADE_PATHS["PANOS_OFFICIAL_V1"]) == return_values - assert get_upgrade_path("9.1.6", "10.1.9", UPGRADE_PATHS["PANOS_MAJOR_ONLY_V1"]) == [ + assert os_version.get_upgrade_path("9.1.6", "10.1.9", UPGRADE_PATHS["PANOS_OFFICIAL_V1"]) == return_values + assert os_version.get_upgrade_path("9.1.6", "10.1.9", UPGRADE_PATHS["PANOS_MAJOR_ONLY_V1"]) == [ "10.0.0", "10.1.0", "10.1.9", @@ -16,9 +44,26 @@ def test_get_upgrade_path(): def test_get_upgrade_path_current_greater_than_target(): with pytest.raises(ValueError, match="Target version must be newer than current version."): - get_upgrade_path("10.1.9", "9.1.6", UPGRADE_PATHS["PANOS_MAJOR_ONLY_V1"]) + os_version.get_upgrade_path("10.1.9", "9.1.6", UPGRADE_PATHS["PANOS_MAJOR_ONLY_V1"]) def test_get_upgrade_path_current_equals_target(): with pytest.raises(ValueError, match="Target version equals current version. No upgrade necessary."): - get_upgrade_path("10.1.9", "10.1.9", UPGRADE_PATHS["PANOS_MAJOR_ONLY_V1"]) + os_version.get_upgrade_path("10.1.9", "10.1.9", UPGRADE_PATHS["PANOS_MAJOR_ONLY_V1"]) + + +@pytest.mark.parametrize("data", LOOSE_VERSION) +def test_compare_loose(data): + assert os_version.compare_version_loose(**data["sent"]) == data["received"] + + +@pytest.mark.parametrize("data", STRICT_VERSION) +def test_compare_strict(data): + assert os_version.compare_version_strict(**data["sent"]) == data["received"] + + +def test_compare_strict_bad_version(): + with pytest.raises(ValueError, match="invalid version number."): + os_version.compare_version_strict("3.3.3b", "==", "3.3.3b") + with pytest.raises(ValueError, match="Invalid comparison operator:"): + os_version.compare_version_strict("3.3.3", "not-an-operator", "3.3.3") diff --git a/tests/unit/test_private_version.py b/tests/unit/test_private_version.py new file mode 100644 index 00000000..428abd45 --- /dev/null +++ b/tests/unit/test_private_version.py @@ -0,0 +1,76 @@ +"""Tests for distutils.version.""" +# pylint: disable=deprecated-module,missing-class-docstring,invalid-name,protected-access,consider-using-f-string,no-else-continue,raise-missing-from + +# Taken from https://github.com/python/cpython/blob/3.11/Lib/distutils/tests/test_version.py + +import unittest +from netutils._private.version import LooseVersion +from netutils._private.version import StrictVersion + + +class VersionTestCase(unittest.TestCase): + def test_prerelease(self): + version = StrictVersion("1.2.3a1") + self.assertEqual(version.version, (1, 2, 3)) + self.assertEqual(version.prerelease, ("a", 1)) + self.assertEqual(str(version), "1.2.3a1") + + version = StrictVersion("1.2.0") + self.assertEqual(str(version), "1.2") + + def test_cmp_strict(self): + versions = ( + ("1.5.1", "1.5.2b2", -1), + ("161", "3.10a", ValueError), + ("8.02", "8.02", 0), + ("3.4j", "1996.07.12", ValueError), + ("3.2.pl0", "3.1.1.6", ValueError), + ("2g6", "11g", ValueError), + ("0.9", "2.2", -1), + ("1.2.1", "1.2", 1), + ("1.1", "1.2.2", -1), + ("1.2", "1.1", 1), + ("1.2.1", "1.2.2", -1), + ("1.2.2", "1.2", 1), + ("1.2", "1.2.2", -1), + ("0.4.0", "0.4", 0), + ("1.13++", "5.5.kw", ValueError), + ) + + for v1, v2, wanted in versions: + try: + res = StrictVersion(v1)._cmp(StrictVersion(v2)) + except ValueError: + if wanted is ValueError: + continue + else: + raise AssertionError(("cmp(%s, %s) " "shouldn't raise ValueError") % (v1, v2)) + self.assertEqual(res, wanted, "cmp(%s, %s) should be %s, got %s" % (v1, v2, wanted, res)) + res = StrictVersion(v1)._cmp(v2) + self.assertEqual(res, wanted, "cmp(%s, %s) should be %s, got %s" % (v1, v2, wanted, res)) + res = StrictVersion(v1)._cmp(object()) + self.assertIs(res, NotImplemented, "cmp(%s, %s) should be NotImplemented, got %s" % (v1, v2, res)) + + def test_cmp(self): + versions = ( + ("1.5.1", "1.5.2b2", -1), + ("161", "3.10a", 1), + ("8.02", "8.02", 0), + ("3.4j", "1996.07.12", -1), + ("3.2.pl0", "3.1.1.6", 1), + ("2g6", "11g", -1), + ("0.960923", "2.2beta29", -1), + ("1.13++", "5.5.kw", -1), + ) + + for v1, v2, wanted in versions: + res = LooseVersion(v1)._cmp(LooseVersion(v2)) + self.assertEqual(res, wanted, "cmp(%s, %s) should be %s, got %s" % (v1, v2, wanted, res)) + res = LooseVersion(v1)._cmp(v2) + self.assertEqual(res, wanted, "cmp(%s, %s) should be %s, got %s" % (v1, v2, wanted, res)) + res = LooseVersion(v1)._cmp(object()) + self.assertIs(res, NotImplemented, "cmp(%s, %s) should be NotImplemented, got %s" % (v1, v2, res)) + + +def test_suite(): + return unittest.TestLoader().loadTestsFromTestCase(VersionTestCase) diff --git a/tests/unit/test_sanitize.py b/tests/unit/test_sanitize.py new file mode 100644 index 00000000..9d21ede4 --- /dev/null +++ b/tests/unit/test_sanitize.py @@ -0,0 +1,28 @@ +"""Test for the network os sanitize functions.""" +import glob +import os + +import pytest +from netutils.config import compliance +from netutils.config.conversion import paloalto_panos_clean_newlines + +MOCK_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), "mock", "config", "sanitize") + +TXT_FILE = "_sent.txt" +SANITIZE_FILE = "_sanitized.txt" + +sanitize_files = [] + +for network_os in list(compliance.parser_map.keys()): + for _file in glob.glob(f"{MOCK_DIR}/{network_os}/*{TXT_FILE}"): + sanitize_files.append([_file, network_os]) + + +@pytest.mark.parametrize("_file", sanitize_files) +def test_panos_newline_character(_file, get_text_data): + truncate_file = os.path.join(MOCK_DIR, _file[0][: -len(TXT_FILE)]) + + sent_cfg = get_text_data(os.path.join(MOCK_DIR, _file[0])) + sanitized_cfg = paloalto_panos_clean_newlines(cfg=sent_cfg) + received_data = get_text_data(truncate_file + "_sanitized.txt") + assert sanitized_cfg == received_data