Better discord webhook url regex#208
Closed
IlluminatiFish wants to merge 8 commits intobee-san:mainfrom
IlluminatiFish:main
Closed
Better discord webhook url regex#208IlluminatiFish wants to merge 8 commits intobee-san:mainfrom IlluminatiFish:main
IlluminatiFish wants to merge 8 commits intobee-san:mainfrom
IlluminatiFish:main
Conversation
Better webhook url regex, to allow other subdomains such as ptb & canary which are actively used as well as allowing for the detection of webhooks using the old domain discordapp.com and allowing for the matching of webhook urls that include the api version after the api path and more distinct expressions for webhook tokens and webhook ids, also allowing for webhook urls that have the scheme of http
bee-san
requested changes
Oct 12, 2021
pywhat/Data/regex.json
Outdated
| { | ||
| "Name": "Discord Webhook", | ||
| "Regex": "(?i)^(https://discord\\.com/api/webhooks/[0-9]+/[A-Za-z0-9-_]+)$", | ||
| "Regex": "(?i)^(https?:\/\/(?:ptb\.|canary\.)?discord(?:app)?\.com\/api(?:\/v\d{1,2})?\/webhooks\/(\d{17,19})\/([\w\-]{68}))$", |
Owner
There was a problem hiding this comment.
Any chance we can get tests for ptb, canary and discordapp ? :)
Contributor
Author
There was a problem hiding this comment.
Sure thing! :)
Added more discord webhook test candidates, to test the api version string and the new subdomains & domains (ptb, canary and discordapp)
Hopefully this escaped everything
Forgot to escape one more character class
More escaping of regex in the JSON file
Hopefully this is the final commit
Fix indent
bee-san
requested changes
Oct 13, 2021
| "https://canary.discordapp.com/api/v9/webhooks/894893734582452235/KhNc2-_zwY9FfCAK0iGUa_KfYyW8m5Ja_5i-V24fEY6ETwvLLn-GmdT_vq0Do9-YRsij" | ||
| ] | ||
| ) | ||
| _assert_match_first_item("Discord Webhook", res) |
Owner
There was a problem hiding this comment.
This is only testing that one of these URLs works, not that all of them work. Please make them into separate functions? :) <3
Codecov Report
@@ Coverage Diff @@
## main #208 +/- ##
=======================================
Coverage 94.46% 94.46%
=======================================
Files 14 14
Lines 1717 1717
=======================================
Hits 1622 1622
Misses 95 95
Continue to review full report at Codecov.
|
IlluminatiFish
added a commit
to IlluminatiFish/pyWhat
that referenced
this pull request
Oct 17, 2021
Added loads of test candidates and updated discord webhook regex as per bee-san#208
1 task
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prerequisites
Why do we need this pull request?
Better webhook url regex, to allow other subdomains such as ptb & canary which are actively used as well as allowing for the detection of webhooks using the old domain discordapp.com and allowing for the matching of webhook urls that include the api version after the api path and more distinct expressions for webhook tokens and webhook ids, also allowing for webhook urls that have the scheme of http
What GitHub issues does this fix?
Expands upon changes made in #173
Copy / paste of output
Couldn't get the script to work so I could not test the changes to the regex i've made with the regex however I have tested it on its own in python 3.10 as well as using https://pythex.org