You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/waf/policies/lifecycle-management.md
+312-1Lines changed: 312 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -844,6 +844,317 @@ Downloading security updates may take several minutes, and the version of securi
844
844
845
845
If _APSignatures_ is not created or the specified versions are not available, it will default to the version stored in the compiler Docker image.
846
846
847
+
## Policy Types and References
848
+
849
+
NGINX App Protect WAF with Policy Lifecycle Management supports multiple ways to define and reference security policies through APPolicy Custom Resources. This flexibility allows you to choose the most appropriate approach based on your deployment architecture, policy management workflow, and operational requirements.
850
+
851
+
## Policy Definition Types
852
+
853
+
Policy Lifecycle Management supports three distinct approaches for defining WAF policies:
Reference a precompiled policy bundle (.tgz file) stored in the shared persistent volume.
863
+
864
+
## Inline Policy Definition
865
+
866
+
### Description
867
+
868
+
Inline policy definition allows you to specify the complete WAF policy configuration directly within the APPolicy Custom Resource. This approach provides full declarative management through Kubernetes manifests and is ideal for version-controlled policy configurations.
869
+
870
+
### Example Configuration
871
+
872
+
Create a file named `inline-policy.yaml`:
873
+
874
+
```yaml
875
+
apiVersion: appprotect.f5.com/v1
876
+
kind: APPolicy
877
+
metadata:
878
+
name: dataguard-blocking-inline
879
+
namespace: <namespace>
880
+
spec:
881
+
policy:
882
+
name: dataguard_blocking_inline
883
+
template:
884
+
name: POLICY_TEMPLATE_NGINX_BASE
885
+
applicationLanguage: utf-8
886
+
enforcementMode: blocking
887
+
blocking-settings:
888
+
violations:
889
+
- name: VIOL_DATA_GUARD
890
+
alarm: true
891
+
block: true
892
+
- name: VIOL_ATTACK_SIGNATURE
893
+
alarm: true
894
+
block: true
895
+
data-guard:
896
+
enabled: true
897
+
maskData: true
898
+
creditCardNumbers: true
899
+
usSocialSecurityNumbers: true
900
+
enforcementMode: ignore-urls-in-list
901
+
enforcementUrls: []
902
+
```
903
+
904
+
Apply the policy:
905
+
```bash
906
+
kubectl apply -f inline-policy.yaml
907
+
```
908
+
909
+
## JSON Policy Reference
910
+
911
+
### Description
912
+
913
+
JSON policy reference allows you to store your policy configuration as a separate JSON file in the shared persistent volume and reference it from the APPolicy Custom Resource. This approach separates policy content from Kubernetes resource management while maintaining compilation automation.
914
+
915
+
### Prerequisites
916
+
917
+
- Policy JSON file must be stored in the shared persistent volume
918
+
- File must be accessible at the specified path within the container
919
+
- Proper file permissions (readable by the Policy Controller)
920
+
921
+
### File Change Tracking
922
+
923
+
The Policy Controller can automatically monitor policy files for changes and trigger recompilation when modifications are detected. This feature is controlled through the `externalReferenceDetails.tracking` configuration:
3. **Status Updates**: Custom Resource status reflects the new compilation state
1015
+
4. **Bundle Replacement**: New policy bundle replaces the previous version
1016
+
1017
+
{{< call-out "note" >}}
1018
+
**No CR Reapplication Needed**: You do NOT need to reapply the APPolicy Custom Resource when updating the JSON file. Simply edit the file and the Policy Controller will detect the changes and recompile automatically.
1019
+
{{< /call-out >}}
1020
+
1021
+
## Precompiled Bundle Reference
1022
+
1023
+
### Description
1024
+
1025
+
Precompiled bundle reference allows you to use policy bundles that have been pre-compiled using external WAF compiler tools. This approach is useful for policies compiled outside of the Kubernetes environment or when integrating with external policy management systems.
1026
+
1027
+
### Prerequisites
1028
+
1029
+
- Precompiled bundle (.tgz) file must be stored in the shared persistent volume
1030
+
- Bundle must be compatible with the current WAF Enforcer version
1031
+
- Proper file permissions (readable by the Policy Controller)
1032
+
1033
+
### Bundle Validation
1034
+
1035
+
The Policy Controller performs validation of precompiled bundles using `apcompile --dump` to ensure:
1036
+
1037
+
- **Bundle Integrity**: Verification that the bundle is properly formed
1038
+
- **Version Compatibility**: Confirmation that the bundle works with current enforcer
1039
+
- **Content Validation**: Basic checks on policy structure and syntax
1040
+
1041
+
### Example Configuration
1042
+
1043
+
**Step 1: Prepare the precompiled bundle**
1044
+
1045
+
Ensure your precompiled policy bundle is available in the shared volume. For example, place `policy2.tgz` in `/mnt/nap5_bundles_pv_data/`.
1046
+
1047
+
**Step 2: Create the APPolicy Custom Resource**
1048
+
1049
+
Create a file named `precompiled-bundle-policy.yaml`:
1050
+
1051
+
```yaml
1052
+
apiVersion: appprotect.f5.com/v1
1053
+
kind: APPolicy
1054
+
metadata:
1055
+
name: dataguard-tgz
1056
+
namespace: <namespace>
1057
+
spec:
1058
+
policy:
1059
+
$ref: /etc/app_protect/bundles/policy2.tgz
1060
+
externalReferenceDetails:
1061
+
tracking:
1062
+
enabled: true
1063
+
intervalInSeconds: 10
1064
+
```
1065
+
1066
+
**Step 3: Apply the Custom Resource**
1067
+
1068
+
```bash
1069
+
kubectl apply -f precompiled-bundle-policy.yaml
1070
+
```
1071
+
1072
+
### Bundle Management
1073
+
1074
+
When using precompiled bundles:
1075
+
1076
+
1. **Validation Phase**: Policy Controller validates the bundle structure
1077
+
2. **Deployment**: Bundle is made available to NGINX containers
1078
+
3. **Change Detection**: If tracking is enabled, bundle file changes trigger updates
1079
+
4. **Status Reporting**: Custom Resource status shows bundle deployment state
1080
+
1081
+
### Updating Precompiled Bundles
1082
+
1083
+
Once the APPolicy Custom Resource has been applied, updating your policy bundle is straightforward:
1084
+
1085
+
**To update your bundle:**
1086
+
1. Replace the existing bundle file with your new bundle (keeping the same filename)
1087
+
2. For example, replace `/mnt/nap5_bundles_pv_data/policy2.tgz` with your updated bundle
1088
+
3. The Policy Controller automatically handles the rest
1089
+
1090
+
**What happens automatically:**
1091
+
1. **Change Detection**: If tracking is enabled, the Policy Controller detects the file modification
1092
+
2. **Revalidation**: The new bundle is validated using `apcompile --dump`
1093
+
3. **Deployment**: If validation passes, the new bundle is deployed
1094
+
4. **Status Updates**: Custom Resource status reflects the new validation and deployment state
1095
+
1096
+
{{< call-out "note" >}}
1097
+
**No CR Reapplication Needed**: You do NOT need to reapply the APPolicy Custom Resource when updating the bundle file. Simply replace the bundle file with the same name and the Policy Controller will detect the changes and revalidate automatically.
1098
+
{{< /call-out >}}
1099
+
1100
+
## Policy Status Monitoring
1101
+
1102
+
Regardless of the policy type used, you can monitor the status of your policies using standard Kubernetes commands:
0 commit comments