bee-san / pyWhat

🐸 Identify anything. pyWhat easily lets you identify emails, IP addresses, and more. Feed it a .pcap file or some text and it'll tell you what it is! 🧙‍♀️
MIT License
6.52k stars 350 forks source link

Remove duplicate regexes, add test to spot duplicate regexes #215

Closed hexiro closed 2 years ago

hexiro commented 2 years ago

Prerequisites

Why do we need this pull request?

Adds a test to check for duplicate regexes by name. This is useful to prevent someone from adding a regex for something that already exists. Though, this might not always work out because the names need to be an exact match. This also deletes one of the duplicate regexes.

What GitHub issues does this fix?

Copy / paste of output

Please copy and paste the output of PyWhat with your new addition using an example that tests this addition below:

Gets rid of second match

Matched on: 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:test@github.com
Name: GitHub Access Token
Exploit: Use the command below to verify that the access token is valid:
  $ curl -s -u "user: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:test@github.com" https://api.github.com/user
  curl -s -H "Authorization: token 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:test@github.com" "https://api.github.com/users/[USERNAME]/orgs"
 . # Check scope of your api token
 $  curl "https://api.github.com/rate_limit" -i -u "user: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:test@github.com" | grep "X-OAuth-Scopes:"

Matched on: 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
Name: GitHub Personal Access Token
Exploit: Use the command below to verify that the access token is valid:
  $ curl -s -u "user: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" https://api.github.com/user
  curl -s -H "Authorization: token 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" "https://api.github.com/users/[USERNAME]/orgs"
 . # Check scope of your api token
 $  curl "https://api.github.com/rate_limit" -i -u "user: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" | grep "X-OAuth-Scopes:"

Matched on: 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:test@github.com
Name: Uniform Resource Locator (URL)

Matched on: test@github.com
Name: Email Address

Matched on: R4kszbsOnupGqTEGPx4mYQmeeaAIAC33tH
Name: Ripple (XRP) Wallet Address
Link:  https://xrpscan.com/account/R4kszbsOnupGqTEGPx4mYQmeeaAIAC33tH
codecov-commenter commented 2 years ago

Codecov Report

Merging #215 (1083b4b) into main (e2e109e) will increase coverage by 0.02%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   92.35%   92.37%   +0.02%     
==========================================
  Files          14       14              
  Lines        1203     1207       +4     
==========================================
+ Hits         1111     1115       +4     
  Misses         92       92              
Impacted Files Coverage Δ
tests/test_regex_database.py 88.88% <100.00%> (+1.38%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e2e109e...1083b4b. Read the comment docs.

bee-san commented 2 years ago

thanks so much!!!