Skip to content
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

Added / fixed tests and regex #175

Merged
merged 10 commits into from
Oct 6, 2021
55 changes: 41 additions & 14 deletions pywhat/Data/regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,19 @@
"Bug Bounty"
]
},
{
"Name": "Node Package Manager (NPM) Token",
"Regex": "^(npm_[0-9a-zA-Z]{36})$",
"plural_name": false,
"Description": null,
"Exploit": null,
"Rarity": 1,
"URL": null,
"Tags": [
"Token",
"Bug Bounty"
]
},
{
"Name": "GitHub Personal Access Token",
"Regex": "^(ghp_[0-9a-zA-Z]{36})$",
Expand Down Expand Up @@ -755,20 +768,6 @@
"Credentials"
]
},
{
"Name": "Bitly Secret Key",
"Regex": "(?i)^(R_[0-9a-f]{32})$",
"plural_name": false,
"Description": null,
"Exploit": "Use the command below to verify that the secret key is valid:\n $ curl \"https://api-ssl.bitly.com/v3/shorten?access_token=SECRET_KEY_HERE&longUrl=https://www.google.com\"\n",
"Rarity": 1,
"URL": null,
"Tags": [
"Bug Bounty",
"Credentials",
"API Keys"
]
},
{
"Name": "PyPi Upload Token",
"Regex": "(?i)^(pypi-AgEIcHlwaS5vcmc[A-Za-z0-9-_]+)$",
Expand Down Expand Up @@ -1044,6 +1043,34 @@
"Bug Bounty"
]
},
{
"Name": "Bitly Secret Key",
"Regex": "^([0-9a-f]{40})$",
"plural_name": false,
"Description": null,
"Exploit": "Use the command below to verify that the secret key is valid:\n $ curl \"https://api-ssl.bitly.com/v3/shorten?access_token=SECRET_KEY_HERE&longUrl=https://www.google.com\"\n",
"Rarity": 0.5,
"URL": null,
"Tags": [
"Bug Bounty",
"Credentials",
"API Keys"
]
},
{
"Name": "Visual Studio App Center API Token",
"Regex": "^([0-9a-f]{40})$",
"plural_name": false,
"Description": null,
"Rarity": 0.5,
"Exploit":null,
"URL": null,
"Tags": [
"Identifiers",
"API Keys",
"Bug Bounty"
]
},
{
"Name": "YouTube Channel ID",
"Regex": "^(UC[0-9A-Za-z_-]{21}[AQgw]{1})$",
Expand Down
18 changes: 16 additions & 2 deletions tests/test_regex_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ def test_regex_successfully_parses():


def _assert_match_in_items(name, res):
0xmostafam marked this conversation as resolved.
Show resolved Hide resolved
for i in res:
assert i["Regex Pattern"]["Name"] == name
assert any(name in i["Regex Pattern"]["Name"] for i in res)


@pytest.mark.skip(
Expand Down Expand Up @@ -266,6 +265,21 @@ def test_litecoin():
_assert_match_first_item("Litecoin (LTC) Wallet Address", res)


def test_visual_studio_token():
res = r.check(["4435bc4358816be97a3f014499116c83ab224fb2"])
_assert_match_in_items("Visual Studio App Center API Token", res)


def test_npm_token():
res = r.check(["npm_ir3kktsOr4JeXqeD72C3cWo2mbs5sQ2pfnt9"])
_assert_match_first_item("Node Package Manager (NPM) Token", res)


def test_bitly_secret_key():
res = r.check(["96f79079f1d658895d188a78f303220c6f161b05"])
_assert_match_in_items("Bitly Secret Key", res)


def test_bitcoincash():
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
_assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
Expand Down