From c6c727c83f27beb09c43cc60cb41596e757c4748 Mon Sep 17 00:00:00 2001 From: David Clarance Date: Mon, 4 Oct 2021 17:41:51 +0530 Subject: [PATCH 1/6] Adding test token for pypi upload --- tests/test_regex_identifier.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index 9103033..06a6aa2 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -801,3 +801,8 @@ def test_new_relic_synthetics_api_key(): def test_new_relic_user_api_key(): res = r.check(["NRAK-WI4JTVS049IF5A3FGS5N51XS3Y5"]) _assert_match_first_item("New Relic User API Key", res) + + +def test_pypi_upload_token(): + res = r.check(["pypi-AgEIcHlwaS5vcmcCJDZlNzEyNGJmLWQ4N2UtNGZhYS1iNWEzLWQzYzg2YjU3NzAxYgACJXsicGVybWlzc2lvbnMiOiAidXNlciIsICJ2ZXJzaW9uIjogMX0AAAYgeYcgrZO31PTS_3ipsd0fTSMy1kVkxCzhQvHN6m97yIE"]) + _assert_match_first_item("Pypi Upload Token", res) From c87ef84b0cd857323819dab9822839a795d9baf9 Mon Sep 17 00:00:00 2001 From: David Clarance Date: Mon, 4 Oct 2021 17:59:24 +0530 Subject: [PATCH 2/6] Fixed case mismatch --- tests/test_regex_identifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index 06a6aa2..45e40c4 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -805,4 +805,4 @@ def test_new_relic_user_api_key(): def test_pypi_upload_token(): res = r.check(["pypi-AgEIcHlwaS5vcmcCJDZlNzEyNGJmLWQ4N2UtNGZhYS1iNWEzLWQzYzg2YjU3NzAxYgACJXsicGVybWlzc2lvbnMiOiAidXNlciIsICJ2ZXJzaW9uIjogMX0AAAYgeYcgrZO31PTS_3ipsd0fTSMy1kVkxCzhQvHN6m97yIE"]) - _assert_match_first_item("Pypi Upload Token", res) + _assert_match_first_item("PyPi Upload Token", res) From 7c370981df927c0fe65f83e148396eabdc3de983 Mon Sep 17 00:00:00 2001 From: David Clarance Date: Mon, 4 Oct 2021 18:23:05 +0530 Subject: [PATCH 3/6] formatting changes --- tests/test_regex_identifier.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index 45e40c4..a16bedb 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -804,5 +804,9 @@ def test_new_relic_user_api_key(): def test_pypi_upload_token(): - res = r.check(["pypi-AgEIcHlwaS5vcmcCJDZlNzEyNGJmLWQ4N2UtNGZhYS1iNWEzLWQzYzg2YjU3NzAxYgACJXsicGVybWlzc2lvbnMiOiAidXNlciIsICJ2ZXJzaW9uIjogMX0AAAYgeYcgrZO31PTS_3ipsd0fTSMy1kVkxCzhQvHN6m97yIE"]) + res = r.check( + [ + "pypi-AgEIcHlwaS5vcmcCJDZlNzEyNGJmLWQ4N2UtNGZhYS1iNWEzLWQzYzg2YjU3NzAxYgACJXsicGVybWlzc2lvbnMiOiAidXNlciIsICJ2ZXJzaW9uIjogMX0AAAYgeYcgrZO31PTS_3ipsd0fTSMy1kVkxCzhQvHN6m97yIE" + ] + ) _assert_match_first_item("PyPi Upload Token", res) From b9eb210e049844a704aa11de158d47fd2746fdc9 Mon Sep 17 00:00:00 2001 From: David Clarance Date: Mon, 4 Oct 2021 20:09:02 +0530 Subject: [PATCH 4/6] correct spacing --- tests/test_regex_identifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index a16bedb..6feb796 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -801,8 +801,8 @@ def test_new_relic_synthetics_api_key(): def test_new_relic_user_api_key(): res = r.check(["NRAK-WI4JTVS049IF5A3FGS5N51XS3Y5"]) _assert_match_first_item("New Relic User API Key", res) - - + + def test_pypi_upload_token(): res = r.check( [ From 30f8970b781144b44d2f9161dcdd0065f21c91bd Mon Sep 17 00:00:00 2001 From: David Clarance Date: Mon, 4 Oct 2021 21:29:06 +0530 Subject: [PATCH 5/6] Black formatting for new and old code --- tests/test_regex_identifier.py | 53 +++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index 3d89803..3d95bb6 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -117,10 +117,14 @@ def test_lat_long6(): def test_ip(): res = r.check( - ["http://10.1.1.1/just/a/test"], boundaryless=Filter({"Tags": ["Identifiers"]}) + ["http://10.1.1.1/just/a/test"], + boundaryless=Filter({"Tags": ["Identifiers"]}), ) _assert_match_first_item("Uniform Resource Locator (URL)", res) - assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"] + assert ( + "Internet Protocol (IP) Address Version 4" + in res[1]["Regex Pattern"]["Name"] + ) def test_ip_not_url(): @@ -337,7 +341,9 @@ def test_maestro_card_spaces(): _assert_match_first_item("Maestro Card Number", res) -@pytest.mark.skip("Key:Value Pair is not ran by default because of low rarity.") +@pytest.mark.skip( + "Key:Value Pair is not ran by default because of low rarity." +) def test_username(): res = r.check(["james:S3cr37_P@$$W0rd"]) _assert_match_first_item("Key:Value Pair", res) @@ -355,7 +361,8 @@ def test_email2(): def test_email3(): res = r.check( - ["john.smith@[123.123.123.123]"], boundaryless=Filter({"Tags": ["Identifiers"]}) + ["john.smith@[123.123.123.123]"], + boundaryless=Filter({"Tags": ["Identifiers"]}), ) assert "Email Address" in res[2]["Regex Pattern"]["Name"] @@ -479,7 +486,9 @@ def test_jwt(): def test_s3(): res = r.check(["http://s3.amazonaws.com/bucket/"]) - _assert_match_first_item("Amazon Web Services Simple Storage (AWS S3) URL", res) + _assert_match_first_item( + "Amazon Web Services Simple Storage (AWS S3) URL", res + ) def test_s3_internal(): @@ -502,12 +511,16 @@ def test_arn(): def test_arn2(): - res = r.check(["arn:partition:service:region:account-id:resourcetype/resource"]) + res = r.check( + ["arn:partition:service:region:account-id:resourcetype/resource"] + ) _assert_match_first_item("Amazon Resource Name (ARN)", res) def test_arn3(): - res = r.check(["arn:partition:service:region:account-id:resourcetype:resource"]) + res = r.check( + ["arn:partition:service:region:account-id:resourcetype:resource"] + ) _assert_match_first_item("Amazon Resource Name (ARN)", res) @@ -600,7 +613,9 @@ def test_aws_org_id(): def test_asin(): res = r.check(["B07ND5BB8V"]) - _assert_match_first_item("Amazon Standard Identification Number (ASIN)", res) + _assert_match_first_item( + "Amazon Standard Identification Number (ASIN)", res + ) def test_google_api_key(): @@ -649,7 +664,9 @@ def test_square_application_secret(): def test_square_access_token(): - res = r.check(["EAAAEBQZoq15Ub0PBBr_kw0zK-uIHcBPBZcfjPFT05ODfjng9GqFK9Dbgtj1ILcU"]) + res = r.check( + ["EAAAEBQZoq15Ub0PBBr_kw0zK-uIHcBPBZcfjPFT05ODfjng9GqFK9Dbgtj1ILcU"] + ) _assert_match_first_item("Square Access Token", res) @@ -665,7 +682,9 @@ def test_github_access_token(): def test_slack_api_key(): res = r.check( - ["xoxp-514654431830-843187921057-792480346180-d44d2r9b71f954o8z2k5llt41ovpip6v"] + [ + "xoxp-514654431830-843187921057-792480346180-d44d2r9b71f954o8z2k5llt41ovpip6v" + ] ) _assert_match_first_item("Slack API Key", res) _assert_match_exploit_first_item( @@ -702,17 +721,23 @@ def test_pgp_private_key(): def test_discord_token(): - res = r.check(["NzQ4MDk3ODM3OTgzODU4NzIz.X0YeZw.UlcjuCywUAWvPH9s-3cXNBaq3M4"]) + res = r.check( + ["NzQ4MDk3ODM3OTgzODU4NzIz.X0YeZw.UlcjuCywUAWvPH9s-3cXNBaq3M4"] + ) _assert_match_first_item("Discord Bot Token", res) def test_discord_token_2(): - res = r.check(["MTE4NDQyNjQ0NTAxMjk5MjAz.DPM2DQ.vLNMR02Qxb9DJFucGZK1UtTs__s"]) + res = r.check( + ["MTE4NDQyNjQ0NTAxMjk5MjAz.DPM2DQ.vLNMR02Qxb9DJFucGZK1UtTs__s"] + ) _assert_match_first_item("Discord Bot Token", res) def test_discord_token_3(): - res = r.check(["ODYyOTUyOTE3NTg4NjM5NzY1.YOf1iA.7lARgFXmodxpgmPvOXapaKUga6M"]) + res = r.check( + ["ODYyOTUyOTE3NTg4NjM5NzY1.YOf1iA.7lARgFXmodxpgmPvOXapaKUga6M"] + ) _assert_match_first_item("Discord Bot Token", res) @@ -802,6 +827,7 @@ def test_new_relic_user_api_key(): res = r.check(["NRAK-WI4JTVS049IF5A3FGS5N51XS3Y5"]) _assert_match_first_item("New Relic User API Key", res) + def test_pypi_upload_token(): res = r.check( [ @@ -810,6 +836,7 @@ def test_pypi_upload_token(): ) _assert_match_first_item("PyPi Upload Token", res) + def test_turkish_car_plate(): res = r.check(["34A2344"]) _assert_match_first_item("Turkish License Plate Number", res) From e266bc849fc0ef3ef8a8d323d1cea0b8b8735a3f Mon Sep 17 00:00:00 2001 From: David Clarance Date: Tue, 5 Oct 2021 11:44:30 +0530 Subject: [PATCH 6/6] Formatting changes after ensuring black version is correct --- tests/test_regex_identifier.py | 45 +++++++++------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/tests/test_regex_identifier.py b/tests/test_regex_identifier.py index 3d95bb6..80b2e9e 100644 --- a/tests/test_regex_identifier.py +++ b/tests/test_regex_identifier.py @@ -121,10 +121,7 @@ def test_ip(): boundaryless=Filter({"Tags": ["Identifiers"]}), ) _assert_match_first_item("Uniform Resource Locator (URL)", res) - assert ( - "Internet Protocol (IP) Address Version 4" - in res[1]["Regex Pattern"]["Name"] - ) + assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"] def test_ip_not_url(): @@ -341,9 +338,7 @@ def test_maestro_card_spaces(): _assert_match_first_item("Maestro Card Number", res) -@pytest.mark.skip( - "Key:Value Pair is not ran by default because of low rarity." -) +@pytest.mark.skip("Key:Value Pair is not ran by default because of low rarity.") def test_username(): res = r.check(["james:S3cr37_P@$$W0rd"]) _assert_match_first_item("Key:Value Pair", res) @@ -486,9 +481,7 @@ def test_jwt(): def test_s3(): res = r.check(["http://s3.amazonaws.com/bucket/"]) - _assert_match_first_item( - "Amazon Web Services Simple Storage (AWS S3) URL", res - ) + _assert_match_first_item("Amazon Web Services Simple Storage (AWS S3) URL", res) def test_s3_internal(): @@ -511,16 +504,12 @@ def test_arn(): def test_arn2(): - res = r.check( - ["arn:partition:service:region:account-id:resourcetype/resource"] - ) + res = r.check(["arn:partition:service:region:account-id:resourcetype/resource"]) _assert_match_first_item("Amazon Resource Name (ARN)", res) def test_arn3(): - res = r.check( - ["arn:partition:service:region:account-id:resourcetype:resource"] - ) + res = r.check(["arn:partition:service:region:account-id:resourcetype:resource"]) _assert_match_first_item("Amazon Resource Name (ARN)", res) @@ -613,9 +602,7 @@ def test_aws_org_id(): def test_asin(): res = r.check(["B07ND5BB8V"]) - _assert_match_first_item( - "Amazon Standard Identification Number (ASIN)", res - ) + _assert_match_first_item("Amazon Standard Identification Number (ASIN)", res) def test_google_api_key(): @@ -664,9 +651,7 @@ def test_square_application_secret(): def test_square_access_token(): - res = r.check( - ["EAAAEBQZoq15Ub0PBBr_kw0zK-uIHcBPBZcfjPFT05ODfjng9GqFK9Dbgtj1ILcU"] - ) + res = r.check(["EAAAEBQZoq15Ub0PBBr_kw0zK-uIHcBPBZcfjPFT05ODfjng9GqFK9Dbgtj1ILcU"]) _assert_match_first_item("Square Access Token", res) @@ -682,9 +667,7 @@ def test_github_access_token(): def test_slack_api_key(): res = r.check( - [ - "xoxp-514654431830-843187921057-792480346180-d44d2r9b71f954o8z2k5llt41ovpip6v" - ] + ["xoxp-514654431830-843187921057-792480346180-d44d2r9b71f954o8z2k5llt41ovpip6v"] ) _assert_match_first_item("Slack API Key", res) _assert_match_exploit_first_item( @@ -721,23 +704,17 @@ def test_pgp_private_key(): def test_discord_token(): - res = r.check( - ["NzQ4MDk3ODM3OTgzODU4NzIz.X0YeZw.UlcjuCywUAWvPH9s-3cXNBaq3M4"] - ) + res = r.check(["NzQ4MDk3ODM3OTgzODU4NzIz.X0YeZw.UlcjuCywUAWvPH9s-3cXNBaq3M4"]) _assert_match_first_item("Discord Bot Token", res) def test_discord_token_2(): - res = r.check( - ["MTE4NDQyNjQ0NTAxMjk5MjAz.DPM2DQ.vLNMR02Qxb9DJFucGZK1UtTs__s"] - ) + res = r.check(["MTE4NDQyNjQ0NTAxMjk5MjAz.DPM2DQ.vLNMR02Qxb9DJFucGZK1UtTs__s"]) _assert_match_first_item("Discord Bot Token", res) def test_discord_token_3(): - res = r.check( - ["ODYyOTUyOTE3NTg4NjM5NzY1.YOf1iA.7lARgFXmodxpgmPvOXapaKUga6M"] - ) + res = r.check(["ODYyOTUyOTE3NTg4NjM5NzY1.YOf1iA.7lARgFXmodxpgmPvOXapaKUga6M"]) _assert_match_first_item("Discord Bot Token", res)