From ac578b4a26215a6b8ef4386b54ff2c5b9795f9da Mon Sep 17 00:00:00 2001 From: msingh-developer <133210848+msingh-developer@users.noreply.github.com> Date: Mon, 18 Nov 2024 19:56:06 +0530 Subject: [PATCH] Dv 14890 rules fix (#9) * New rules(p1Flow and inputSchema) issue fix * Update rules.json * Recommendation message for node color change --------- Co-authored-by: GitHub Action --- docs/rules.json | 10 +- package-lock.json | 4 +- package.json | 4 +- rules/dv-rule-node-001/NodeRule.js | 4 +- .../PingOneFlowRule.js | 4 +- .../tests/PingOneFlowRule.expect.json | 4 +- .../tests/PingOneFlowRule.json | 525 +++++++++--------- rules/dv-rule-subflow-001/SubflowRule.js | 7 +- .../tests/SubflowRule3.expect.json | 10 +- 9 files changed, 290 insertions(+), 282 deletions(-) diff --git a/docs/rules.json b/docs/rules.json index 8e939b4..34224e6 100644 --- a/docs/rules.json +++ b/docs/rules.json @@ -2,7 +2,7 @@ { "name": "@ping-identity/dvlint-base-rule-pack", "description": "Collection of base rules used to lint DaVinci flows.", - "version": "1.0.5", + "version": "1.0.6", "rules": [ { "id": "dv-rule-annotations-001", @@ -150,7 +150,7 @@ "description": "All success/error JSON nodes should proper colors", "message": "Incorrect node color [%] - %", "type": "best-practice", - "recommendation": "The [%] - % is not using the correct color. To ensure consistency, use the recommended color: [%].", + "recommendation": "The <%> is not using the correct color. To ensure consistency, use the recommended color: [%].", "code": "dv-bp-node-002" }, "dv-bp-node-003": { @@ -201,7 +201,7 @@ "description": "Incorrect ending nodes for PingOne flow.", "message": "Incorrect ending nodes for PingOne flow.", "type": "error", - "recommendation": "This PingOne-enabled flow is missing an appropriate ending node. These flows should conclude with either a 'Return a Success Response' node or a 'Return an Error Response' node.", + "recommendation": "This PingOne-enabled flow is missing appropriate ending nodes. These flows should conclude with either a 'Return Success Response (Redirect Flows)' node or a 'Return Error Response (Redirect Flows)' node of the PingOne Authentication connector.", "code": "dv-er-pingOneFlow-001" } }, @@ -227,8 +227,8 @@ "code": "dv-er-subflow-002" }, "dv-er-subflow-003": { - "description": "Missing Input schema values.", - "message": "Input Schema values '%' for '%' subflow is not configured in main flow.", + "description": "Missing Input schema values", + "message": "Input Schema values for '%' subflow is not configured.", "type": "error", "recommendation": "The input schema values for the '%' subflow are not currently configured. Configure the schema in the subflow.", "code": "dv-er-subflow-003" diff --git a/package-lock.json b/package-lock.json index 9bc8c2f..145b7b3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@ping-identity/dvlint-base-rule-pack", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ping-identity/dvlint-base-rule-pack", - "version": "1.0.5", + "version": "1.0.6", "license": "Apache License 2.0", "dependencies": { "@ping-identity/dvlint": "^1.0.3" diff --git a/package.json b/package.json index 1475103..c148e4b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ping-identity/dvlint-base-rule-pack", - "version": "1.0.5", + "version": "1.0.6", "description": "Collection of base rules used to lint DaVinci flows.", "main": "RulePack.js", "scripts": { @@ -37,4 +37,4 @@ "dependencies": { "@ping-identity/dvlint": "^1.0.3" } -} \ No newline at end of file +} diff --git a/rules/dv-rule-node-001/NodeRule.js b/rules/dv-rule-node-001/NodeRule.js index 22d1bb6..a3ddd9f 100644 --- a/rules/dv-rule-node-001/NodeRule.js +++ b/rules/dv-rule-node-001/NodeRule.js @@ -24,7 +24,7 @@ class NodeRule extends LintRule { description: "All success/error JSON nodes should proper colors", message: "Incorrect node color [%] - %", type: "best-practice", - recommendation: "The [%] - % is not using the correct color. To ensure consistency, use the recommended color: [%].", + recommendation: "The <%> is not using the correct color. To ensure consistency, use the recommended color: [%].", }); this.addCode("dv-bp-node-003", { description: "All nodes should have a description", @@ -95,7 +95,7 @@ class NodeRule extends LintRule { data.properties?.backgroundColor?.value.toLowerCase(), `${data.name} (${data.id}) - ${data.capabilityName}`, ], - recommendationArgs: [backgroundColor[connectorCapability], `${data.name} (${data.id}) - ${data.capabilityName}`], + recommendationArgs: [`${data.name} (${data.id}) - ${data.capabilityName}`, backgroundColor[connectorCapability]], nodeId: data.id, }); } diff --git a/rules/dv-rule-pingOneFlow-001/PingOneFlowRule.js b/rules/dv-rule-pingOneFlow-001/PingOneFlowRule.js index c1157d7..bc9a4ba 100644 --- a/rules/dv-rule-pingOneFlow-001/PingOneFlowRule.js +++ b/rules/dv-rule-pingOneFlow-001/PingOneFlowRule.js @@ -12,7 +12,7 @@ class PingOneFlowRule extends LintRule { description: "Incorrect ending nodes for PingOne flow.", message: "Incorrect ending nodes for PingOne flow.", type: "error", - recommendation: "This PingOne-enabled flow is missing an appropriate ending node. These flows should conclude with either a 'Return a Success Response' node or a 'Return an Error Response' node." + recommendation: "This PingOne-enabled flow is missing appropriate ending nodes. These flows should conclude with either a 'Return Success Response (Redirect Flows)' node or a 'Return Error Response (Redirect Flows)' node of the PingOne Authentication connector." }); } @@ -22,7 +22,7 @@ class PingOneFlowRule extends LintRule { // Incorrect ending nodes for PingOne flow if (targetFlow?.settings?.pingOneFlow) { - const endNodesCapability = ['createErrorResponse', 'createSuccessResponse']; + const endNodesCapability = ['returnSuccessResponseRedirect', 'returnErrorResponseRedirect']; const endNodesData = targetFlow.graphData.elements.nodes?.filter(node => endNodesCapability.includes(node.data.capabilityName)) || []; const nodeIdMap = endNodesData.map(node => node.data.id); const nodeSourceMap = targetFlow.graphData.elements.edges?.map(edge => edge.data.source) || []; diff --git a/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.expect.json b/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.expect.json index fa182e2..3268f44 100644 --- a/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.expect.json +++ b/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.expect.json @@ -17,7 +17,7 @@ "code": "dv-er-pingOneFlow-001", "message": "Incorrect ending nodes for PingOne flow.", "type": "error", - "recommendation": "This PingOne-enabled flow is missing an appropriate ending node. These flows should conclude with either a 'Return a Success Response' node or a 'Return an Error Response' node." + "recommendation": "This PingOne-enabled flow is missing appropriate ending nodes. These flows should conclude with either a 'Return Success Response (Redirect Flows)' node or a 'Return Error Response (Redirect Flows)' node of the PingOne Authentication connector." } ], "rulesApplied": [ @@ -34,7 +34,7 @@ "code": "dv-er-pingOneFlow-001", "message": "Incorrect ending nodes for PingOne flow.", "type": "error", - "recommendation": "This PingOne-enabled flow is missing an appropriate ending node. These flows should conclude with either a 'Return a Success Response' node or a 'Return an Error Response' node." + "recommendation": "This PingOne-enabled flow is missing appropriate ending nodes. These flows should conclude with either a 'Return Success Response (Redirect Flows)' node or a 'Return Error Response (Redirect Flows)' node of the PingOne Authentication connector." } ] } diff --git a/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.json b/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.json index daae8af..a683dad 100644 --- a/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.json +++ b/rules/dv-rule-pingOneFlow-001/tests/PingOneFlowRule.json @@ -1,271 +1,276 @@ { - "companyId": "6YWgejhFHGFyhZM57KfdhnYf7fmeMZKM", - "connectorIds": [ - "httpConnector" - ], - "createdDate": 1729754257220, - "currentVersion": 9, - "customerId": "1576bd3c19c0fb0a828342b21d46a57e", - "description": "", - "flowStatus": "enabled", - "name": "testPingOneFlow", - "flowId": "f78ec9aa1c267c440e46e0db665c64a0", - "versionId": 9, - "graphData": { - "elements": { - "nodes": [ - { - "data": { - "id": "wt491cq4ts", - "nodeType": "CONNECTION", - "connectionId": "26389add19130693fbd0dfc5217c6d9b", - "connectorId": "httpConnector", - "name": "HTTP-1729677766708", - "label": "HTTP-1729677766708", - "status": "configured", - "capabilityName": "customHtmlMessage", - "type": "trigger", - "properties": { - "showContinueButton": { - "value": true - }, - "button": { - "displayName": "Node 1" - }, - "messageTitle": { - "value": "[\n {\n \"children\": [\n {\n \"text\": \"Start Node\"\n }\n ]\n }\n]" - }, - "nodeTitle": { - "value": "Start Node" - }, - "nodeDescription": { - "value": "Start Node Desc" - } + "companyId": "18f50856-c4db-472e-9b6f-ede77e39f617", + "authTokenExpireIds": [], + "connectorIds": [ + "httpConnector", + "pingOneAuthenticationConnector" + ], + "createdDate": 1731913455975, + "currentVersion": 6, + "customerId": "aa71686ea426ffce6d9c5661f36734ec", + "description": "Imported on Fri Nov 15 2024 10:41:25 GMT+0000 (Coordinated Universal Time)", + "flowStatus": "enabled", + "inputSchemaCompiled": { + "parameters": { + "type": "object", + "properties": { + "subflowfield1": { + "description": "some desc", + "preferredDataType": "string", + "isExpanded": true, + "type": "string", + "name": "subflowfield1" + } + }, + "additionalProperties": false, + "required": [] + } + }, + "isInputSchemaSaved": true, + "isOutputSchemaSaved": false, + "name": "testPingOneFlow", + "publishedVersion": 1, + "settings": { + "csp": "worker-src 'self' blob:; script-src 'self' https://cdn.jsdelivr.net https://code.jquery.com https://devsdk.singularkey.com http://cdnjs.cloudflare.com 'unsafe-inline' 'unsafe-eval';", + "intermediateLoadingScreenCSS": "", + "intermediateLoadingScreenHTML": "", + "pingOneFlow": true + }, + "flowId": "f78ec9aa1c267c440e46e0db665c64a0", + "versionId": 6, + "graphData": { + "elements": { + "nodes": [ + { + "data": { + "id": "1vblmjv3vi", + "nodeType": "CONNECTION", + "connectionId": "481e952e6b11db8360587b8711620786", + "connectorId": "httpConnector", + "name": "HTTP", + "label": "HTTP", + "status": "configured", + "capabilityName": "customHtmlMessage", + "type": "trigger", + "properties": { + "message": { + "value": "[\n {\n \"children\": [\n {\n \"text\": \"hellow subflow1\"\n }\n ]\n }\n]" + }, + "showContinueButton": { + "value": true } - }, - "position": { - "x": 277, - "y": 236.58954310166553 - }, - "group": "nodes", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": false, - "classes": "" + } }, - { - "data": { - "id": "xmghk6n80n", - "nodeType": "EVAL", - "label": "Evaluator" - }, - "position": { - "x": 402.49996622569824, - "y": 236.29477155083276 - }, - "group": "nodes", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": false, - "classes": "" + "position": { + "x": 277, + "y": 236 }, - { - "data": { - "id": "vt3yauyg3q", - "nodeType": "CONNECTION", - "connectionId": "26389add19130693fbd0dfc5217c6d9b", - "connectorId": "httpConnector", - "name": "HTTP-1729677766708", - "label": "HTTP-1729677766708", - "status": "configured", - "capabilityName": "createErrorResponse", - "type": "action", - "properties": { - "nodeTitle": { - "value": "Error Response Json" - }, - "nodeDescription": { - "value": "some desc" - } - } - }, - "position": { - "x": 527.9999324513966, - "y": 236 - }, - "group": "nodes", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": false, - "classes": "" + "group": "nodes", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": false, + "classes": "" + }, + { + "data": { + "id": "ol1pm5ky3a", + "nodeType": "CONNECTION", + "connectionId": "2e6dfde64d7e0ca275c7c9c57dc8fe63", + "connectorId": "pingOneAuthenticationConnector", + "name": "PingOne Authentication", + "label": "PingOne Authentication", + "status": "configured", + "capabilityName": "returnSuccessResponseRedirect", + "type": "action", + "properties": {} }, - { - "data": { - "id": "q4p9w2dqbc", - "nodeType": "EVAL", - "label": "Evaluator" - }, - "position": { - "x": 708.9999159627962, - "y": 238.500004651572 - }, - "group": "nodes", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": false, - "classes": "" + "position": { + "x": 600, + "y": 240 }, - { - "data": { - "id": "q1iytjg9at", - "nodeType": "CONNECTION", - "connectionId": "26389add19130693fbd0dfc5217c6d9b", - "connectorId": "httpConnector", - "name": "HTTP-1729677766708", - "label": "HTTP-1729677766708", - "status": "configured", - "capabilityName": "createSuccessResponse", - "type": "action", - "properties": { - "nodeTitle": { - "value": "Success Json" - }, - "nodeDescription": { - "value": "some desc" - } - } - }, - "position": { - "x": 889.9998994741958, - "y": 241.000009303144 - }, - "group": "nodes", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": false, - "classes": "" - } - ], - "edges": [ - { - "data": { - "id": "10p794d2ng", - "source": "wt491cq4ts", - "target": "xmghk6n80n" - }, - "position": { - "x": 0, - "y": 0 - }, - "group": "edges", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": true, - "classes": "" + "group": "nodes", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": false, + "classes": "" + }, + { + "data": { + "id": "0mrt1txkd8", + "nodeType": "EVAL", + "label": "Evaluator" }, - { - "data": { - "id": "hxfp64z4jw", - "source": "xmghk6n80n", - "target": "vt3yauyg3q" - }, - "position": { - "x": 0, - "y": 0 - }, - "group": "edges", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": true, - "classes": "" + "position": { + "x": 750, + "y": 240 }, - { - "data": { - "id": "ip8qln89xs", - "source": "vt3yauyg3q", - "target": "q4p9w2dqbc" - }, - "position": { - "x": 0, - "y": 0 - }, - "group": "edges", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": true, - "classes": "" + "group": "nodes", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": false, + "classes": "" + }, + { + "data": { + "id": "6rp1p273wg", + "nodeType": "CONNECTION", + "connectionId": "2e6dfde64d7e0ca275c7c9c57dc8fe63", + "connectorId": "pingOneAuthenticationConnector", + "name": "PingOne Authentication", + "label": "PingOne Authentication", + "status": "configured", + "capabilityName": "returnErrorResponseRedirect", + "type": "action", + "properties": {} }, - { - "data": { - "id": "0968uubr7w", - "source": "q4p9w2dqbc", - "target": "q1iytjg9at" - }, - "position": { - "x": 0, - "y": 0 - }, - "group": "edges", - "removed": false, - "selected": false, - "selectable": true, - "locked": false, - "grabbable": true, - "pannable": true, - "classes": "" - } - ] - }, - "data": {}, - "zoomingEnabled": true, - "userZoomingEnabled": true, - "zoom": 1, - "minZoom": 1e-50, - "maxZoom": 1e+50, - "panningEnabled": true, - "userPanningEnabled": true, - "pan": { - "x": 0, - "y": 0 - }, - "boxSelectionEnabled": true, - "renderer": { - "name": "null" - } + "position": { + "x": 1050, + "y": 240 + }, + "group": "nodes", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": false, + "classes": "" + }, + { + "data": { + "id": "wsk27ay6dr", + "nodeType": "EVAL" + }, + "position": { + "x": 408.5, + "y": 238 + }, + "group": "nodes", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": false, + "classes": "" + } + ], + "edges": [ + { + "data": { + "id": "figtunjcmb", + "source": "ol1pm5ky3a", + "target": "0mrt1txkd8" + }, + "position": { + "x": 0, + "y": 0 + }, + "group": "edges", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": true, + "classes": "" + }, + { + "data": { + "id": "1do6jzvyyw", + "source": "0mrt1txkd8", + "target": "6rp1p273wg" + }, + "position": { + "x": 0, + "y": 0 + }, + "group": "edges", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": true, + "classes": "" + }, + { + "data": { + "id": "x56ykv0dqv", + "source": "1vblmjv3vi", + "target": "wsk27ay6dr" + }, + "position": { + "x": 0, + "y": 0 + }, + "group": "edges", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": true, + "classes": "" + }, + { + "data": { + "id": "jx5cl6h00e", + "source": "wsk27ay6dr", + "target": "ol1pm5ky3a" + }, + "position": { + "x": 0, + "y": 0 + }, + "group": "edges", + "removed": false, + "selected": false, + "selectable": true, + "locked": false, + "grabbable": true, + "pannable": true, + "classes": "" + } + ] }, - "settings": { - "csp": "worker-src 'self' blob:; script-src 'self' https://cdn.jsdelivr.net https://code.jquery.com https://devsdk.singularkey.com http://cdnjs.cloudflare.com 'unsafe-inline' 'unsafe-eval';", - "intermediateLoadingScreenCSS": "", - "intermediateLoadingScreenHTML": "", - "pingOneFlow": true + "data": {}, + "zoomingEnabled": true, + "userZoomingEnabled": true, + "zoom": 1, + "minZoom": 1e-50, + "maxZoom": 1e+50, + "panningEnabled": true, + "userPanningEnabled": true, + "pan": { + "x": 0, + "y": 0 }, - "flowColor": "#AFD5FF", - "savedDate": 1729754257175, - "variables": [], - "connections": [] - } - \ No newline at end of file + "boxSelectionEnabled": true, + "renderer": { + "name": "null" + } + }, + "inputSchema": [ + { + "propertyName": "subflowfield1", + "description": "some desc", + "preferredDataType": "string", + "preferredControlType": "textField", + "isExpanded": true + } + ], + "flowColor": "#AFD5FF", + "savedDate": 1731913455935, + "variables": [], + "connections": [] +} diff --git a/rules/dv-rule-subflow-001/SubflowRule.js b/rules/dv-rule-subflow-001/SubflowRule.js index 157d81f..e0ebfad 100644 --- a/rules/dv-rule-subflow-001/SubflowRule.js +++ b/rules/dv-rule-subflow-001/SubflowRule.js @@ -25,8 +25,8 @@ class DVRule extends LintRule { "In this subflow, '%' points back to '%', which can cause import and export errors. Configure the subflow to return to the parent flow.", }); this.addCode("dv-er-subflow-003", { - description: "Missing Input schema values.", - message: "Input Schema values '%' for '%' subflow is not configured in main flow.", + description: "Missing Input schema values", + message: "Input Schema values for '%' subflow is not configured.", type: "error", recommendation: "The input schema values for the '%' subflow are not currently configured. Configure the schema in the subflow.", }); @@ -92,8 +92,9 @@ class DVRule extends LintRule { if (missingFields?.length > 0) { const selectedSubflowName = node.data.properties.subFlowId.value.label; this.addError("dv-er-subflow-003", { - messageArgs: [missingFields.join(', '), selectedSubflowName], + messageArgs: [selectedSubflowName], recommendationArgs: [selectedSubflowName], + nodeId: node.data.id, }); } } diff --git a/rules/dv-rule-subflow-001/tests/SubflowRule3.expect.json b/rules/dv-rule-subflow-001/tests/SubflowRule3.expect.json index 78b3fb5..a1c6030 100644 --- a/rules/dv-rule-subflow-001/tests/SubflowRule3.expect.json +++ b/rules/dv-rule-subflow-001/tests/SubflowRule3.expect.json @@ -15,9 +15,10 @@ "errors": [ { "code": "dv-er-subflow-003", - "message": "Input Schema values 'inputSchemaSubflow1' for 'subflow1' subflow is not configured in main flow.", + "message": "Input Schema values for 'subflow1' subflow is not configured.", "type": "error", - "recommendation": "The input schema values for the 'subflow1' subflow are not currently configured. Configure the schema in the subflow." + "recommendation": "The input schema values for the 'subflow1' subflow are not currently configured. Configure the schema in the subflow.", + "nodeId": "rmlvzfp7qq" } ], "rulesApplied": [ @@ -32,9 +33,10 @@ "errors": [ { "code": "dv-er-subflow-003", - "message": "Input Schema values 'inputSchemaSubflow1' for 'subflow1' subflow is not configured in main flow.", + "message": "Input Schema values for 'subflow1' subflow is not configured.", "type": "error", - "recommendation": "The input schema values for the 'subflow1' subflow are not currently configured. Configure the schema in the subflow." + "recommendation": "The input schema values for the 'subflow1' subflow are not currently configured. Configure the schema in the subflow.", + "nodeId": "rmlvzfp7qq" } ] }