Skip to content

Commit

Permalink
Merge pull request #198 from bee-san/bee-set-to-0
Browse files Browse the repository at this point in the history
Set some regex to 0 to prevent spammy reports
  • Loading branch information
bee-san committed Oct 10, 2021
2 parents e36b83a + 8b2a4e7 commit 0765321
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pywhat"
version = "4.3.0"
version = "4.3.1"
description = "What is that thing?"
authors = ["Bee <github@skerritt.blog>"]
license = "MIT"
Expand Down
16 changes: 8 additions & 8 deletions pywhat/Data/regex.json
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@
"Regex": "^([0-9a-fA-F]{24})$",
"plural_name": false,
"Description": null,
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"Identifiers",
Expand All @@ -1776,7 +1776,7 @@
"Regex": "^([0-9]{10})$",
"plural_name": false,
"Description": "Seconds elapsed since unix epoch: 1970, between year 2001 and 2286",
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"UNIX Timestamp",
Expand All @@ -1789,7 +1789,7 @@
"Regex": "^([0-9]{13})$",
"plural_name": false,
"Description": "Milliseconds elapsed since unix epoch: 1970, between year 2001 and 2286",
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"UNIX Timestamp",
Expand All @@ -1802,7 +1802,7 @@
"Regex": "^([0-9]{8,10})$",
"plural_name": false,
"Description": "Seconds elapsed since unix epoch: 1970",
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"UNIX Timestamp",
Expand All @@ -1815,7 +1815,7 @@
"Regex": "^([0-9]{11,13})$",
"plural_name": false,
"Description": "Milliseconds elapsed since unix epoch: 1970",
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"UNIX Timestamp",
Expand All @@ -1828,7 +1828,7 @@
"Regex": "^([0-9A-HJKMNP-TV-Z]{26})$",
"plural_name": false,
"Description": null,
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"Identifiers",
Expand All @@ -1840,7 +1840,7 @@
"Regex": "^((?=.*[A-Z])(?=.*[a-z])[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]{1})$",
"plural_name": false,
"Description": null,
"Rarity": 0.1,
"Rarity": 0,
"URL": "https://www.youtube.com/watch?v=",
"Tags": [
"Media",
Expand All @@ -1853,7 +1853,7 @@
"Regex": "^([0-9]{10})$",
"plural_name": false,
"Description": null,
"Rarity": 0.1,
"Rarity": 0,
"URL": null,
"Tags": [
"Credentials",
Expand Down
2 changes: 1 addition & 1 deletion pywhat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pywhat.helper import AvailableTags, Keys
from pywhat.identifier import Identifier

__version__ = "4.3.0"
__version__ = "4.3.1"

tags = AvailableTags().get_tags()
pywhat_tags = tags # left for backward compatibility purposes
Expand Down
8 changes: 4 additions & 4 deletions tests/test_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def test_pgp_private_key():

def test_file_fixture_turkish_car_plate():
runner = CliRunner()
result = runner.invoke(main, ["fixtures/file"])
result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"])
assert result.exit_code == 0
assert re.findall("Turkish License Plate Number", str(result.output))

Expand All @@ -594,7 +594,7 @@ def test_file_fixture_turkish_id_number():

def test_file_fixture_turkish_tax_number():
runner = CliRunner()
result = runner.invoke(main, ["fixtures/file"])
result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"])
assert result.exit_code == 0
assert re.findall("Turkish Tax Number", str(result.output))

Expand All @@ -608,14 +608,14 @@ def test_file_fixture_uuid():

def test_file_fixture_objectid():
runner = CliRunner()
result = runner.invoke(main, ["fixtures/file"])
result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"])
assert result.exit_code == 0
assert re.findall("ObjectID", str(result.output))


def test_file_fixture_ulid():
runner = CliRunner()
result = runner.invoke(main, ["fixtures/file"])
result = runner.invoke(main, ["--rarity", "0:", "fixtures/file"])
assert result.exit_code == 0
assert re.findall("ULID", str(result.output))

Expand Down
25 changes: 14 additions & 11 deletions tests/test_regex_identifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import pytest

from pywhat import regex_identifier
from pywhat.filter import Filter
from pywhat.filter import Distribution, Filter
from pywhat.helper import load_regexes

database = load_regexes()
r = regex_identifier.RegexIdentifier()
filter1 = Filter({"MinRarity": 0.0})
d = Distribution(filter1)
r_rarity_0 = regex_identifier.RegexIdentifier()


def _assert_match_first_item(name, res):
Expand Down Expand Up @@ -415,12 +418,12 @@ def test_youtube2():


def test_youtube_id():
res = r.check(["dQw4w9WgXcQ"])
res = r.check(["dQw4w9WgXcQ"], dist=d)
_assert_match_first_item("YouTube Video ID", res)


def test_youtube_id2():
res = r.check(["078-05-1120"])
res = r.check(["078-05-1120"], dist=d)
assert "YouTube Video ID" not in res


Expand Down Expand Up @@ -533,35 +536,35 @@ def test_arn4():


def test_unix_timestamp():
res = r.check(["1577836800"]) # 2020-01-01
res = r.check(["1577836800"], dist=d) # 2020-01-01
keys = [m["Regex Pattern"]["Name"] for m in res]
assert "Unix Timestamp" in keys
assert "Recent Unix Timestamp" in keys


def test_unix_timestamp2():
res = r.check(["94694400"]) # 1973-01-01
res = r.check(["94694400"], dist=d) # 1973-01-01
keys = [m["Regex Pattern"]["Name"] for m in res]
assert "Unix Timestamp" in keys
assert "Recent Unix Timestamp" not in keys


def test_unix_timestamp3():
res = r.check(["1234567"]) # 7 numbers
res = r.check(["1234567"], dist=d) # 7 numbers
keys = [m["Regex Pattern"]["Name"] for m in res]
assert "Unix Timestamp" not in keys
assert "Recent Unix Timestamp" not in keys


def test_unix_timestamp4():
res = r.check(["1577836800000"]) # 2020-01-01
res = r.check(["1577836800000"], dist=d) # 2020-01-01
keys = [m["Regex Pattern"]["Name"] for m in res]
assert "Unix Millisecond Timestamp" in keys
assert "Recent Unix Millisecond Timestamp" in keys


def test_unix_timestamp5():
res = r.check(["94694400000"]) # 1973-01-01
res = r.check(["94694400000"], dist=d) # 1973-01-01
keys = [m["Regex Pattern"]["Name"] for m in res]
assert "Unix Millisecond Timestamp" in keys
assert "Recent Unix Millisecond Timestamp" not in keys
Expand Down Expand Up @@ -1006,7 +1009,7 @@ def test_turkish_id_number2():


def test_turkish_tax_number():
res = r.check(["1234567890"])
res = r.check(["1234567890"], dist=d)
assert "Turkish Tax Number" in str(res)


Expand All @@ -1016,12 +1019,12 @@ def test_uuid():


def test_objectid():
res = r.check(["5fc7c33a7ef88b139122a38a"])
res = r_rarity_0.check(["5fc7c33a7ef88b139122a38a"], dist=d)
assert "ObjectID" in str(res)


def test_ulid():
res = r.check(["01ERJ58HMWDN3VTRRHZQV2T5R5"])
res = r_rarity_0.check(["01ERJ58HMWDN3VTRRHZQV2T5R5"], dist=d)
assert "ULID" in str(res)


Expand Down

0 comments on commit 0765321

Please sign in to comment.