From 474b86c2e56eb00bc0791056377eae00ae31f07d Mon Sep 17 00:00:00 2001 From: Garfield Lee Freeman Date: Mon, 15 Apr 2024 15:53:57 +0200 Subject: [PATCH] add a destination for the move multi-config for unfixed versions of pan-os --- policies/rules/security/service.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/policies/rules/security/service.go b/policies/rules/security/service.go index 9cf5d1c..481f048 100644 --- a/policies/rules/security/service.go +++ b/policies/rules/security/service.go @@ -420,11 +420,18 @@ func (s *Service) MoveGroup(ctx context.Context, loc Location, position rule.Pos } } + // Some versions of PAN-OS require that the destination always be set. + var dst string + if !vn.Gte(util.FixedPanosVersionForMultiConfigMove) { + dst = "top" + } + updates.Add(&xmlapi.Config{ - Action: "move", - Xpath: util.AsXpath(path), - Where: "top", - Target: s.client.GetTarget(), + Action: "move", + Xpath: util.AsXpath(path), + Where: "top", + Destination: dst, + Target: s.client.GetTarget(), }) baseIndex = 0 @@ -452,11 +459,18 @@ func (s *Service) MoveGroup(ctx context.Context, loc Location, position rule.Pos } } + // Some versions of PAN-OS require that the destination always be set. + var dst string + if !vn.Gte(util.FixedPanosVersionForMultiConfigMove) { + dst = "bottom" + } + updates.Add(&xmlapi.Config{ - Action: "move", - Xpath: util.AsXpath(path), - Where: "bottom", - Target: s.client.GetTarget(), + Action: "move", + Xpath: util.AsXpath(path), + Where: "bottom", + Destination: dst, + Target: s.client.GetTarget(), }) baseIndex = len(listing) - 1