Skip to content

fix: reject self-parenting in PanObject child operations - #628

Open
Shubham-Padkonde wants to merge 1 commit into
PaloAltoNetworks:developfrom
Shubham-Padkonde:fix/reject-self-children
Open

Shubham-Padkonde wants to merge 1 commit into
PaloAltoNetworks:developfrom
Shubham-Padkonde:fix/reject-self-children

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Description

Fixes #512.

Adding a PanObject as its own child makes its parent point back to itself, so later operations such as vsys, delete() and delete_similar() can recurse indefinitely. Reject that operation with ValueError before modifying the tree.

Apply the same validation to insert() and extend(), which can create the same invalid relationship. extend() validates the complete batch before changing any child's parent, so rejection leaves existing parent links intact. The methods document the new error, and three regression tests verify rejection and unchanged state. This prevents direct self-parenting; it does not introduce broader ancestor-cycle or reparenting policy changes.

Validation

Ubuntu 22.04/WSL, Poetry 1.7.1, dependencies from the existing lockfile:

  • All three regressions fail on unchanged develop (92ed648d) and pass with the fix.
  • Full suite on Python 3.8.20 and 3.9.25: 3,133 passed, 1,653 skipped on each, matching the current CI interpreter versions.
  • make check-format passes (Black and isort).
  • make lint still fails on existing repository findings: 4,146 after this patch versus 4,149 on unchanged source. Comparison ignoring shifted line numbers finds no added diagnostics.
  • make bandit still reports the same eight findings as unchanged source; no new findings.
  • git diff --check passes. No dependency files changed.

The legacy make test-all target uses a Python 2.7 tox configuration and calls setup.py, which is absent from the current checkout; that target was not used as evidence. The actual CI Python versions were tested directly. Live-device tests and macOS were not exercised. The pinned pytest also fails during startup on Python 3.10, so validation uses the supported CI versions above.

Investigation, implementation and testing were assisted by Codex/GPT-6.

Signed-off-by: Shubham Padkonde <shubhampadkonde12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Block adding an object to itself (by using .add) as it causes infinite recursive loop on PanObject.vsys()

1 participant