-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: webhook regex url with underscores #1755
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"value": "webhookUrl", | ||
"required": true, | ||
"placeholder": "http://www.abcd.com", | ||
"regex": "^(https?:\\/\\/)(?![a-zA-Z0-9-]*\\.ngrok\\.io)(?!localhost|.*\\.localhost)([a-zA-Z0-9-]{1,63}\\.)+[a-zA-Z]{2,}(\\/.*)?$" | ||
"regex": "^(https?:\\/\\/)(?![a-zA-Z0-9-]*\\.ngrok\\.io)(?!localhost|.*\\.localhost)([a-zA-Z0-9-_]{1,63}\\.)+[a-zA-Z]{2,}(\\/.*)?$" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Issue Identified: Regex Fails to Exclude Base Domain "ngrok.io" The current regex incorrectly allows the base domain Recommended Actions:
🔗 Analysis chainLGTM: Regex updated to allow underscores in domain names. The change successfully addresses the PR objective by allowing underscores in the domain part of the webhook URL. This modification maintains all existing validations while expanding the range of accepted URLs. While this change improves flexibility, it's worth noting that technically, according to RFC 1034, underscores are not allowed in domain names. However, they are widely used and accepted in practice. To ensure compatibility, you may want to verify that all systems interacting with these URLs can handle underscores in domain names without issues. To verify the regex change, you can use the following script: This script will test the updated regex against various valid and invalid URLs to ensure it behaves as expected. [/run_scripts] [/run_scripts] [/run_scripts] 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Test cases
valid_urls=(
"http://example.com"
"https://sub_domain.example.com"
"http://sub-domain.example_domain.com/path"
)
invalid_urls=(
"http://localhost"
"https://example.localhost"
"http://ngrok.io"
"ftp://example.com"
)
# Function to test regex
test_regex() {
local regex="$1"
local url="$2"
if echo "$url" | grep -qP "$regex"; then
echo "PASS: $url"
else
echo "FAIL: $url"
fi
}
# Extract regex from file
regex=$(grep -oP '(?<="regex": ").*(?=")' src/configurations/destinations/webhook/ui-config.json)
echo "Testing valid URLs:"
for url in "${valid_urls[@]}"; do
test_regex "$regex" "$url"
done
echo -e "\nTesting invalid URLs:"
for url in "${invalid_urls[@]}"; do
test_regex "$regex" "$url"
done
Length of output: 9882 Script: #!/bin/bash
# Test cases
valid_urls=(
"http://example.com"
"https://sub_domain.example.com"
"http://sub-domain.example_domain.com/path"
)
invalid_urls=(
"http://localhost"
"https://example.localhost"
"http://ngrok.io"
"ftp://example.com"
)
# Function to test regex
test_regex() {
local regex="$1"
local url="$2"
if echo "$url" | grep -P "$regex" >/dev/null 2>&1; then
echo "PASS: $url"
else
echo "FAIL: $url"
fi
}
# Extract regex from file using jq for accurate parsing
regex=$(jq -r '.regex' src/configurations/destinations/webhook/ui-config.json)
echo "Extracted Regex: $regex"
echo "Testing valid URLs:"
for url in "${valid_urls[@]}"; do
test_regex "$regex" "$url"
done
echo -e "\nTesting invalid URLs:"
for url in "${invalid_urls[@]}"; do
test_regex "$regex" "$url"
done
Length of output: 2180 Script: #!/bin/bash
# Display the entire JSON content for manual inspection
echo "Full JSON Content:"
cat src/configurations/destinations/webhook/ui-config.json
echo -e "\nListing top-level keys:"
jq 'keys' src/configurations/destinations/webhook/ui-config.json
echo -e "\nSearching for 'regex' key at any depth:"
jq '.. | .regex? // empty' src/configurations/destinations/webhook/ui-config.json
Length of output: 6740 Script: #!/bin/bash
# Test cases
valid_urls=(
"http://example.com"
"https://sub_domain.example.com"
"http://sub-domain.example_domain.com/path"
)
invalid_urls=(
"http://localhost"
"https://example.localhost"
"http://ngrok.io"
"ftp://example.com"
)
# Function to test regex
test_regex() {
local regex="$1"
local url="$2"
if echo "$url" | grep -P "$regex" >/dev/null 2>&1; then
echo "PASS: $url"
else
echo "FAIL: $url"
fi
}
# Extract regex for "Webhook URL" field using jq
regex=$(jq -r '.uiConfig[].fields[] | select(.label == "Webhook URL").regex' src/configurations/destinations/webhook/ui-config.json)
echo "Extracted Regex for 'Webhook URL': $regex"
echo "Testing valid URLs:"
for url in "${valid_urls[@]}"; do
test_regex "$regex" "$url"
done
echo -e "\nTesting invalid URLs:"
for url in "${invalid_urls[@]}"; do
test_regex "$regex" "$url"
done
Length of output: 4938 |
||
}, | ||
{ | ||
"type": "singleSelect", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ is valid only for subdomains, not for domains