From b1ba0e9f2c446e33eb1c3983a47f470a8ac14ef3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ou=C5=A1ek?= <brousek@ics.muni.cz>
Date: Tue, 19 Mar 2024 20:32:21 +0100
Subject: [PATCH] CONFORMANCE_IDP_BASE_URL

---
 .../{saml-headless.yaml => saml-headless-all.yaml}         | 6 +++---
 nuclei-templates/{saml-raw.yaml => saml-raw-all.yaml}      | 7 ++++---
 2 files changed, 7 insertions(+), 6 deletions(-)
 rename nuclei-templates/{saml-headless.yaml => saml-headless-all.yaml} (80%)
 rename nuclei-templates/{saml-raw.yaml => saml-raw-all.yaml} (86%)

diff --git a/nuclei-templates/saml-headless.yaml b/nuclei-templates/saml-headless-all.yaml
similarity index 80%
rename from nuclei-templates/saml-headless.yaml
rename to nuclei-templates/saml-headless-all.yaml
index 649a7f5..7332a7f 100644
--- a/nuclei-templates/saml-headless.yaml
+++ b/nuclei-templates/saml-headless-all.yaml
@@ -6,7 +6,7 @@ info:
   tags: saml,headless
 variables:
   AUTHORIZATION: "Bearer abcd...789"
-  CONFORMANCE_IDP_HOSTNAME: conformance-idp.maiv1.incubator.geant.org
+  CONFORMANCE_IDP_BASE_URL: https://conformance-idp.maiv1.incubator.geant.org/
   RESULT_OUTPUT_DIR: ""
   FILENAME: '{{date_time("%Y-%M-%D_%H-%m-%s")}}-{{replace_regex(BaseURL,"(\\W+)","_")}}'
   TEST_CASES:
@@ -33,11 +33,11 @@ headless:
         value: "{{AUTHORIZATION}}"
     - action: navigate
       args:
-        url: "https://{{CONFORMANCE_IDP_HOSTNAME}}/module.php/conformance/test/setup?testId={{url_encode(TEST_CASE)}}&spEntityId={{url_encode(SP_ENTITY_ID)}}"
+        url: "{{trim_suffix(CONFORMANCE_IDP_BASE_URL, '/')}}/module.php/conformance/test/setup?testId={{url_encode(TEST_CASE)}}&spEntityId={{url_encode(SP_ENTITY_ID)}}"
     - action: waitload
     - action: navigate
       args:
-        url: "https://{{CONFORMANCE_IDP_HOSTNAME}}/saml2/idp/SSOService.php?spentityid={{url_encode(SP_ENTITY_ID)}}&ConsumerURL={{url_encode(BaseURL)}}"
+        url: "{{trim_suffix(CONFORMANCE_IDP_BASE_URL, '/')}}/saml2/idp/SSOService.php?spentityid={{url_encode(SP_ENTITY_ID)}}&ConsumerURL={{url_encode(BaseURL)}}"
     - action: waitload
     - action: screenshot
       args:
diff --git a/nuclei-templates/saml-raw.yaml b/nuclei-templates/saml-raw-all.yaml
similarity index 86%
rename from nuclei-templates/saml-raw.yaml
rename to nuclei-templates/saml-raw-all.yaml
index 3393d51..aa83b71 100644
--- a/nuclei-templates/saml-raw.yaml
+++ b/nuclei-templates/saml-raw-all.yaml
@@ -6,7 +6,8 @@ info:
   tags: saml,raw
 variables:
   AUTHORIZATION: "Bearer abcd...789"
-  CONFORMANCE_IDP_HOSTNAME: conformance-idp.maiv1.incubator.geant.org
+  CONFORMANCE_IDP_BASE_URL: https://conformance-idp.maiv1.incubator.geant.org/
+  CONFORMANCE_IDP_HOSTNAME: '{{replace_regex(CONFORMANCE_IDP_BASE_URL, "^https?://|/.*$", "")}}'
   TEST_CASES:
     - noSignature
     - invalidSignature
@@ -52,9 +53,9 @@ http:
   # HTTP-POST binding
   - raw:
       - |
-        @Host: {{replace_regex(trim_prefix(trim(acs,"[]"), "https://"), "/.*", "")}}
+        @Host: {{replace_regex(trim(acs,"[]"), "^https?://|/.*$", "")}}
         POST {{trim(acs,"[]")}} HTTP/1.1
-        Host: {{replace_regex(trim_prefix(trim(acs,"[]"), "https://"), "/.*", "")}}
+        Host: {{replace_regex(trim(acs,"[]"), "^https?://|/.*$", "")}}
         Content-Type: application/x-www-form-urlencoded
 
         SAMLResponse={{url_encode(trim(samlresponse,"[]"))}}
-- 
GitLab