PaloAltoNetworks / PaloAltoNetworks/pan-os-python

default_icmp_type ApplicationObject incorrect vartype

Open
#560 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
400
Forks
199
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

Failure to parse XML with refresh all on device groups.

Specifically the child object that fails is the ApplicationObject -> "default_icmp_type" VersionedParamPath.

This particular code piece fails:

elif self.vartype == "int":
    settings[self.param] = int(elm.text)

Under panos.base.ParamPath.parse_value_from_xml_last_tag line 3306.

The elm.text field fails to be translated to an integer with

Expected behavior

Parsing completes successfully.

Current behavior

`Traceback (most recent call last):
File "c:\git\Pan_OS_Tests\env\Lib\site-packages\panos\base.py", line 3307, in parse_value_from_xml_last_tag
settings[self.param] = int(elm.text)
^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '13,14'

Possible solution

Depending on how these params are handled downstream we can either:

  1. Handle the exception for this particular conversion and instead save it as a string ignoring param types
  2. Define appropriate param versions (set to None) for default_icmp_type for all affected Panorama versions.

Steps to reproduce

  1. Build Panorama Object
  2. Get all DeviceGroup Objects
    pa = Panorama("", api_username="",  api_password="") 

    dg_test = DeviceGroup()

    # Building device group as a child of Panorama
    pa.add(dg_test)

    # Get all device groups:
    device_groups = DeviceGroup.refreshall(dg_test)

Specifically this affects filters associated with icmp-timestamp. (Since that's both ICMP type 13 & 14).

Screenshots

N/A

Context

Just trying to get all devicegroups from Panorama.

Your Environment

  • Version used: Panorama Version 10.1.12
  • Environment name and version (e.g. Chrome 59, node.js 5.4, python 3.7.3): python 3.12.1
  • Operating System and version (desktop or mobile): Windows 10
  • Link to your project: N/A

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at panos.base.ParamPath.parse_value_from_xml_last_tag around line 3306 and trace the definition of ApplicationObject's default_icmp_type. Reproduce the failure through DeviceGroup.refreshall with the icmp-timestamp value "13,14" on Panorama 10.1.12. Done means device-group refresh parses successfully without the ValueError and the chosen parameter handling matches downstream expectations.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.