Skip to content

Commit e4ac4f7

Browse files
20250624 - NGINX Instance Manager and App Protect bugfix (#87)
1 parent f38b153 commit e4ac4f7

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

etc/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Main variables
44
[main]
55
banner = "NGINX Declarative API"
6-
version = "5.3.0"
6+
version = "5.3.1"
77
url = "https://github.com/f5devcentral/NGINX-Declarative-API"
88

99
# Templates

src/v5_3/NAPUtils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def checkDeclarationPolicies(declaration: dict):
149149

150150
# For the given declaration creates/updates NGINX App Protect WAF policies on NGINX Instance Manager
151151
# making sure that they are in sync with what is defined in the JSON declaration
152-
# Returns a tuple with two dictionaries: all_policy_names_and_versions, all_policy_active_names_and_uids
152+
# Returns a JSON with status code and content
153153
def provisionPolicies(nmsUrl: str, nmsUsername: str, nmsPassword: str, declaration: dict):
154154
# NGINX App Protect policies - each policy supports multiple tagged versions
155155

@@ -212,7 +212,8 @@ def provisionPolicies(nmsUrl: str, nmsUsername: str, nmsPassword: str, declarati
212212

213213
all_policy_names_and_versions[policy_name].append({'tag': tag, 'uid': uid})
214214

215-
return all_policy_names_and_versions, all_policy_active_names_and_uids
215+
return JSONResponse(status_code=200, content={"all_policy_names_and_versions": all_policy_names_and_versions,
216+
"all_policy_active_names_and_uids": all_policy_active_names_and_uids})
216217

217218

218219
# Publish a NGINX App Protect WAF policy making it active

src/v5_3/NIMOutput.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,17 @@ def NIMOutput(d, declaration: ConfigDeclaration, apiversion: str, b64HttpConf: s
236236
"headers": {'Content-Type': 'application/json'}}
237237

238238
# Provision NGINX App Protect WAF policies to NGINX Instance Manager
239-
provisionedNapPolicies, activePolicyUids = v5_3.NAPUtils.provisionPolicies(
239+
ppReply = v5_3.NAPUtils.provisionPolicies(
240240
nmsUrl=nmsUrl, nmsUsername=nmsUsername, nmsPassword=nmsPassword, declaration=d)
241241

242+
if ppReply.status_code >= 400:
243+
return {"status_code": ppReply.status_code,
244+
"message": {"status_code": ppReply.status_code, "message": {"code": ppReply.status_code, "content": ppReply.content} }}
245+
246+
napPolicies = json.loads(ppReply.body)
247+
provisionedNapPolicies = napPolicies['all_policy_names_and_versions']
248+
activePolicyUids = napPolicies['all_policy_active_names_and_uids']
249+
242250
### / NGINX App Protect policies support
243251

244252
### Publish staged config to instance group

0 commit comments

Comments
 (0)