Repository: zaproxy/zaproxy
Issue: Default policy on start up not using edited policy rules

### Describe the bug

modified rules of the auto selected scan policy are not used. 'Default' is shown and used for the active scans.

### Steps to reproduce the behavior

Change the rules of the default policy, then close zap and restart. 

Attempt an active scan, the default policy is used however the edited rules that I changed are not shown. It states 'Default' for all rules. 

If reselect default policy from drop down in active scan pop up then modified rules show.

From then on the default policy has the correct modified rules for all active scans.

### Expected behavior

Show and use modified rules

### Software versions

2.11.1

### Screenshots

_No response_

### Errors from the zap.log file

_No response_

### Additional context

_No response_

### Would you like to help fix this issue?

- [ ] Yes

Changed files:
zap/src/main/java/org/zaproxy/zap/extension/ascan/CustomScanDialog.java

diff --git a/zap/src/main/java/org/zaproxy/zap/extension/ascan/CustomScanDialog.java b/zap/src/main/java/org/zaproxy/zap/extension/ascan/CustomScanDialog.java
index 2420ce43c..0fc5fd738 100644
--- a/zap/src/main/java/org/zaproxy/zap/extension/ascan/CustomScanDialog.java
+++ b/zap/src/main/java/org/zaproxy/zap/extension/ascan/CustomScanDialog.java
@@ -146,10 +146,7 @@ public class CustomScanDialog extends StandardFieldsDialog {
         this.customPanels = customPanels;
         this.policyPanel =
                 new ScanPolicyPanel(
-                        this,
-                        extension,
-                        Constant.messages.getString("ascan.custom.tab.policy"),
-                        new ScanPolicy());
+                        this, extension, Constant.messages.getString("ascan.custom.tab.policy"));
         this.filterPanel = new FilterPanel();
         addWindowListener(
                 new WindowAdapter() {
@@ -259,6 +256,7 @@ public class CustomScanDialog extends StandardFieldsDialog {
         getTechTree().refresh();
         setTechSet(techTreeState);
 
+        policyPanel.initScanPolicy(scanPolicy);
         this.setCustomTabPanel(4, policyPanel);
 
         // Filter panel
@@ -982,14 +980,10 @@ public class CustomScanDialog extends StandardFieldsDialog {
         private List<PolicyCategoryPanel> categoryPanels = Collections.emptyList();
         private ScanPolicy scanPolicy;
 
-        public ScanPolicyPanel(
-                Window parent,
-                ExtensionActiveScan extension,
-                String rootName,
-                ScanPolicy scanPolicy) {
+        ScanPolicyPanel(Window parent, ExtensionActiveScan extension, String rootName) {
             super(rootName);
 
-            this.scanPolicy = scanPolicy;
+            this.scanPolicy = new ScanPolicy();
             String[] ROOT = {};
 
             policyAllCategoryPanel =
@@ -1021,6 +1015,26 @@ public class CustomScanDialog extends StandardFieldsDialog {
                 this.categoryPanels.add(panel);
             }
             showDialog(true);
+
+            scanPolicy = null;
+        }
+
+        /**
+         * Initialises the panel with the given policy.
+         *
+         * <p>Successive calls have no effect.
+         *
+         * @param scanPolicy the scan policy.
+         * @see #setScanPolicy(ScanPolicy)
+         * @see #resetAndSetPolicy(String)
+         */
+        void initScanPolicy(ScanPolicy scanPolicy) {
+            if (this.scanPolicy != null || scanPolicy == null) {
+                return;
+            }
+
+            this.scanPolicy = scanPolicy;
+            setScanPolicy(scanPolicy);
         }
 
         public void resetAndSetPolicy(String scanPolicyName) {