{
  "name": "Vouli IQ — verified webhook router",
  "flow": [
    {
      "id": 1,
      "module": "gateway:CustomWebHook",
      "version": 1,
      "parameters": {
        "hook": null,
        "maxResults": 1
      },
      "mapper": {},
      "metadata": {
        "designer": {
          "x": 0,
          "y": 0
        }
      }
    },
    {
      "id": 6,
      "module": "builtin:BasicRouter",
      "version": 1,
      "mapper": null,
      "metadata": {
        "designer": {
          "x": 150,
          "y": 0
        }
      },
      "routes": [
        {
          "flow": [
            {
              "id": 3,
              "module": "gateway:WebhookRespond",
              "version": 1,
              "parameters": {},
              "filter": {
                "name": "X-Vouli-Signature-V2 is valid (HMAC-SHA256 of \"<timestamp>.<raw body>\") and signed within 300 s",
                "conditions": [
                  [
                    {
                      "a": "{{get(map(1.`__IMTHEADERS__`; \"value\"; \"name\"; \"x-vouli-signature-v2\"); 1)}}",
                      "b": "{{\"v2=\" + sha256(get(map(1.`__IMTHEADERS__`; \"value\"; \"name\"; \"x-vouli-timestamp\"); 1) + \".\" + 1.value; \"hex\"; \"PASTE_YOUR_whsec_SECRET_HERE\")}}",
                      "o": "text:contain"
                    },
                    {
                      "a": "{{abs(parseNumber(formatDate(now; \"X\"); \".\") - parseNumber(get(map(1.`__IMTHEADERS__`; \"value\"; \"name\"; \"x-vouli-timestamp\"); 1); \".\"))}}",
                      "b": "300",
                      "o": "number:lessorequal"
                    }
                  ]
                ]
              },
              "mapper": {
                "status": "200",
                "body": "{\"received\":true}",
                "headers": [
                  {
                    "key": "Content-Type",
                    "value": "application/json"
                  }
                ]
              },
              "metadata": {
                "designer": {
                  "x": 300,
                  "y": -150
                }
              }
            },
            {
              "id": 4,
              "module": "json:ParseJSON",
              "version": 1,
              "parameters": {
                "type": ""
              },
              "mapper": {
                "json": "{{1.value}}"
              },
              "metadata": {
                "designer": {
                  "x": 600,
                  "y": -150
                }
              }
            },
            {
              "id": 5,
              "module": "builtin:BasicRouter",
              "version": 1,
              "mapper": null,
              "metadata": {
                "designer": {
                  "x": 900,
                  "y": -150
                }
              },
              "routes": [
                {
                  "flow": [
                    {
                      "id": 10,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = assessment.completed",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "assessment.completed",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_assessment_completed",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": -450
                        }
                      }
                    }
                  ]
                },
                {
                  "flow": [
                    {
                      "id": 11,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = verdict.changed",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "verdict.changed",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_verdict_changed",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": -300
                        }
                      }
                    }
                  ]
                },
                {
                  "flow": [
                    {
                      "id": 12,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = roadmap.updated",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "roadmap.updated",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_roadmap_updated",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": -150
                        }
                      }
                    }
                  ]
                },
                {
                  "flow": [
                    {
                      "id": 13,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = risk.created",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "risk.created",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_risk_created",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": 0
                        }
                      }
                    }
                  ]
                },
                {
                  "flow": [
                    {
                      "id": 14,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = risk.severity_changed",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "risk.severity_changed",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_risk_severity_changed",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": 150
                        }
                      }
                    }
                  ]
                },
                {
                  "flow": [
                    {
                      "id": 15,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = compliance.posture_changed",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "compliance.posture_changed",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_compliance_posture_changed",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": 300
                        }
                      }
                    }
                  ]
                },
                {
                  "flow": [
                    {
                      "id": 16,
                      "module": "util:SetVariable2",
                      "version": 1,
                      "parameters": {},
                      "filter": {
                        "name": "type = evidence.pack_filed",
                        "conditions": [
                          [
                            {
                              "a": "{{4.type}}",
                              "b": "evidence.pack_filed",
                              "o": "text:equal"
                            }
                          ]
                        ]
                      },
                      "mapper": {
                        "name": "vouli_evidence_pack_filed",
                        "scope": "roundtrip",
                        "value": "{{4.data}}"
                      },
                      "metadata": {
                        "designer": {
                          "x": 1200,
                          "y": 450
                        }
                      }
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "flow": [
            {
              "id": 2,
              "module": "gateway:WebhookRespond",
              "version": 1,
              "parameters": {},
              "filter": {
                "name": "X-Vouli-Signature-V2 is missing or invalid, or older than 300 s",
                "conditions": [
                  [
                    {
                      "a": "{{get(map(1.`__IMTHEADERS__`; \"value\"; \"name\"; \"x-vouli-signature-v2\"); 1)}}",
                      "b": "{{\"v2=\" + sha256(get(map(1.`__IMTHEADERS__`; \"value\"; \"name\"; \"x-vouli-timestamp\"); 1) + \".\" + 1.value; \"hex\"; \"PASTE_YOUR_whsec_SECRET_HERE\")}}",
                      "o": "text:notcontain"
                    }
                  ],
                  [
                    {
                      "a": "{{abs(parseNumber(formatDate(now; \"X\"); \".\") - parseNumber(get(map(1.`__IMTHEADERS__`; \"value\"; \"name\"; \"x-vouli-timestamp\"); 1); \".\"))}}",
                      "b": "300",
                      "o": "number:greater"
                    }
                  ]
                ]
              },
              "mapper": {
                "status": "401",
                "body": "invalid signature",
                "headers": []
              },
              "metadata": {
                "designer": {
                  "x": 300,
                  "y": 150
                }
              }
            }
          ]
        }
      ]
    }
  ],
  "metadata": {
    "instant": true,
    "version": 1,
    "scenario": {
      "roundtrips": 1,
      "maxErrors": 3,
      "autoCommit": true,
      "autoCommitTriggerLast": true,
      "sequential": false,
      "confidential": true,
      "dataloss": false,
      "dlq": false,
      "freshVariables": false
    },
    "designer": {
      "orphans": []
    },
    "zone": "eu1.make.com"
  }
}
