PaloAltoNetworks / PaloAltoNetworks/pan.dev

Issue/Help with "Python SDK SecurityRule group and target"

Open
#873 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
MDX
Stars
78
Forks
88
Avg merge
5d 17h
Merged PRs (30d)
18

Description

Documentation link

panos.policies.SecurityRule in pan-os-python module

Describe the problem

I'm programming a python script to retrieve security rules in a Device Group policy from Panorama, and I've noticed some things that differ from or are not included in the documentation. The target attribute in panos.policies.SecurityRule is the important issue and the reason I'm writing here, as I describe below

panos.policies.SecurityRule.group type

Although the documentation specifies this attribute is a string, the security profile group is returned as a list (with a string)

panos.policies.SecurityRule.target value

The XML API specifies which virtual system alongside the firewall the rule applies to, but the SDK only returns a list with the firewalls' serial number and no information about the virtual systems within that firewall where the rule is applied. This makes it impossible to know which policy has targeted rules included, unless you only use one virtual system per firewall or don't use the target field in any rule

Image

Suggested fix

  • As only one security profile group can be provided to a rule, panos.policies.SecurityRule.group could be as easy as adding [0] somewhere

  • The SDK needs to look for aditional information retrieved from XML API when assigning panos.policies.SecurityRule.target its value, since the virtual system is also specified as an attribute in a tag named "entry" (same as the firewall's serial number, but this tag is a child of the child tag "vsys" of its "entry" tag, e.g. <entry name="SERIAL_NUMBER"><vsys><entry name="VSYS#"/></vsys></entry>). The retrieved list could be a list of tuple with 2 values, dictionaries with 2 keys, or even a list of strings with both serial number and virtual system name concatenated with any separator character

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 with the panos.policies.SecurityRule implementation and its documentation at module-policies.html, then compare the XML API response for group and target values, including the nested vsys entries. Done means the SDK exposes the documented group shape and preserves each firewall serial number together with its targeted virtual system, with tests covering both cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.