From db94be13159cc8ac11e49544f089b5288c3c234f Mon Sep 17 00:00:00 2001 From: Dino Chiesa Date: Fri, 20 Sep 2024 15:17:35 -0700 Subject: [PATCH] add check for multiple fallbacks --- ...cate-servers.js => TD008-target-LB-servers.js} | 15 +++++++++++++++ test/fixtures/resources/TD008/fail/t4.xml | 14 ++++++++++++++ test/fixtures/resources/TD008/pass/t4.xml | 12 ++++++++++++ 3 files changed, 41 insertions(+) rename lib/package/plugins/{TD008-target-LB-duplicate-servers.js => TD008-target-LB-servers.js} (89%) create mode 100644 test/fixtures/resources/TD008/fail/t4.xml create mode 100644 test/fixtures/resources/TD008/pass/t4.xml diff --git a/lib/package/plugins/TD008-target-LB-duplicate-servers.js b/lib/package/plugins/TD008-target-LB-servers.js similarity index 89% rename from lib/package/plugins/TD008-target-LB-duplicate-servers.js rename to lib/package/plugins/TD008-target-LB-servers.js index 3973885..dc82126 100644 --- a/lib/package/plugins/TD008-target-LB-duplicate-servers.js +++ b/lib/package/plugins/TD008-target-LB-servers.js @@ -43,6 +43,21 @@ const onTargetEndpoint = function (endpoint, cb) { if (loadBalancers.length == 1) { const loadBalancer = loadBalancers[0]; + // check multiple fallbacks + const fallbacks = xpath.select( + "Server[IsFallback = 'true']", + loadBalancer + ); + if (fallbacks.length > 1) { + endpoint.addMessage({ + plugin, + line: loadBalancers[0].lineNumber, + column: loadBalancers[0].columnNumber, + message: "Multiple Server entries with IsFallback=true" + }); + flagged = true; + } + const servers = xpath.select("Server", loadBalancer); if (servers.length > 1) { const previouslyDetected = []; diff --git a/test/fixtures/resources/TD008/fail/t4.xml b/test/fixtures/resources/TD008/fail/t4.xml new file mode 100644 index 0000000..4dc231a --- /dev/null +++ b/test/fixtures/resources/TD008/fail/t4.xml @@ -0,0 +1,14 @@ + + + + + + + true + + + true + + + + diff --git a/test/fixtures/resources/TD008/pass/t4.xml b/test/fixtures/resources/TD008/pass/t4.xml new file mode 100644 index 0000000..8f11d85 --- /dev/null +++ b/test/fixtures/resources/TD008/pass/t4.xml @@ -0,0 +1,12 @@ + + + + + + + + true + + + +