path
stringlengths 9
117
| type
stringclasses 2
values | project
stringclasses 10
values | commit_hash
stringlengths 40
40
| commit_message
stringlengths 1
137
| ground_truth
stringlengths 0
2.74k
| main_code
stringlengths 102
3.37k
| context
stringlengths 0
14.7k
|
---|---|---|---|---|---|---|---|
tests.test_distribution/test_distribution3
|
Modified
|
bee-san~pyWhat
|
c0bce292b254cda3c6fb9c3de18d5293e8b5b3ff
|
Another cleanup
|
<3>:<del> path = "../pywhat/Data/regex.json"
<4>:<del> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<5>:<del> with open(fullpath, "r", encoding="utf-8") as myfile:
<6>:<del> regexes = json.load(myfile)
<7>:<add> regexes = load_regexes()
|
# module: tests.test_distribution
def test_distribution3():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter1) & Distribution(filter2)
<3> path = "../pywhat/Data/regex.json"
<4> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<5> with open(fullpath, "r", encoding="utf-8") as myfile:
<6> regexes = json.load(myfile)
<7> assert dist._dict["MinRarity"] == 0.4
<8> assert dist._dict["MaxRarity"] == 0.8
<9> assert dist._dict["Tags"] == {"Networking"}
<10> assert dist._dict["ExcludeTags"] == set()
<11>
<12> for regex in regexes:
<13> if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
<14> assert regex in dist.get_regexes()
<15>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
at: tests.test_distribution.test_distribution3
dist = Distribution(filter1) & Distribution(filter2)
regexes = load_regexes()
===========changed ref 0===========
# module: pywhat.helper
+ def load_regexes() -> list:
+ path = "Data/regex.json"
+ fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
+ with open(fullpath, "r", encoding="utf-8") as myfile:
+ return json.load(myfile)
+
===========changed ref 1===========
# module: tests.test_distribution
def test_distribution():
dist = Distribution()
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert regexes == dist.get_regexes()
===========changed ref 2===========
# module: tests.test_distribution
def test_distribution2():
filter = {
"MinRarity": 0.3,
"MaxRarity": 0.8,
"Tags": ["Networking"],
"ExcludeTags": ["Identifiers"],
}
dist = Distribution(filter)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
if (
0.3 <= regex["Rarity"] <= 0.8
and "Networking" in regex["Tags"]
and "Identifiers" not in regex["Tags"]
):
assert regex in dist.get_regexes()
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_regex_successfully_parses():
r = regex_identifier.RegexIdentifier()
- print(r.distribution.get_regexes)
assert "Name" in r.distribution.get_regexes()[0]
===========changed ref 4===========
# module: pywhat.distribution
class Distribution:
-
- def _load_regexes(self):
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- self._regexes = json.load(myfile)
- self._filter()
-
===========changed ref 5===========
# module: pywhat.helper
class AvailableTags():
def __init__(self):
self.tags = set()
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
self.tags.update(regex["Tags"])
===========changed ref 6===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
+ self._regexes = load_regexes()
- self._load_regexes()
+ self._filter()
|
tests.test_distribution/test_distribution4
|
Modified
|
bee-san~pyWhat
|
c0bce292b254cda3c6fb9c3de18d5293e8b5b3ff
|
Another cleanup
|
<4>:<del> path = "../pywhat/Data/regex.json"
<5>:<del> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<6>:<del> with open(fullpath, "r", encoding="utf-8") as myfile:
<7>:<del> regexes = json.load(myfile)
<8>:<add> regexes = load_regexes()
|
# module: tests.test_distribution
def test_distribution4():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter2)
<3> dist &= Distribution(filter1)
<4> path = "../pywhat/Data/regex.json"
<5> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<6> with open(fullpath, "r", encoding="utf-8") as myfile:
<7> regexes = json.load(myfile)
<8> assert dist._dict["MinRarity"] == 0.4
<9> assert dist._dict["MaxRarity"] == 0.8
<10> assert dist._dict["Tags"] == {"Networking"}
<11> assert dist._dict["ExcludeTags"] == set()
<12>
<13> for regex in regexes:
<14> if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
<15> assert regex in dist.get_regexes()
<16>
|
===========unchanged ref 0===========
at: pywhat
pywhat_tags = AvailableTags().get_tags()
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
at: tests.test_distribution.test_distribution4
dist = Distribution(filter2)
dist &= Distribution(filter1)
regexes = load_regexes()
===========changed ref 0===========
# module: pywhat.helper
+ def load_regexes() -> list:
+ path = "Data/regex.json"
+ fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
+ with open(fullpath, "r", encoding="utf-8") as myfile:
+ return json.load(myfile)
+
===========changed ref 1===========
# module: tests.test_distribution
def test_distribution():
dist = Distribution()
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert regexes == dist.get_regexes()
===========changed ref 2===========
# module: tests.test_distribution
def test_distribution2():
filter = {
"MinRarity": 0.3,
"MaxRarity": 0.8,
"Tags": ["Networking"],
"ExcludeTags": ["Identifiers"],
}
dist = Distribution(filter)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
if (
0.3 <= regex["Rarity"] <= 0.8
and "Networking" in regex["Tags"]
and "Identifiers" not in regex["Tags"]
):
assert regex in dist.get_regexes()
===========changed ref 3===========
# module: tests.test_distribution
def test_distribution3():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) & Distribution(filter2)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
assert dist._dict["Tags"] == {"Networking"}
assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_regex_successfully_parses():
r = regex_identifier.RegexIdentifier()
- print(r.distribution.get_regexes)
assert "Name" in r.distribution.get_regexes()[0]
===========changed ref 5===========
# module: pywhat.distribution
class Distribution:
-
- def _load_regexes(self):
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- self._regexes = json.load(myfile)
- self._filter()
-
===========changed ref 6===========
# module: pywhat.helper
class AvailableTags():
def __init__(self):
self.tags = set()
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
self.tags.update(regex["Tags"])
===========changed ref 7===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
+ self._regexes = load_regexes()
- self._load_regexes()
+ self._filter()
|
tests.test_distribution/test_distribution5
|
Modified
|
bee-san~pyWhat
|
c0bce292b254cda3c6fb9c3de18d5293e8b5b3ff
|
Another cleanup
|
<3>:<del> path = "../pywhat/Data/regex.json"
<4>:<del> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<5>:<del> with open(fullpath, "r", encoding="utf-8") as myfile:
<6>:<del> regexes = json.load(myfile)
<7>:<add> regexes = load_regexes()
|
# module: tests.test_distribution
def test_distribution5():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter1) | Distribution(filter2)
<3> path = "../pywhat/Data/regex.json"
<4> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<5> with open(fullpath, "r", encoding="utf-8") as myfile:
<6> regexes = json.load(myfile)
<7> assert dist._dict["MinRarity"] == 0.3
<8> assert dist._dict["MaxRarity"] == 1
<9> assert dist._dict["Tags"] == pywhat_tags
<10> assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
<11>
<12> for regex in regexes:
<13> if (
<14> 0.3 <= regex["Rarity"] <= 1
<15> and "Identifiers" not in regex["Tags"]
<16> and "Media" not in regex["Tags"]
<17> ):
<18> assert regex in dist.get_regexes()
<19>
|
===========unchanged ref 0===========
at: pywhat
pywhat_tags = AvailableTags().get_tags()
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
at: tests.test_distribution.test_distribution5
dist = Distribution(filter1) | Distribution(filter2)
===========changed ref 0===========
# module: pywhat.helper
+ def load_regexes() -> list:
+ path = "Data/regex.json"
+ fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
+ with open(fullpath, "r", encoding="utf-8") as myfile:
+ return json.load(myfile)
+
===========changed ref 1===========
# module: tests.test_distribution
def test_distribution():
dist = Distribution()
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert regexes == dist.get_regexes()
===========changed ref 2===========
# module: tests.test_distribution
def test_distribution2():
filter = {
"MinRarity": 0.3,
"MaxRarity": 0.8,
"Tags": ["Networking"],
"ExcludeTags": ["Identifiers"],
}
dist = Distribution(filter)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
if (
0.3 <= regex["Rarity"] <= 0.8
and "Networking" in regex["Tags"]
and "Identifiers" not in regex["Tags"]
):
assert regex in dist.get_regexes()
===========changed ref 3===========
# module: tests.test_distribution
def test_distribution4():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter2)
dist &= Distribution(filter1)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
assert dist._dict["Tags"] == {"Networking"}
assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 4===========
# module: tests.test_distribution
def test_distribution3():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) & Distribution(filter2)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
assert dist._dict["Tags"] == {"Networking"}
assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_regex_successfully_parses():
r = regex_identifier.RegexIdentifier()
- print(r.distribution.get_regexes)
assert "Name" in r.distribution.get_regexes()[0]
===========changed ref 6===========
# module: pywhat.distribution
class Distribution:
-
- def _load_regexes(self):
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- self._regexes = json.load(myfile)
- self._filter()
-
===========changed ref 7===========
# module: pywhat.helper
class AvailableTags():
def __init__(self):
self.tags = set()
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
self.tags.update(regex["Tags"])
===========changed ref 8===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
+ self._regexes = load_regexes()
- self._load_regexes()
+ self._filter()
|
tests.test_distribution/test_distribution6
|
Modified
|
bee-san~pyWhat
|
c0bce292b254cda3c6fb9c3de18d5293e8b5b3ff
|
Another cleanup
|
<4>:<del> path = "../pywhat/Data/regex.json"
<5>:<del> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<6>:<del> with open(fullpath, "r", encoding="utf-8") as myfile:
<7>:<del> regexes = json.load(myfile)
<8>:<add> regexes = load_regexes()
|
# module: tests.test_distribution
def test_distribution6():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter2)
<3> dist |= Distribution(filter1)
<4> path = "../pywhat/Data/regex.json"
<5> fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
<6> with open(fullpath, "r", encoding="utf-8") as myfile:
<7> regexes = json.load(myfile)
<8> assert dist._dict["MinRarity"] == 0.3
<9> assert dist._dict["MaxRarity"] == 1
<10> assert dist._dict["Tags"] == pywhat_tags
<11> assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
<12>
<13> for regex in regexes:
<14> if (
<15> 0.3 <= regex["Rarity"] <= 1
<16> and "Identifiers" not in regex["Tags"]
<17> and "Media" not in regex["Tags"]
<18> ):
<19> assert regex in dist.get_regexes()
<20>
|
===========unchanged ref 0===========
at: _pytest.python_api
raises(expected_exception: Union[Type[E], Tuple[Type[E], ...]], func: Callable[..., Any], *args: Any, **kwargs: Any) -> _pytest._code.ExceptionInfo[E]
raises(expected_exception: Union[Type[E], Tuple[Type[E], ...]], *, match: Optional[Union[str, Pattern[str]]]=...) -> "RaisesContext[E]"
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.helper
InvalidTag(*args: object)
at: tests.test_distribution.test_distribution6
dist = Distribution(filter2)
dist |= Distribution(filter1)
===========changed ref 0===========
# module: tests.test_distribution
def test_distribution():
dist = Distribution()
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert regexes == dist.get_regexes()
===========changed ref 1===========
# module: tests.test_distribution
def test_distribution2():
filter = {
"MinRarity": 0.3,
"MaxRarity": 0.8,
"Tags": ["Networking"],
"ExcludeTags": ["Identifiers"],
}
dist = Distribution(filter)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
if (
0.3 <= regex["Rarity"] <= 0.8
and "Networking" in regex["Tags"]
and "Identifiers" not in regex["Tags"]
):
assert regex in dist.get_regexes()
===========changed ref 2===========
# module: tests.test_distribution
def test_distribution5():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) | Distribution(filter2)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.3
assert dist._dict["MaxRarity"] == 1
assert dist._dict["Tags"] == pywhat_tags
assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
for regex in regexes:
if (
0.3 <= regex["Rarity"] <= 1
and "Identifiers" not in regex["Tags"]
and "Media" not in regex["Tags"]
):
assert regex in dist.get_regexes()
===========changed ref 3===========
# module: tests.test_distribution
def test_distribution4():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter2)
dist &= Distribution(filter1)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
assert dist._dict["Tags"] == {"Networking"}
assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 4===========
# module: tests.test_distribution
def test_distribution3():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) & Distribution(filter2)
- path = "../pywhat/Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
assert dist._dict["Tags"] == {"Networking"}
assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_regex_successfully_parses():
r = regex_identifier.RegexIdentifier()
- print(r.distribution.get_regexes)
assert "Name" in r.distribution.get_regexes()[0]
===========changed ref 6===========
# module: pywhat.helper
+ def load_regexes() -> list:
+ path = "Data/regex.json"
+ fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
+ with open(fullpath, "r", encoding="utf-8") as myfile:
+ return json.load(myfile)
+
===========changed ref 7===========
# module: pywhat.distribution
class Distribution:
-
- def _load_regexes(self):
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- self._regexes = json.load(myfile)
- self._filter()
-
===========changed ref 8===========
# module: pywhat.helper
class AvailableTags():
def __init__(self):
self.tags = set()
- path = "Data/regex.json"
- fullpath = os.path.join(os.path.dirname(os.path.abspath(__file__)), path)
- with open(fullpath, "r", encoding="utf-8") as myfile:
- regexes = json.load(myfile)
+ regexes = load_regexes()
for regex in regexes:
self.tags.update(regex["Tags"])
|
pywhat.what/parse_options
|
Modified
|
bee-san~pyWhat
|
5fc4e97ad3527e7d41c4a4c642f9d2fc297b019b
|
Fix CLI
|
<25>:<add>
<add> return distribution
|
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
<0> filter = dict()
<1> if rarity is not None:
<2> rarities = rarity.split(":")
<3> if len(rarities) != 2:
<4> print("Invalid rarity range format ('min:max' expected)")
<5> sys.exit(1)
<6> try:
<7> if not rarities[0].isspace() and rarities[0]:
<8> filter["MinRarity"] = float(rarities[0])
<9> if not rarities[1].isspace() and rarities[1]:
<10> filter["MaxRarity"] = float(rarities[1])
<11> except ValueError:
<12> print("Invalid rarity argument (float expected)")
<13> sys.exit(1)
<14> if include_tags is not None:
<15> filter["Tags"] = list(map(str.strip, include_tags.split(',')))
<16> if exclude_tags is not None:
<17> filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
<18>
<19> try:
<20> distribution = Distribution(filter)
<21> except InvalidTag:
<22> print("Passed tags are not valid.\n" \
<23> "You can check available tags by using: 'pywhat --tags'")
<24> sys.exit(1)
<25>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.helper
InvalidTag(*args: object)
at: sys
exit(status: object=..., /) -> NoReturn
|
tests.test_click/test_filtration
|
Modified
|
bee-san~pyWhat
|
5fc4e97ad3527e7d41c4a4c642f9d2fc297b019b
|
Fix CLI
|
<3>:<add> assert "THM{" not in result.output
<del> assert "THM{" in result.output
<4>:<add> assert "ETH" not in result.output
<del> assert "ETH" in result.output
<5>:<add> assert "Email Address" in result.output
<add> assert "IP" in result.output
<add> assert "URL" in result.output
|
# module: tests.test_click
def test_filtration():
<0> runner = CliRunner()
<1> result = runner.invoke(main, ["--rarity", "0.5:", "--include_tags", "Identifiers,Media", "fixtures/file"])
<2> assert result.exit_code == 0
<3> assert "THM{" in result.output
<4> assert "ETH" in result.output
<5>
|
===========unchanged ref 0===========
at: click.testing
CliRunner(charset: Optional[Text]=..., env: Optional[Mapping[str, str]]=..., echo_stdin: bool=..., mix_stderr: bool=...)
at: click.testing.CliRunner
invoke(cli: BaseCommand, args: Optional[Union[str, Iterable[str]]]=..., input: Optional[Union[bytes, Text, IO[Any]]]=..., env: Optional[Mapping[str, str]]=..., catch_exceptions: bool=..., color: bool=..., **extra: Any) -> Result
at: click.testing.Result.__init__
self.exit_code = exit_code
at: pywhat.what
main(text_input, rarity, include_tags, exclude_tags)
===========changed ref 0===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
try:
distribution = Distribution(filter)
except InvalidTag:
print("Passed tags are not valid.\n" \
"You can check available tags by using: 'pywhat --tags'")
sys.exit(1)
+
+ return distribution
|
pywhat.distribution/Distribution.__init__
|
Modified
|
bee-san~pyWhat
|
69053078dc6c7f0bc95dadddf644e2a6680efec9
|
Make tags case insensitive
|
<0>:<add> tags = CaseInsensitiveSet(AvailableTags().get_tags())
<del> tags = AvailableTags().get_tags()
<5>:<add> self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
<del> self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
<6>:<add> self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
<del> self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
<9>:<del>
|
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
<0> tags = AvailableTags().get_tags()
<1> self._dict = dict()
<2> if filters_dict is None:
<3> filters_dict = dict()
<4>
<5> self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
<6> self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
<7> self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
<8> self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
<9>
<10> if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
<11> raise InvalidTag("Passed filter contains tags that are not used by 'what'")
<12>
<13> self._regexes = load_regexes()
<14> self._filter()
<15>
|
===========unchanged ref 0===========
at: pywhat.distribution.Distribution
_filter()
at: pywhat.distribution.Distribution._filter
self._regexes = temp_regexes
at: pywhat.helper
AvailableTags()
InvalidTag(*args: object)
load_regexes() -> list
CaseInsensitiveSet(iterable=None)
at: pywhat.helper.AvailableTags
get_tags()
===========changed ref 0===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __len__(self):
+ return len(self._elements)
+
===========changed ref 1===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __iter__(self):
+ return iter(self._elements)
+
===========changed ref 2===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __repr__(self):
+ return self._elements.__repr__()
+
===========changed ref 3===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __contains__(self, value):
+ return self._lower(value) in self._elements
+
===========changed ref 4===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def _lower(self, value):
+ return value.lower() if isinstance(value, str) else value
+
===========changed ref 5===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def issubset(self, other):
+ for value in self:
+ if value not in other:
+ return False
+ return True
+
===========changed ref 6===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __init__(self, iterable=None):
+ self._elements = set()
+ if iterable is not None:
+ self._elements = set(map(self._lower, iterable))
+
|
tests.test_distribution/test_distribution3
|
Modified
|
bee-san~pyWhat
|
69053078dc6c7f0bc95dadddf644e2a6680efec9
|
Make tags case insensitive
|
<6>:<add> assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
<del> assert dist._dict["Tags"] == {"Networking"}
<7>:<add> assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
<del> assert dist._dict["ExcludeTags"] == set()
|
# module: tests.test_distribution
def test_distribution3():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter1) & Distribution(filter2)
<3> regexes = load_regexes()
<4> assert dist._dict["MinRarity"] == 0.4
<5> assert dist._dict["MaxRarity"] == 0.8
<6> assert dist._dict["Tags"] == {"Networking"}
<7> assert dist._dict["ExcludeTags"] == set()
<8>
<9> for regex in regexes:
<10> if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
<11> assert regex in dist.get_regexes()
<12>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
CaseInsensitiveSet(iterable=None)
===========changed ref 0===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __len__(self):
+ return len(self._elements)
+
===========changed ref 1===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __iter__(self):
+ return iter(self._elements)
+
===========changed ref 2===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __repr__(self):
+ return self._elements.__repr__()
+
===========changed ref 3===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __contains__(self, value):
+ return self._lower(value) in self._elements
+
===========changed ref 4===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def _lower(self, value):
+ return value.lower() if isinstance(value, str) else value
+
===========changed ref 5===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def issubset(self, other):
+ for value in self:
+ if value not in other:
+ return False
+ return True
+
===========changed ref 6===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __init__(self, iterable=None):
+ self._elements = set()
+ if iterable is not None:
+ self._elements = set(map(self._lower, iterable))
+
===========changed ref 7===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
+ tags = CaseInsensitiveSet(AvailableTags().get_tags())
- tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
+ self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
- self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
- self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
-
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
|
tests.test_distribution/test_distribution4
|
Modified
|
bee-san~pyWhat
|
69053078dc6c7f0bc95dadddf644e2a6680efec9
|
Make tags case insensitive
|
<7>:<add> assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
<del> assert dist._dict["Tags"] == {"Networking"}
<8>:<add> assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
<del> assert dist._dict["ExcludeTags"] == set()
|
# module: tests.test_distribution
def test_distribution4():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter2)
<3> dist &= Distribution(filter1)
<4> regexes = load_regexes()
<5> assert dist._dict["MinRarity"] == 0.4
<6> assert dist._dict["MaxRarity"] == 0.8
<7> assert dist._dict["Tags"] == {"Networking"}
<8> assert dist._dict["ExcludeTags"] == set()
<9>
<10> for regex in regexes:
<11> if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
<12> assert regex in dist.get_regexes()
<13>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
CaseInsensitiveSet(iterable=None)
===========changed ref 0===========
# module: tests.test_distribution
def test_distribution3():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) & Distribution(filter2)
regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
+ assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
- assert dist._dict["Tags"] == {"Networking"}
+ assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
- assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 1===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __len__(self):
+ return len(self._elements)
+
===========changed ref 2===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __iter__(self):
+ return iter(self._elements)
+
===========changed ref 3===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __repr__(self):
+ return self._elements.__repr__()
+
===========changed ref 4===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __contains__(self, value):
+ return self._lower(value) in self._elements
+
===========changed ref 5===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def _lower(self, value):
+ return value.lower() if isinstance(value, str) else value
+
===========changed ref 6===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def issubset(self, other):
+ for value in self:
+ if value not in other:
+ return False
+ return True
+
===========changed ref 7===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __init__(self, iterable=None):
+ self._elements = set()
+ if iterable is not None:
+ self._elements = set(map(self._lower, iterable))
+
===========changed ref 8===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
+ tags = CaseInsensitiveSet(AvailableTags().get_tags())
- tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
+ self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
- self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
- self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
-
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
|
tests.test_distribution/test_distribution5
|
Modified
|
bee-san~pyWhat
|
69053078dc6c7f0bc95dadddf644e2a6680efec9
|
Make tags case insensitive
|
<6>:<add> assert dist._dict["Tags"] == CaseInsensitiveSet(pywhat_tags)
<del> assert dist._dict["Tags"] == pywhat_tags
<7>:<add> assert dist._dict["ExcludeTags"] == CaseInsensitiveSet(["Identifiers", "Media"])
<del> assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
|
# module: tests.test_distribution
def test_distribution5():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter1) | Distribution(filter2)
<3> regexes = load_regexes()
<4> assert dist._dict["MinRarity"] == 0.3
<5> assert dist._dict["MaxRarity"] == 1
<6> assert dist._dict["Tags"] == pywhat_tags
<7> assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
<8>
<9> for regex in regexes:
<10> if (
<11> 0.3 <= regex["Rarity"] <= 1
<12> and "Identifiers" not in regex["Tags"]
<13> and "Media" not in regex["Tags"]
<14> ):
<15> assert regex in dist.get_regexes()
<16>
|
===========unchanged ref 0===========
at: pywhat
pywhat_tags = AvailableTags().get_tags()
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
CaseInsensitiveSet(iterable=None)
===========changed ref 0===========
# module: tests.test_distribution
def test_distribution4():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter2)
dist &= Distribution(filter1)
regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
+ assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
- assert dist._dict["Tags"] == {"Networking"}
+ assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
- assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 1===========
# module: tests.test_distribution
def test_distribution3():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) & Distribution(filter2)
regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
+ assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
- assert dist._dict["Tags"] == {"Networking"}
+ assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
- assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 2===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __len__(self):
+ return len(self._elements)
+
===========changed ref 3===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __iter__(self):
+ return iter(self._elements)
+
===========changed ref 4===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __repr__(self):
+ return self._elements.__repr__()
+
===========changed ref 5===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __contains__(self, value):
+ return self._lower(value) in self._elements
+
===========changed ref 6===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def _lower(self, value):
+ return value.lower() if isinstance(value, str) else value
+
===========changed ref 7===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def issubset(self, other):
+ for value in self:
+ if value not in other:
+ return False
+ return True
+
===========changed ref 8===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __init__(self, iterable=None):
+ self._elements = set()
+ if iterable is not None:
+ self._elements = set(map(self._lower, iterable))
+
===========changed ref 9===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
+ tags = CaseInsensitiveSet(AvailableTags().get_tags())
- tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
+ self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
- self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
- self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
-
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
|
tests.test_distribution/test_distribution6
|
Modified
|
bee-san~pyWhat
|
69053078dc6c7f0bc95dadddf644e2a6680efec9
|
Make tags case insensitive
|
<7>:<add> assert dist._dict["Tags"] == CaseInsensitiveSet(pywhat_tags)
<del> assert dist._dict["Tags"] == pywhat_tags
<8>:<add> assert dist._dict["ExcludeTags"] == CaseInsensitiveSet(["Identifiers", "Media"])
<del> assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
|
# module: tests.test_distribution
def test_distribution6():
<0> filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
<1> filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
<2> dist = Distribution(filter2)
<3> dist |= Distribution(filter1)
<4> regexes = load_regexes()
<5> assert dist._dict["MinRarity"] == 0.3
<6> assert dist._dict["MaxRarity"] == 1
<7> assert dist._dict["Tags"] == pywhat_tags
<8> assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
<9>
<10> for regex in regexes:
<11> if (
<12> 0.3 <= regex["Rarity"] <= 1
<13> and "Identifiers" not in regex["Tags"]
<14> and "Media" not in regex["Tags"]
<15> ):
<16> assert regex in dist.get_regexes()
<17>
|
===========unchanged ref 0===========
at: pywhat
pywhat_tags = AvailableTags().get_tags()
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.distribution.Distribution.__init__
self._dict = dict()
at: pywhat.helper
load_regexes() -> list
CaseInsensitiveSet(iterable=None)
===========changed ref 0===========
# module: tests.test_distribution
def test_distribution4():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter2)
dist &= Distribution(filter1)
regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
+ assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
- assert dist._dict["Tags"] == {"Networking"}
+ assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
- assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 1===========
# module: tests.test_distribution
def test_distribution5():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) | Distribution(filter2)
regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.3
assert dist._dict["MaxRarity"] == 1
+ assert dist._dict["Tags"] == CaseInsensitiveSet(pywhat_tags)
- assert dist._dict["Tags"] == pywhat_tags
+ assert dist._dict["ExcludeTags"] == CaseInsensitiveSet(["Identifiers", "Media"])
- assert dist._dict["ExcludeTags"] == {"Identifiers", "Media"}
for regex in regexes:
if (
0.3 <= regex["Rarity"] <= 1
and "Identifiers" not in regex["Tags"]
and "Media" not in regex["Tags"]
):
assert regex in dist.get_regexes()
===========changed ref 2===========
# module: tests.test_distribution
def test_distribution3():
filter1 = {"MinRarity": 0.3, "Tags": ["Networking"], "ExcludeTags": ["Identifiers"]}
filter2 = {"MinRarity": 0.4, "MaxRarity": 0.8, "ExcludeTags": ["Media"]}
dist = Distribution(filter1) & Distribution(filter2)
regexes = load_regexes()
assert dist._dict["MinRarity"] == 0.4
assert dist._dict["MaxRarity"] == 0.8
+ assert dist._dict["Tags"] == CaseInsensitiveSet(["Networking"])
- assert dist._dict["Tags"] == {"Networking"}
+ assert dist._dict["ExcludeTags"] == CaseInsensitiveSet()
- assert dist._dict["ExcludeTags"] == set()
for regex in regexes:
if 0.4 <= regex["Rarity"] <= 0.8 and "Networking" in regex["Tags"]:
assert regex in dist.get_regexes()
===========changed ref 3===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __len__(self):
+ return len(self._elements)
+
===========changed ref 4===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __iter__(self):
+ return iter(self._elements)
+
===========changed ref 5===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __repr__(self):
+ return self._elements.__repr__()
+
===========changed ref 6===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __contains__(self, value):
+ return self._lower(value) in self._elements
+
===========changed ref 7===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def _lower(self, value):
+ return value.lower() if isinstance(value, str) else value
+
===========changed ref 8===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def issubset(self, other):
+ for value in self:
+ if value not in other:
+ return False
+ return True
+
===========changed ref 9===========
# module: pywhat.helper
+ class CaseInsensitiveSet(collections.abc.Set):
+ def __init__(self, iterable=None):
+ self._elements = set()
+ if iterable is not None:
+ self._elements = set(map(self._lower, iterable))
+
===========changed ref 10===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
+ tags = CaseInsensitiveSet(AvailableTags().get_tags())
- tags = AvailableTags().get_tags()
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
+ self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
- self._dict["Tags"] = set(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
- self._dict["ExcludeTags"] = set(filters_dict.setdefault("ExcludeTags", set()))
self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
-
if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
95566f076273eb94c46cb6952841e539d57c65d6
|
Fix printing
|
<4>:<add> if text["File Signatures"] and text["Regexes"]:
<del> if text["File Signatures"]:
<9>:<del> if to_out:
<10>:<del> console.print(to_out)
|
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"]:
<5> to_out += "\n"
<6> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff] with Magic Numbers {text['File Signatures']['ISO 8859-1']}."
<7> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {text['File Signatures']['Description']}."
<8> to_out += "\n"
<9> if to_out:
<10> console.print(to_out)
<11>
<12> if text["Regexes"]:
<13> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<14> table = Table(
<15> show_header=True, header_style="bold #D7Afff", show_lines=True
<16> )
<17> table.add_column("Matched Text", overflow="fold")
<18> table.add_column("Identified as", overflow="fold")
<19> table.add_column("Description")
<20> for i in text["Regexes"]:
<21> matched = i["Matched"]
<22> name = i["Regex Pattern"]["Name"]
<23> description = None
<24>
<25> if "URL" in i["Regex Pattern"]:
<26> description = (
<27> "Click here to analyse in the browser "
<28> + i["Regex Pattern"]["URL"]
<29> + matched.replace(" ", "")
<30> )
<31>
<32> if i["Regex Pattern"]["Description"]:
<33> if description:
<34> description = (
<35> description + "\n" + i["Regex Pattern"]["Description"]
<36> )
<37> else:
<38> description =</s>
|
===========below chunk 0===========
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict):
# offset: 1
if description:
table.add_row(
matched,
name,
description,
)
else:
table.add_row(
matched,
name,
"None",
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
|
pywhat.regex_identifier/RegexIdentifier.check
|
Modified
|
bee-san~pyWhat
|
d22b9ddbd0580e3b0d6b20fb6be5967f81a21997
|
Merge branch 'main' into recursion
|
<0>:<add> if distribution is None:
<del> if distribution is None:
<1>:<add> distribution = self.distribution
<del> distribution = self.distribution
<2>:<add> matches = []
<del> matches = []
<3>:<del> for txt in text:
<4>:<del> for reg in distribution.get_regexes():
<5>:<del> matched_regex = re.search(reg["Regex"], txt, re.UNICODE)
<6>:<del>
<7>:<del> if matched_regex:
<8>:<del> reg = copy.copy(reg) # necessary, when checking phone
<9>:<del> # numbers from file that may contain
<10>:<del> # non-international numbers
<11>:<del> matched = self.clean_text(matched_regex.group(0))
<12>:<del>
<13>:<del> if "Phone Number" in reg["Name"]:
<14>:<del> number = re.sub(r"[-() ]", "", matched)
<15>:<del> codes_path = "Data/phone_codes.json"
<16>:<del> codes_fullpath = os.path.join(
<17>:<del> os.path.dirname(os.path.abspath(__file__)), codes_path)
<18>:<del> with open(codes_fullpath, "r", encoding="utf-8") as myfile:
<19>:<del> codes = json.load(myfile)
<20>:<del>
<21>:<del> locations = []
<22>:<del> for code in codes:
<23>:<del> if number.startswith(code["dial_code"]):
<24>:<del> locations.append(code["name"])
<25>:<del> if len(locations):
<26>:<del> reg["Description"] = (
<27>:<del> "Location(s)"
<28>:<del> + ": "
<29>:<del> + ", ".join(locations)
<30>:<del> )
<31>:<del>
<32>:<del> matches.append(
<33>:<del> {
<34>:<del> "Matched": matched,
<35>:<del> "Regex Pattern": reg,
<36>:<del> }
<37>:<del> )
<38>:<del>
<39>:<del> return matches
|
# module: pywhat.regex_identifier
-
-
class RegexIdentifier:
-
def check(self, text, distribution: Optional[Distribution] = None):
<0> if distribution is None:
<1> distribution = self.distribution
<2> matches = []
<3> for txt in text:
<4> for reg in distribution.get_regexes():
<5> matched_regex = re.search(reg["Regex"], txt, re.UNICODE)
<6>
<7> if matched_regex:
<8> reg = copy.copy(reg) # necessary, when checking phone
<9> # numbers from file that may contain
<10> # non-international numbers
<11> matched = self.clean_text(matched_regex.group(0))
<12>
<13> if "Phone Number" in reg["Name"]:
<14> number = re.sub(r"[-() ]", "", matched)
<15> codes_path = "Data/phone_codes.json"
<16> codes_fullpath = os.path.join(
<17> os.path.dirname(os.path.abspath(__file__)), codes_path)
<18> with open(codes_fullpath, "r", encoding="utf-8") as myfile:
<19> codes = json.load(myfile)
<20>
<21> locations = []
<22> for code in codes:
<23> if number.startswith(code["dial_code"]):
<24> locations.append(code["name"])
<25> if len(locations):
<26> reg["Description"] = (
<27> "Location(s)"
<28> + ": "
<29> + ", ".join(locations)
<30> )
<31>
<32> matches.append(
<33> {
<34> "Matched": matched,
<35> "Regex Pattern": reg,
<36> }
<37> )
<38>
<39> return matches
<40>
|
===========unchanged ref 0===========
at: copy
copy(x: _T) -> _T
at: json
load(fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]]=..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]]=..., parse_float: Optional[Callable[[str], Any]]=..., parse_int: Optional[Callable[[str], Any]]=..., parse_constant: Optional[Callable[[str], Any]]=..., object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]]=..., **kwds: Any) -> Any
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
dirname(p: _PathLike[AnyStr]) -> AnyStr
dirname(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.regex_identifier.RegexIdentifier
clean_text(text)
at: pywhat.regex_identifier.RegexIdentifier.__init__
self.distribution = Distribution()
at: re
UNICODE = RegexFlag.UNICODE
search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
search(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
===========unchanged ref 1===========
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
at: typing.Match
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
string: AnyStr
re: Pattern[AnyStr]
group(group1: Union[str, int], group2: Union[str, int], /, *groups: Union[str, int]) -> Tuple[AnyStr, ...]
group(group: Union[str, int]=..., /) -> AnyStr
|
pywhat.identifier/Identifier.identify
|
Modified
|
bee-san~pyWhat
|
d22b9ddbd0580e3b0d6b20fb6be5967f81a21997
|
Merge branch 'main' into recursion
|
<0>:<add> if dist is None:
<del> if dist is None:
<1>:<add> dist = self.distribution
<del> dist = self.distribution
<2>:<add> identify_obj = {}
<del> identify_obj = {}
<3>:<del>
<4>:<del> magic_numbers = None
<5>:<del> if not api and self._file_exists(text):
<6>:<del> magic_numbers = self._file_sig.open_binary_scan_magic_nums(text)
<7>:<del> text = self._file_sig.open_file_loc(text)
<8>:<add> identify_obj["File Signatures"] = {}
<del> identify_obj["File Signatures"] = magic_numbers
<9>:<del> else:
<10>:<del> text = [text]
<11>:<del>
<12>:<del> if not magic_numbers:
<13>:<del> # If file doesn't exist, check to see if the inputted text is
<14>:<del> # a file in hex format
<15>:<del> identify_obj["File Signatures"] = self._file_sig.check_magic_nums(text)
<16>:<del>
<17>:<del> identify_obj["Regexes"] = self._regex_id.check(text, dist)
<18>:<del>
<19>:<del> # get_hashes takes a list of hashes, we split to give it a list
<20>:<del> # identify_obj["Hashes"] = self._name_that_hash.get_hashes(text.split())
<21>:<del>
<22>:<del> return identify_obj
<23>:<add> identify_obj["Regexes"] = {}
<add> search = []
|
# module: pywhat.identifier
-
-
class Identifier:
-
+ def identify(self, input: str, dist: Distribution = None,
- def identify(self, text: str, dist: Distribution = None,
api=False) -> dict:
<0> if dist is None:
<1> dist = self.distribution
<2> identify_obj = {}
<3>
<4> magic_numbers = None
<5> if not api and self._file_exists(text):
<6> magic_numbers = self._file_sig.open_binary_scan_magic_nums(text)
<7> text = self._file_sig.open_file_loc(text)
<8> identify_obj["File Signatures"] = magic_numbers
<9> else:
<10> text = [text]
<11>
<12> if not magic_numbers:
<13> # If file doesn't exist, check to see if the inputted text is
<14> # a file in hex format
<15> identify_obj["File Signatures"] = self._file_sig.check_magic_nums(text)
<16>
<17> identify_obj["Regexes"] = self._regex_id.check(text, dist)
<18>
<19> # get_hashes takes a list of hashes, we split to give it a list
<20> # identify_obj["Hashes"] = self._name_that_hash.get_hashes(text.split())
<21>
<22> return identify_obj
<23>
|
===========unchanged ref 0===========
at: glob
iglob(pathname: AnyStr, *, recursive: bool=...) -> Iterator[AnyStr]
at: os.path
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
basename(p: _PathLike[AnyStr]) -> AnyStr
basename(p: AnyStr) -> AnyStr
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier.Identifier.__init__
self.distribution = distribution
self.distribution = Distribution()
self._regex_id = RegexIdentifier()
self._file_sig = FileSignatures()
at: pywhat.magic_numbers.FileSignatures
open_file_loc(file_loc)
open_binary_scan_magic_nums(file_loc)
at: pywhat.nameThatHash
Nth()
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: pywhat.regex_identifier
-
-
class RegexIdentifier:
-
def check(self, text, distribution: Optional[Distribution] = None):
+ if distribution is None:
- if distribution is None:
+ distribution = self.distribution
- distribution = self.distribution
+ matches = []
- matches = []
- for txt in text:
- for reg in distribution.get_regexes():
- matched_regex = re.search(reg["Regex"], txt, re.UNICODE)
-
- if matched_regex:
- reg = copy.copy(reg) # necessary, when checking phone
- # numbers from file that may contain
- # non-international numbers
- matched = self.clean_text(matched_regex.group(0))
-
- if "Phone Number" in reg["Name"]:
- number = re.sub(r"[-() ]", "", matched)
- codes_path = "Data/phone_codes.json"
- codes_fullpath = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), codes_path)
- with open(codes_fullpath, "r", encoding="utf-8") as myfile:
- codes = json.load(myfile)
-
- locations = []
- for code in codes:
- if number.startswith(code["dial_code"]):
- locations.append(code["name"])
- if len(locations):
- reg["Description"] = (
- "Location(s)"
- + ": "
- + ", ".join(locations)
- )
-
- matches.append(
- {
- "Matched": matched,
- "Regex Pattern": reg,
- }
- )
-
- return matches
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
d22b9ddbd0580e3b0d6b20fb6be5967f81a21997
|
Merge branch 'main' into recursion
|
<1>:<add> pyWhat - Identify what something is.\n
<del> What - Identify what something is.\n
<17>:<add> * what 'HTB{this is a flag}'
<del> * what "HTB{this is a flag}"
<19>:<add> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<del> * what "0x52908400098527886E0F7030069857D2E4169EE7"
<26>:<add>
<add>
<add> pyWhat can also search files or even the whole directory with recursion:
<add>
<add> * what 'secret.txt'
<add>
<add> * what 'this/is/a/path'
|
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> What - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<10> --include_tags list\n
<11> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<12> --include_tags list\n
<13> Exclude specified tags. List is a comma separated list.\n
<14>
<15> Examples:
<16>
<17> * what "HTB{this is a flag}"
<18>
<19> * what "0x52908400098527886E0F7030069857D2E4169EE7"
<20>
<21> * what -- 52.6169586, -1.9779857
<22>
<23> * what --rarity 0.6: [email protected]
<24>
<25> Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
<26>
<27> """
<28>
<29> what_obj = What_Object(
<30> parse_options(rarity, include_tags, exclude_tags)
<31> )
<32> identified_output = what_obj.what_</s>
|
===========below chunk 0===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
p = printer.Printing()
p.pretty_print(identified_output)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.what
print_tags(ctx, opts, value)
===========changed ref 0===========
# module: pywhat.identifier
-
-
class Identifier:
-
- def _file_exists(self, text):
- return os.path.isfile(text)
-
===========changed ref 1===========
# module: pywhat.identifier
-
-
class Identifier:
-
+ def identify(self, input: str, dist: Distribution = None,
- def identify(self, text: str, dist: Distribution = None,
api=False) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ identify_obj = {}
- identify_obj = {}
-
- magic_numbers = None
- if not api and self._file_exists(text):
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(text)
- text = self._file_sig.open_file_loc(text)
+ identify_obj["File Signatures"] = {}
- identify_obj["File Signatures"] = magic_numbers
- else:
- text = [text]
-
- if not magic_numbers:
- # If file doesn't exist, check to see if the inputted text is
- # a file in hex format
- identify_obj["File Signatures"] = self._file_sig.check_magic_nums(text)
-
- identify_obj["Regexes"] = self._regex_id.check(text, dist)
-
- # get_hashes takes a list of hashes, we split to give it a list
- # identify_obj["Hashes"] = self._name_that_hash.get_hashes(text.split())
-
- return identify_obj
+ identify_obj["Regexes"] = {}
+ search = []
===========changed ref 2===========
# module: pywhat.regex_identifier
-
-
class RegexIdentifier:
-
def check(self, text, distribution: Optional[Distribution] = None):
+ if distribution is None:
- if distribution is None:
+ distribution = self.distribution
- distribution = self.distribution
+ matches = []
- matches = []
- for txt in text:
- for reg in distribution.get_regexes():
- matched_regex = re.search(reg["Regex"], txt, re.UNICODE)
-
- if matched_regex:
- reg = copy.copy(reg) # necessary, when checking phone
- # numbers from file that may contain
- # non-international numbers
- matched = self.clean_text(matched_regex.group(0))
-
- if "Phone Number" in reg["Name"]:
- number = re.sub(r"[-() ]", "", matched)
- codes_path = "Data/phone_codes.json"
- codes_fullpath = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), codes_path)
- with open(codes_fullpath, "r", encoding="utf-8") as myfile:
- codes = json.load(myfile)
-
- locations = []
- for code in codes:
- if number.startswith(code["dial_code"]):
- locations.append(code["name"])
- if len(locations):
- reg["Description"] = (
- "Location(s)"
- + ": "
- + ", ".join(locations)
- )
-
- matches.append(
- {
- "Matched": matched,
- "Regex Pattern": reg,
- }
- )
-
- return matches
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
d22b9ddbd0580e3b0d6b20fb6be5967f81a21997
|
Merge branch 'main' into recursion
|
<0>:<add> console = Console(highlight=False)
<del> console = Console(highlight=False)
<1>:<del>
<2>:<del> to_out = ""
<3>:<del>
<4>:<del> if text["File Signatures"] and text["Regexes"]:
<5>:<del> to_out += "\n"
<6>:<del> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff] with Magic Numbers {text['File Signatures']['ISO 8859-1']}."
<7>:<del> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {text['File Signatures']['Description']}."
<8>:<del> to_out += "\n"
<9>:<del>
<10>:<del> if text["Regexes"]:
<11>:<del> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<12>:<del> table = Table(
<13>:<del> show_header=True, header_style="bold #D7Afff", show_lines=True
<14>:<del> )
<15>:<del> table.add_column("Matched Text", overflow="fold")
<16>:<del> table.add_column("Identified as", overflow="fold")
<17>:<del> table.add_column("Description")
<18>:<del> for i in text["Regexes"]:
<19>:<del> matched = i["Matched"]
<20>:<del> name = i["Regex Pattern"]["Name"]
<21>:<del> description = None
<22>:<del>
<23>:<del> if "URL" in i["Regex Pattern"]:
<24>:<del> description = (
<25>:<del> "Click here to analyse in the browser "
<26>:<del> + i["Regex Pattern"]["URL"]
<27>:<del> + matched.replace(" ", "")
<28>:<del> )
<29>:<del>
<30>:<del> if i["Regex Pattern"]["Description"]:
<31>:<del> if description:
<32>:<del> description = (
<33>:<del> description + "\n" + i["Regex Pattern"]["Description"]
<34>:<del> )
<35>:<del> else:
<36>:<del> description = i["Regex Pattern"]["Description"]
<37>:<del>
|
# module: pywhat.printer
-
-
class Printing:
def pretty_print(self, text: dict):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"] and text["Regexes"]:
<5> to_out += "\n"
<6> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff] with Magic Numbers {text['File Signatures']['ISO 8859-1']}."
<7> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {text['File Signatures']['Description']}."
<8> to_out += "\n"
<9>
<10> if text["Regexes"]:
<11> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<12> table = Table(
<13> show_header=True, header_style="bold #D7Afff", show_lines=True
<14> )
<15> table.add_column("Matched Text", overflow="fold")
<16> table.add_column("Identified as", overflow="fold")
<17> table.add_column("Description")
<18> for i in text["Regexes"]:
<19> matched = i["Matched"]
<20> name = i["Regex Pattern"]["Name"]
<21> description = None
<22>
<23> if "URL" in i["Regex Pattern"]:
<24> description = (
<25> "Click here to analyse in the browser "
<26> + i["Regex Pattern"]["URL"]
<27> + matched.replace(" ", "")
<28> )
<29>
<30> if i["Regex Pattern"]["Description"]:
<31> if description:
<32> description = (
<33> description + "\n" + i["Regex Pattern"]["Description"]
<34> )
<35> else:
<36> description = i["Regex Pattern"]["Description"]
<37> </s>
|
===========below chunk 0===========
# module: pywhat.printer
-
-
class Printing:
def pretty_print(self, text: dict):
# offset: 1
table.add_row(
matched,
name,
description,
)
else:
table.add_row(
matched,
name,
"None",
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
===========changed ref 0===========
# module: pywhat.identifier
-
-
class Identifier:
-
- def _file_exists(self, text):
- return os.path.isfile(text)
-
===========changed ref 1===========
# module: tests.test_click
+
+ def test_nothing_found():
+ runner = CliRunner()
+ result = runner.invoke(main, [""])
+ assert result.exit_code == 0
+ assert "Nothing found!" in result.output
+
===========changed ref 2===========
# module: pywhat.identifier
-
-
class Identifier:
-
+ def identify(self, input: str, dist: Distribution = None,
- def identify(self, text: str, dist: Distribution = None,
api=False) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ identify_obj = {}
- identify_obj = {}
-
- magic_numbers = None
- if not api and self._file_exists(text):
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(text)
- text = self._file_sig.open_file_loc(text)
+ identify_obj["File Signatures"] = {}
- identify_obj["File Signatures"] = magic_numbers
- else:
- text = [text]
-
- if not magic_numbers:
- # If file doesn't exist, check to see if the inputted text is
- # a file in hex format
- identify_obj["File Signatures"] = self._file_sig.check_magic_nums(text)
-
- identify_obj["Regexes"] = self._regex_id.check(text, dist)
-
- # get_hashes takes a list of hashes, we split to give it a list
- # identify_obj["Hashes"] = self._name_that_hash.get_hashes(text.split())
-
- return identify_obj
+ identify_obj["Regexes"] = {}
+ search = []
===========changed ref 3===========
# module: pywhat.regex_identifier
-
-
class RegexIdentifier:
-
def check(self, text, distribution: Optional[Distribution] = None):
+ if distribution is None:
- if distribution is None:
+ distribution = self.distribution
- distribution = self.distribution
+ matches = []
- matches = []
- for txt in text:
- for reg in distribution.get_regexes():
- matched_regex = re.search(reg["Regex"], txt, re.UNICODE)
-
- if matched_regex:
- reg = copy.copy(reg) # necessary, when checking phone
- # numbers from file that may contain
- # non-international numbers
- matched = self.clean_text(matched_regex.group(0))
-
- if "Phone Number" in reg["Name"]:
- number = re.sub(r"[-() ]", "", matched)
- codes_path = "Data/phone_codes.json"
- codes_fullpath = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), codes_path)
- with open(codes_fullpath, "r", encoding="utf-8") as myfile:
- codes = json.load(myfile)
-
- locations = []
- for code in codes:
- if number.startswith(code["dial_code"]):
- locations.append(code["name"])
- if len(locations):
- reg["Description"] = (
- "Location(s)"
- + ": "
- + ", ".join(locations)
- )
-
- matches.append(
- {
- "Matched": matched,
- "Regex Pattern": reg,
- }
- )
-
- return matches
===========changed ref 4===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
+ pyWhat - Identify what something is.\n
- What - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
--include_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
+ * what 'HTB{this is a flag}'
- * what "HTB{this is a flag}"
+ * what '0x52908400098527886E0F7030069857D2E4169EE7'
- * what "0x52908400098527886E0F7030069857D2E4169EE7"
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
+
+
+ pyWhat can also search files or even the whole</s>
|
tests.test_identifier/test_identifier_works
|
Modified
|
bee-san~pyWhat
|
d22b9ddbd0580e3b0d6b20fb6be5967f81a21997
|
Merge branch 'main' into recursion
|
<0>:<add> r = identifier.Identifier()
<del> r = identifier.Identifier()
<1>:<add> out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
<del> out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
<2>:<add> assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
<del> assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"][0]["Regex Pattern"]["Name"]
|
# module: tests.test_identifier
-
-
def test_identifier_works():
<0> r = identifier.Identifier()
<1> out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
<2> assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"][0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(text: str, dist: Distribution=None, api=False) -> dict
===========changed ref 0===========
# module: pywhat.identifier
-
-
class Identifier:
-
+ def identify(self, input: str, dist: Distribution = None,
- def identify(self, text: str, dist: Distribution = None,
api=False) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ identify_obj = {}
- identify_obj = {}
-
- magic_numbers = None
- if not api and self._file_exists(text):
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(text)
- text = self._file_sig.open_file_loc(text)
+ identify_obj["File Signatures"] = {}
- identify_obj["File Signatures"] = magic_numbers
- else:
- text = [text]
-
- if not magic_numbers:
- # If file doesn't exist, check to see if the inputted text is
- # a file in hex format
- identify_obj["File Signatures"] = self._file_sig.check_magic_nums(text)
-
- identify_obj["Regexes"] = self._regex_id.check(text, dist)
-
- # get_hashes takes a list of hashes, we split to give it a list
- # identify_obj["Hashes"] = self._name_that_hash.get_hashes(text.split())
-
- return identify_obj
+ identify_obj["Regexes"] = {}
+ search = []
===========changed ref 1===========
# module: pywhat.identifier
-
-
class Identifier:
-
- def _file_exists(self, text):
- return os.path.isfile(text)
-
===========changed ref 2===========
# module: tests.test_click
+
+ def test_nothing_found():
+ runner = CliRunner()
+ result = runner.invoke(main, [""])
+ assert result.exit_code == 0
+ assert "Nothing found!" in result.output
+
===========changed ref 3===========
# module: pywhat.regex_identifier
-
-
class RegexIdentifier:
-
def check(self, text, distribution: Optional[Distribution] = None):
+ if distribution is None:
- if distribution is None:
+ distribution = self.distribution
- distribution = self.distribution
+ matches = []
- matches = []
- for txt in text:
- for reg in distribution.get_regexes():
- matched_regex = re.search(reg["Regex"], txt, re.UNICODE)
-
- if matched_regex:
- reg = copy.copy(reg) # necessary, when checking phone
- # numbers from file that may contain
- # non-international numbers
- matched = self.clean_text(matched_regex.group(0))
-
- if "Phone Number" in reg["Name"]:
- number = re.sub(r"[-() ]", "", matched)
- codes_path = "Data/phone_codes.json"
- codes_fullpath = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), codes_path)
- with open(codes_fullpath, "r", encoding="utf-8") as myfile:
- codes = json.load(myfile)
-
- locations = []
- for code in codes:
- if number.startswith(code["dial_code"]):
- locations.append(code["name"])
- if len(locations):
- reg["Description"] = (
- "Location(s)"
- + ": "
- + ", ".join(locations)
- )
-
- matches.append(
- {
- "Matched": matched,
- "Regex Pattern": reg,
- }
- )
-
- return matches
===========changed ref 4===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
+ pyWhat - Identify what something is.\n
- What - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
--include_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
+ * what 'HTB{this is a flag}'
- * what "HTB{this is a flag}"
+ * what '0x52908400098527886E0F7030069857D2E4169EE7'
- * what "0x52908400098527886E0F7030069857D2E4169EE7"
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
+
+
+ pyWhat can also search files or even the whole</s>
===========changed ref 5===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s> mean "anything after -- is textual input".
+
+
+ pyWhat can also search files or even the whole directory with recursion:
+
+ * what 'secret.txt'
+
+ * what 'this/is/a/path'
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
|
pywhat.regex_identifier/RegexIdentifier.check
|
Modified
|
bee-san~pyWhat
|
8b0eb25cd0c6922a7d426b5487da4ddd62cb4fd6
|
Fixed *most* of the tests
|
<5>:<add> for reg in distribution.get_regexes():
<del> for reg in self.regexes:
<6>:<del>
<10>:<add> reg = copy.copy(reg) # necessary, when checking phone
<del> # necessary, when checking phone
<11>:<add> # numbers from file that may contain
<add> # non-international numbers
<del> # numbers from file that may contain non-international numbers
<12>:<del> reg = copy.copy(reg)
|
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
<0> if distribution is None:
<1> distribution = self.distribution
<2> matches = []
<3>
<4> for string in text:
<5> for reg in self.regexes:
<6>
<7> matched_regex = re.search(reg["Regex"], string, re.UNICODE)
<8>
<9> if matched_regex:
<10> # necessary, when checking phone
<11> # numbers from file that may contain non-international numbers
<12> reg = copy.copy(reg)
<13> matched = self.clean_text(matched_regex.group(0))
<14>
<15> if "Phone Number" in reg["Name"]:
<16> number = re.sub(r"[-() ]", "", matched)
<17> codes_path = "Data/phone_codes.json"
<18> codes_fullpath = os.path.join(
<19> os.path.dirname(os.path.abspath(__file__)), codes_path)
<20> with open(codes_fullpath, "r", encoding="utf-8") as myfile:
<21> codes = json.load(myfile)
<22>
<23> locations = []
<24> for code in codes:
<25> if number.startswith(code["dial_code"]):
<26> locations.append(code["name"])
<27> if len(locations):
<28> reg["Description"] = (
<29> "Location(s)"
<30> + ": "
<31> + ", ".join(locations)
<32> )
<33>
<34> matches.append(
<35> {
<36> "Matched": matched,
<37> "Regex Pattern": reg,
<38> }
<39> )
<40>
<41> return matches
<42>
|
===========unchanged ref 0===========
at: copy
copy(x: _T) -> _T
at: json
load(fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]]=..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]]=..., parse_float: Optional[Callable[[str], Any]]=..., parse_int: Optional[Callable[[str], Any]]=..., parse_constant: Optional[Callable[[str], Any]]=..., object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]]=..., **kwds: Any) -> Any
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
dirname(p: _PathLike[AnyStr]) -> AnyStr
dirname(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.regex_identifier.RegexIdentifier
clean_text(text)
at: pywhat.regex_identifier.RegexIdentifier.__init__
self.distribution = Distribution()
at: re
UNICODE = RegexFlag.UNICODE
search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
search(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
===========unchanged ref 1===========
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
at: typing.Match
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
string: AnyStr
re: Pattern[AnyStr]
group(group1: Union[str, int], group2: Union[str, int], /, *groups: Union[str, int]) -> Tuple[AnyStr, ...]
group(group: Union[str, int]=..., /) -> AnyStr
|
pywhat.what/parse_options
|
Modified
|
bee-san~pyWhat
|
8b0eb25cd0c6922a7d426b5487da4ddd62cb4fd6
|
Fixed *most* of the tests
|
<18>:<add>
<del>
|
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
<0> filter = dict()
<1> if rarity is not None:
<2> rarities = rarity.split(":")
<3> if len(rarities) != 2:
<4> print("Invalid rarity range format ('min:max' expected)")
<5> sys.exit(1)
<6> try:
<7> if not rarities[0].isspace() and rarities[0]:
<8> filter["MinRarity"] = float(rarities[0])
<9> if not rarities[1].isspace() and rarities[1]:
<10> filter["MaxRarity"] = float(rarities[1])
<11> except ValueError:
<12> print("Invalid rarity argument (float expected)")
<13> sys.exit(1)
<14> if include_tags is not None:
<15> filter["Tags"] = list(map(str.strip, include_tags.split(',')))
<16> if exclude_tags is not None:
<17> filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
<18>
<19> try:
<20> distribution = Distribution(filter)
<21> except InvalidTag:
<22> print("Passed tags are not valid.\n" \
<23> "You can check available tags by using: 'pywhat --tags'")
<24> sys.exit(1)
<25>
<26> return distribution
<27>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.helper
InvalidTag(*args: object)
at: sys
exit(status: object=..., /) -> NoReturn
===========changed ref 0===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
+ for reg in distribution.get_regexes():
- for reg in self.regexes:
-
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
+ reg = copy.copy(reg) # necessary, when checking phone
- # necessary, when checking phone
+ # numbers from file that may contain
+ # non-international numbers
- # numbers from file that may contain non-international numbers
- reg = copy.copy(reg)
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
8b0eb25cd0c6922a7d426b5487da4ddd62cb4fd6
|
Fixed *most* of the tests
|
<12>:<add> --exclude_tags list\n
<del> --include_tags list\n
|
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<10> --include_tags list\n
<11> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<12> --include_tags list\n
<13> Exclude specified tags. List is a comma separated list.\n
<14>
<15> Examples:
<16>
<17> * what 'HTB{this is a flag}'
<18>
<19> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<20>
<21> * what -- 52.6169586, -1.9779857
<22>
<23> * what --rarity 0.6: [email protected]
<24>
<25> Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
<26>
<27>
<28> pyWhat can also search files or even the whole directory with recursion:
<29>
<30> * what 'secret.txt'
<31>
<32> * what 'this/is/a/path'
<33>
</s>
|
===========below chunk 0===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.printer
Printing()
at: pywhat.printer.Printing
pretty_print(text: dict)
at: pywhat.what
print_tags(ctx, opts, value)
parse_options(rarity, include_tags, exclude_tags)
What_Object(distribution)
at: pywhat.what.What_Object
what_is_this(text: str) -> dict
===========changed ref 0===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
+
-
try:
distribution = Distribution(filter)
except InvalidTag:
print("Passed tags are not valid.\n" \
"You can check available tags by using: 'pywhat --tags'")
sys.exit(1)
return distribution
===========changed ref 1===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
+ for reg in distribution.get_regexes():
- for reg in self.regexes:
-
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
+ reg = copy.copy(reg) # necessary, when checking phone
- # necessary, when checking phone
+ # numbers from file that may contain
+ # non-international numbers
- # numbers from file that may contain non-international numbers
- reg = copy.copy(reg)
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
|
tests.test_identifier/test_identifier_works
|
Modified
|
bee-san~pyWhat
|
8b0eb25cd0c6922a7d426b5487da4ddd62cb4fd6
|
Fixed *most* of the tests
|
<2>:<add> assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
<del> assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
|
# module: tests.test_identifier
def test_identifier_works():
<0> r = identifier.Identifier()
<1> out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
<2> assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(input: str, dist: Distribution=None, api=False) -> dict
===========changed ref 0===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
+
-
try:
distribution = Distribution(filter)
except InvalidTag:
print("Passed tags are not valid.\n" \
"You can check available tags by using: 'pywhat --tags'")
sys.exit(1)
return distribution
===========changed ref 1===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
+ for reg in distribution.get_regexes():
- for reg in self.regexes:
-
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
+ reg = copy.copy(reg) # necessary, when checking phone
- # necessary, when checking phone
+ # numbers from file that may contain
+ # non-international numbers
- # numbers from file that may contain non-international numbers
- reg = copy.copy(reg)
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
===========changed ref 2===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
+ --exclude_tags list\n
- --include_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even the whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(
parse_options</s>
===========changed ref 3===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s>/a/path'
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
|
tests.test_identifier/test_identifier_filtration
|
Modified
|
bee-san~pyWhat
|
8b0eb25cd0c6922a7d426b5487da4ddd62cb4fd6
|
Fixed *most* of the tests
|
<2>:<add> regexes = r.identify('fixtures/file')["Regexes"]["file"]
<del> regexes = r.identify('fixtures/file')["Regexes"]
|
# module: tests.test_identifier
def test_identifier_filtration():
<0> filter = {"Tags": ["Password"]}
<1> r = identifier.Identifier(Distribution(filter))
<2> regexes = r.identify('fixtures/file')["Regexes"]
<3> for regex in regexes:
<4> assert "Password" in regex["Regex Pattern"]["Tags"]
<5>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(input: str, dist: Distribution=None, api=False) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_works():
r = identifier.Identifier()
out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
+ assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
- assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
+
-
try:
distribution = Distribution(filter)
except InvalidTag:
print("Passed tags are not valid.\n" \
"You can check available tags by using: 'pywhat --tags'")
sys.exit(1)
return distribution
===========changed ref 2===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
+ for reg in distribution.get_regexes():
- for reg in self.regexes:
-
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
+ reg = copy.copy(reg) # necessary, when checking phone
- # necessary, when checking phone
+ # numbers from file that may contain
+ # non-international numbers
- # numbers from file that may contain non-international numbers
- reg = copy.copy(reg)
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
===========changed ref 3===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
+ --exclude_tags list\n
- --include_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even the whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(
parse_options</s>
===========changed ref 4===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s>/a/path'
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
|
tests.test_identifier/test_identifier_filtration2
|
Modified
|
bee-san~pyWhat
|
8b0eb25cd0c6922a7d426b5487da4ddd62cb4fd6
|
Fixed *most* of the tests
|
<3>:<add> regexes = r.identify('fixtures/file', dist=Distribution(filter2))["Regexes"]["file"]
<del> regexes = r.identify('fixtures/file', dist=Distribution(filter2))["Regexes"]
|
# module: tests.test_identifier
-
def test_identifier_filtration2():
<0> filter1 = {"ExcludeTags": ["Identifiers"]}
<1> filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
<2> r = identifier.Identifier(Distribution(filter1))
<3> regexes = r.identify('fixtures/file', dist=Distribution(filter2))["Regexes"]
<4> for regex in regexes:
<5> assert "Identifiers" in regex["Regex Pattern"]["Tags"]
<6> assert regex["Regex Pattern"]["Rarity"] >= 0.6
<7>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(input: str, dist: Distribution=None, api=False) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(Distribution(filter))
+ regexes = r.identify('fixtures/file')["Regexes"]["file"]
- regexes = r.identify('fixtures/file')["Regexes"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_works():
r = identifier.Identifier()
out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
+ assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
- assert "Dogecoin (DOGE) Wallet Address" in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
+
-
try:
distribution = Distribution(filter)
except InvalidTag:
print("Passed tags are not valid.\n" \
"You can check available tags by using: 'pywhat --tags'")
sys.exit(1)
return distribution
===========changed ref 3===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
+ for reg in distribution.get_regexes():
- for reg in self.regexes:
-
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
+ reg = copy.copy(reg) # necessary, when checking phone
- # necessary, when checking phone
+ # numbers from file that may contain
+ # non-international numbers
- # numbers from file that may contain non-international numbers
- reg = copy.copy(reg)
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
===========changed ref 4===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
+ --exclude_tags list\n
- --include_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even the whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(
parse_options</s>
===========changed ref 5===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s>/a/path'
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
|
pywhat.identifier/Identifier.identify
|
Modified
|
bee-san~pyWhat
|
841093b4c1c61b574b36d508c8f07ce4a9d8b47d
|
Fixes filtration
|
<21>:<add> regex = self._regex_id.check(text, dist)
<del> regex = self._regex_id.check(text)
<31>:<add> regex = self._regex_id.check(search, dist)
<del> regex = self._regex_id.check(search)
|
# module: pywhat.identifier
class Identifier:
def identify(self, input: str, dist: Distribution = None,
api=False) -> dict:
<0> if dist is None:
<1> dist = self.distribution
<2> identify_obj = {}
<3> identify_obj["File Signatures"] = {}
<4> identify_obj["Regexes"] = {}
<5> search = []
<6>
<7> if os.path.isdir(input):
<8> # if input is a directory, recursively search for all of the files
<9> for myfile in glob.iglob(input + "**/**", recursive=True):
<10> if os.path.isfile(myfile):
<11> search.append(myfile)
<12> else:
<13> search = [input]
<14>
<15> for string in search:
<16> if os.path.isfile(string):
<17> short_name = os.path.basename(string)
<18> magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
<19> text = self._file_sig.open_file_loc(string)
<20> text.append(short_name)
<21> regex = self._regex_id.check(text)
<22> short_name = os.path.basename(string)
<23>
<24> if not magic_numbers:
<25> magic_numbers = self._file_sig.check_magic_nums(string)
<26>
<27> if magic_numbers:
<28> identify_obj["File Signatures"][short_name] = magic_numbers
<29> else:
<30> short_name = "text"
<31> regex = self._regex_id.check(search)
<32>
<33> if regex:
<34> identify_obj["Regexes"][short_name] = regex
<35>
<36> for key, value in identify_obj.items():
<37> # if there are zero regex or file signature matches, set it to None
<38> if len(identify_obj[key]) == 0:
<39> identify_obj[key] = None
<40>
<41> return identify_obj
<42>
|
===========unchanged ref 0===========
at: glob
iglob(pathname: AnyStr, *, recursive: bool=...) -> Iterator[AnyStr]
at: os.path
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
basename(p: _PathLike[AnyStr]) -> AnyStr
basename(p: AnyStr) -> AnyStr
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier.Identifier.__init__
self.distribution = distribution
self.distribution = Distribution()
self._regex_id = RegexIdentifier()
self._file_sig = FileSignatures()
at: pywhat.magic_numbers.FileSignatures
open_file_loc(file_loc)
open_binary_scan_magic_nums(file_loc)
check_magic_nums(text)
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
|
tests.test_click/test_file_fixture_ip4
|
Modified
|
bee-san~pyWhat
|
edaf1a61429af84d04e2e05211be574a1de2b354
|
Print a filename column, even if there is only one file
|
<1>:<add> result = runner.invoke(main, ["118.103.238.230"])
<del> result = runner.invoke(main, ["fixtures/file"])
|
# module: tests.test_click
def test_file_fixture_ip4():
<0> runner = CliRunner()
<1> result = runner.invoke(main, ["fixtures/file"])
<2> assert result.exit_code == 0
<3> assert re.findall("Address Version 4", str(result.output))
<4>
|
===========unchanged ref 0===========
at: click.testing
CliRunner(charset: Optional[Text]=..., env: Optional[Mapping[str, str]]=..., echo_stdin: bool=..., mix_stderr: bool=...)
at: click.testing.CliRunner
invoke(cli: BaseCommand, args: Optional[Union[str, Iterable[str]]]=..., input: Optional[Union[bytes, Text, IO[Any]]]=..., env: Optional[Mapping[str, str]]=..., catch_exceptions: bool=..., color: bool=..., **extra: Any) -> Result
at: click.testing.Result.__init__
self.exit_code = exit_code
at: pywhat.what
main(text_input, rarity, include_tags, exclude_tags)
at: re
findall(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> List[Any]
findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> List[Any]
|
tests.test_click/test_file_fixture_ip6
|
Modified
|
bee-san~pyWhat
|
edaf1a61429af84d04e2e05211be574a1de2b354
|
Print a filename column, even if there is only one file
|
<1>:<add> result = runner.invoke(main, ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
<del> result = runner.invoke(main, ["fixtures/file"])
|
# module: tests.test_click
def test_file_fixture_ip6():
<0> runner = CliRunner()
<1> result = runner.invoke(main, ["fixtures/file"])
<2> assert result.exit_code == 0
<3> assert re.findall("Address Version 6", str(result.output))
<4>
|
===========unchanged ref 0===========
at: click.testing
CliRunner(charset: Optional[Text]=..., env: Optional[Mapping[str, str]]=..., echo_stdin: bool=..., mix_stderr: bool=...)
at: click.testing.CliRunner
invoke(cli: BaseCommand, args: Optional[Union[str, Iterable[str]]]=..., input: Optional[Union[bytes, Text, IO[Any]]]=..., env: Optional[Mapping[str, str]]=..., catch_exceptions: bool=..., color: bool=..., **extra: Any) -> Result
at: click.testing.Result.__init__
self.exit_code = exit_code
at: pywhat.what
main(text_input, rarity, include_tags, exclude_tags)
at: re
findall(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> List[Any]
findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> List[Any]
===========changed ref 0===========
# module: tests.test_click
def test_file_fixture_ip4():
runner = CliRunner()
+ result = runner.invoke(main, ["118.103.238.230"])
- result = runner.invoke(main, ["fixtures/file"])
assert result.exit_code == 0
assert re.findall("Address Version 4", str(result.output))
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
edaf1a61429af84d04e2e05211be574a1de2b354
|
Print a filename column, even if there is only one file
|
<21>:<add> if list(text["Regexes"].keys())[0] == text:
<del> if len(text["Regexes"]) > 1:
<22>:<add> # if input was text, do not add a filename column
<del> # if there is only one file (or input is text), do not add a filename column
<30>:<del>
<31>:<del> if key == "text":
<32>:<del> filename = "None"
<33>:<del> else:
<34>:<add> filename = key
<del> filename = key
|
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"] and text["Regexes"]:
<5> for key, value in text["File Signatures"].items():
<6> if value:
<7> to_out += "\n"
<8> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff]: [bold]{key}[/bold] with Magic Numbers {value['ISO 8859-1']}."
<9> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {value['Description']}."
<10> to_out += "\n"
<11>
<12> if text["Regexes"]:
<13> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<14> table = Table(
<15> show_header=True, header_style="bold #D7Afff", show_lines=True
<16> )
<17> table.add_column("Matched Text", overflow="fold")
<18> table.add_column("Identified as", overflow="fold")
<19> table.add_column("Description")
<20>
<21> if len(text["Regexes"]) > 1:
<22> # if there is only one file (or input is text), do not add a filename column
<23> table.add_column("Filename", overflow="fold")
<24>
<25> for key, value in text["Regexes"].items():
<26> for i in value:
<27> matched = i["Matched"]
<28> name = i["Regex Pattern"]["Name"]
<29> description = None
<30>
<31> if key == "text":
<32> filename = "None"
<33> else:
<34> filename = key
<35>
<36> if "URL" in i["Regex Pattern"]:
<37> description = (
<38> "Click here to analyse in the browser "
<39> + i["Regex Pattern"]["URL"]
<40> + matched.replace(" ",</s>
|
===========below chunk 0===========
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict):
# offset: 1
)
if i["Regex Pattern"]["Description"]:
if description:
description = (
description + "\n" + i["Regex Pattern"]["Description"]
)
else:
description = i["Regex Pattern"]["Description"]
if not description:
description = "None"
if len(text["Regexes"]) == 1:
table.add_row(
matched,
name,
description,
)
else:
table.add_row(
matched,
name,
description,
filename,
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
===========unchanged ref 0===========
at: json
dumps(obj: Any, *, skipkeys: bool=..., ensure_ascii: bool=..., check_circular: bool=..., allow_nan: bool=..., cls: Optional[Type[JSONEncoder]]=..., indent: Union[None, int, str]=..., separators: Optional[Tuple[str, str]]=..., default: Optional[Callable[[Any], Any]]=..., sort_keys: bool=..., **kwds: Any) -> str
===========changed ref 0===========
# module: tests.test_click
def test_file_fixture_ip4():
runner = CliRunner()
+ result = runner.invoke(main, ["118.103.238.230"])
- result = runner.invoke(main, ["fixtures/file"])
assert result.exit_code == 0
assert re.findall("Address Version 4", str(result.output))
===========changed ref 1===========
# module: tests.test_click
def test_file_fixture_ip6():
runner = CliRunner()
+ result = runner.invoke(main, ["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
- result = runner.invoke(main, ["fixtures/file"])
assert result.exit_code == 0
assert re.findall("Address Version 6", str(result.output))
|
pywhat.regex_identifier/RegexIdentifier.check
|
Modified
|
bee-san~pyWhat
|
a4853d779cfb12166085650e294ee2dcd8be4ef5
|
API option to treat input as only text
|
<26>:<add> if len(locations) > 0:
<del> if len(locations):
|
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
<0> if distribution is None:
<1> distribution = self.distribution
<2> matches = []
<3>
<4> for string in text:
<5> for reg in distribution.get_regexes():
<6> matched_regex = re.search(reg["Regex"], string, re.UNICODE)
<7>
<8> if matched_regex:
<9> reg = copy.copy(reg) # necessary, when checking phone
<10> # numbers from file that may contain
<11> # non-international numbers
<12> matched = self.clean_text(matched_regex.group(0))
<13>
<14> if "Phone Number" in reg["Name"]:
<15> number = re.sub(r"[-() ]", "", matched)
<16> codes_path = "Data/phone_codes.json"
<17> codes_fullpath = os.path.join(
<18> os.path.dirname(os.path.abspath(__file__)), codes_path)
<19> with open(codes_fullpath, "r", encoding="utf-8") as myfile:
<20> codes = json.load(myfile)
<21>
<22> locations = []
<23> for code in codes:
<24> if number.startswith(code["dial_code"]):
<25> locations.append(code["name"])
<26> if len(locations):
<27> reg["Description"] = (
<28> "Location(s)"
<29> + ": "
<30> + ", ".join(locations)
<31> )
<32>
<33> matches.append(
<34> {
<35> "Matched": matched,
<36> "Regex Pattern": reg,
<37> }
<38> )
<39>
<40> return matches
<41>
|
===========unchanged ref 0===========
at: copy
copy(x: _T) -> _T
at: json
load(fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]]=..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]]=..., parse_float: Optional[Callable[[str], Any]]=..., parse_int: Optional[Callable[[str], Any]]=..., parse_constant: Optional[Callable[[str], Any]]=..., object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]]=..., **kwds: Any) -> Any
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
dirname(p: _PathLike[AnyStr]) -> AnyStr
dirname(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.regex_identifier.RegexIdentifier
clean_text(text)
at: pywhat.regex_identifier.RegexIdentifier.__init__
self.distribution = Distribution()
at: re
UNICODE = RegexFlag.UNICODE
search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
search(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
===========unchanged ref 1===========
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
at: typing.Match
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
string: AnyStr
re: Pattern[AnyStr]
group(group1: Union[str, int], group2: Union[str, int], /, *groups: Union[str, int]) -> Tuple[AnyStr, ...]
group(group: Union[str, int]=..., /) -> AnyStr
|
pywhat.identifier/Identifier.identify
|
Modified
|
bee-san~pyWhat
|
a4853d779cfb12166085650e294ee2dcd8be4ef5
|
API option to treat input as only text
|
<2>:<del> identify_obj = {}
<3>:<add> identify_obj = {"File Signatures": {}, "Regexes":{}}
<del> identify_obj["File Signatures"] = {}
<4>:<del> identify_obj["Regexes"] = {}
<7>:<add> if not only_text and os.path.isdir(text):
<del> if os.path.isdir(input):
<9>:<add> for myfile in glob.iglob(text + "**/**", recursive=True):
<del> for myfile in glob.iglob(input + "**/**", recursive=True):
<13>:<add> search = [text]
<del> search = [input]
<16>:<add> if not only_text and os.path.isfile(string):
<del> if os.path.isfile(string):
|
# module: pywhat.identifier
class Identifier:
+ def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
- def identify(self, input: str, dist: Distribution = None,
- api=False) -> dict:
<0> if dist is None:
<1> dist = self.distribution
<2> identify_obj = {}
<3> identify_obj["File Signatures"] = {}
<4> identify_obj["Regexes"] = {}
<5> search = []
<6>
<7> if os.path.isdir(input):
<8> # if input is a directory, recursively search for all of the files
<9> for myfile in glob.iglob(input + "**/**", recursive=True):
<10> if os.path.isfile(myfile):
<11> search.append(myfile)
<12> else:
<13> search = [input]
<14>
<15> for string in search:
<16> if os.path.isfile(string):
<17> short_name = os.path.basename(string)
<18> magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
<19> text = self._file_sig.open_file_loc(string)
<20> text.append(short_name)
<21> regex = self._regex_id.check(text, dist)
<22> short_name = os.path.basename(string)
<23>
<24> if not magic_numbers:
<25> magic_numbers = self._file_sig.check_magic_nums(string)
<26>
<27> if magic_numbers:
<28> identify_obj["File Signatures"][short_name] = magic_numbers
<29> else:
<30> short_name = "text"
<31> regex = self._regex_id.check(search, dist)
<32>
<33> if regex:
<34> identify_obj["Regexes"][short_name] = regex
<35>
<36> for key, value in identify_obj.items():
<37> # if there are zero regex or file signature matches, set it to None
<38> if len(identify_obj[key]) == 0:
<39> identify_obj[</s>
|
===========below chunk 0===========
# module: pywhat.identifier
class Identifier:
+ def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
- def identify(self, input: str, dist: Distribution = None,
- api=False) -> dict:
# offset: 1
return identify_obj
===========unchanged ref 0===========
at: glob
iglob(pathname: AnyStr, *, recursive: bool=...) -> Iterator[AnyStr]
at: os.path
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
basename(p: _PathLike[AnyStr]) -> AnyStr
basename(p: AnyStr) -> AnyStr
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier.Identifier.__init__
self.distribution = distribution
self.distribution = Distribution()
self._regex_id = RegexIdentifier()
self._file_sig = FileSignatures()
at: pywhat.magic_numbers.FileSignatures
open_file_loc(file_loc)
open_binary_scan_magic_nums(file_loc)
check_magic_nums(text)
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
for reg in distribution.get_regexes():
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
reg = copy.copy(reg) # necessary, when checking phone
# numbers from file that may contain
# non-international numbers
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
+ if len(locations) > 0:
- if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
a4853d779cfb12166085650e294ee2dcd8be4ef5
|
API option to treat input as only text
|
<28>:<add> pyWhat can also search files or even a whole directory with recursion:
<del> pyWhat can also search files or even the whole directory with recursion:
|
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<10> --include_tags list\n
<11> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<12> --exclude_tags list\n
<13> Exclude specified tags. List is a comma separated list.\n
<14>
<15> Examples:
<16>
<17> * what 'HTB{this is a flag}'
<18>
<19> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<20>
<21> * what -- 52.6169586, -1.9779857
<22>
<23> * what --rarity 0.6: [email protected]
<24>
<25> Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
<26>
<27>
<28> pyWhat can also search files or even the whole directory with recursion:
<29>
<30> * what 'secret.txt'
<31>
<32> * what 'this/is/a/path'
<33>
</s>
|
===========below chunk 0===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.printer
Printing()
at: pywhat.printer.Printing
pretty_print(text: dict)
at: pywhat.what
print_tags(ctx, opts, value)
parse_options(rarity, include_tags, exclude_tags)
What_Object(distribution)
at: pywhat.what.What_Object
what_is_this(text: str) -> dict
===========changed ref 0===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
for reg in distribution.get_regexes():
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
reg = copy.copy(reg) # necessary, when checking phone
# numbers from file that may contain
# non-international numbers
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
+ if len(locations) > 0:
- if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
a4853d779cfb12166085650e294ee2dcd8be4ef5
|
API option to treat input as only text
|
<19>:<add> table.add_column("Description", overflow="fold")
<del> table.add_column("Description")
<34>:<add> "Click here to analyse in the browser\n"
<del> "Click here to analyse in the browser "
|
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"] and text["Regexes"]:
<5> for key, value in text["File Signatures"].items():
<6> if value:
<7> to_out += "\n"
<8> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff]: [bold]{key}[/bold] with Magic Numbers {value['ISO 8859-1']}."
<9> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {value['Description']}."
<10> to_out += "\n"
<11>
<12> if text["Regexes"]:
<13> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<14> table = Table(
<15> show_header=True, header_style="bold #D7Afff", show_lines=True
<16> )
<17> table.add_column("Matched Text", overflow="fold")
<18> table.add_column("Identified as", overflow="fold")
<19> table.add_column("Description")
<20>
<21> if list(text["Regexes"].keys())[0] == text:
<22> # if input was text, do not add a filename column
<23> table.add_column("Filename", overflow="fold")
<24>
<25> for key, value in text["Regexes"].items():
<26> for i in value:
<27> matched = i["Matched"]
<28> name = i["Regex Pattern"]["Name"]
<29> description = None
<30> filename = key
<31>
<32> if "URL" in i["Regex Pattern"]:
<33> description = (
<34> "Click here to analyse in the browser "
<35> + i["Regex Pattern"]["URL"]
<36> + matched.replace(" ", "")
<37> )
<38>
<39> if i["Regex Pattern"]["Description"]:
<40> if</s>
|
===========below chunk 0===========
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict):
# offset: 1
description = (
description + "\n" + i["Regex Pattern"]["Description"]
)
else:
description = i["Regex Pattern"]["Description"]
if not description:
description = "None"
if key == "text":
table.add_row(
matched,
name,
description,
)
else:
table.add_row(
matched,
name,
description,
filename,
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
===========changed ref 0===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
for string in text:
for reg in distribution.get_regexes():
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
reg = copy.copy(reg) # necessary, when checking phone
# numbers from file that may contain
# non-international numbers
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
+ if len(locations) > 0:
- if len(locations):
reg["Description"] = (
"Location(s)"
+ ": "
+ ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
===========changed ref 1===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
--exclude_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
+ pyWhat can also search files or even a whole directory with recursion:
- pyWhat can also search files or even the whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object</s>
===========changed ref 2===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s> * what 'this/is/a/path'
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
|
pywhat.identifier/Identifier.__init__
|
Modified
|
bee-san~pyWhat
|
aa61f3629db441cf4e0b0e65ab525d0b024f8340
|
Merge branch 'main' into sort
|
<0>:<add> if dist is None:
<del> if distribution is None:
<1>:<add> self.distribution = Distribution()
<del> self.distribution = Distribution()
<2>:<add> else:
<del> else:
<3>:<add> self.distribution = dist
<del> self.distribution = distribution
<4>:<add> self._regex_id = RegexIdentifier()
<del> self._regex_id = RegexIdentifier()
<5>:<add> self._file_sig = FileSignatures()
<del> self._file_sig = FileSignatures()
<6>:<add> self._name_that_hash = Nth()
<del> self._name_that_hash = Nth()
<7>:<add> self._key = key
<add> self._reverse = reverse
|
# module: pywhat.identifier
+
+
class Identifier:
+ def __init__(
+ self,
+ *,
+ dist: Optional[Distribution] = None,
+ key: Callable = Keys.NONE,
+ reverse=False
+ ):
- def __init__(self, distribution: Optional[Distribution] = None):
<0> if distribution is None:
<1> self.distribution = Distribution()
<2> else:
<3> self.distribution = distribution
<4> self._regex_id = RegexIdentifier()
<5> self._file_sig = FileSignatures()
<6> self._name_that_hash = Nth()
<7>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.magic_numbers
FileSignatures()
at: pywhat.nameThatHash
Nth()
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: pywhat.helper
+ class Keys(Enum):
+ NAME = lambda match: match["Regex Pattern"]["Name"]
+ RARITY = lambda match: match["Regex Pattern"]["Rarity"]
+ MATCHED = lambda match: match["Matched"]
+ NONE = auto()
+
|
pywhat.identifier/Identifier.identify
|
Modified
|
bee-san~pyWhat
|
aa61f3629db441cf4e0b0e65ab525d0b024f8340
|
Merge branch 'main' into sort
|
<0>:<add> if dist is None:
<del> if dist is None:
<1>:<add> dist = self.distribution
<del> dist = self.distribution
<2>:<add> if key is None:
<add> key = self._key
<add> if reverse is None:
<add> reverse = self._reverse
<add> identify_obj = {"File Signatures": {}, "Regexes": {}}
<del> identify_obj = {"File Signatures": {}, "Regexes":{}}
<3>:<add> search = []
<del> search = []
<4>:<add>
<add> if not only_text and os.path.isdir(text):
<add> # if input is a directory, recursively search for all of the files
<add> for myfile in glob.iglob(text + "**/**", recursive=True):
<add> if os.path.isfile(myfile):
<add> search.append(myfile)
<add> else:
<add> search = [text]
<add>
<add> for string in search:
<add> if not only_text and os.path.isfile(string):
<add> short_name = os.path.basename(string)
<add> magic_numbers = self._file_sig.open_binary_
|
# module: pywhat.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
<0> if dist is None:
<1> dist = self.distribution
<2> identify_obj = {"File Signatures": {}, "Regexes":{}}
<3> search = []
<4>
<5> if not only_text and os.path.isdir(text):
<6> # if input is a directory, recursively search for all of the files
<7> for myfile in glob.iglob(text + "**/**", recursive=True):
<8> if os.path.isfile(myfile):
<9> search.append(myfile)
<10> else:
<11> search = [text]
<12>
<13> for string in search:
<14> if not only_text and os.path.isfile(string):
<15> short_name = os.path.basename(string)
<16> magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
<17> text = self._file_sig.open_file_loc(string)
<18> text.append(short_name)
<19> regex = self._regex_id.check(text, dist)
<20> short_name = os.path.basename(string)
<21>
<22> if not magic_numbers:
<23> magic_numbers = self._file_sig.check_magic_nums(string)
<24>
<25> if magic_numbers:
<26> identify_obj["File Signatures"][short_name] = magic_numbers
<27> else:
<28> short_name = "text"
<29> regex = self._regex_id.check(search, dist)
<30>
<31> if regex:
<32> identify_obj["Regexes"][short_name] = regex</s>
|
===========below chunk 0===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 1
for key, value in identify_obj.items():
# if there are zero regex or file signature matches, set it to None
if len(identify_obj[key]) == 0:
identify_obj[key] = None
return identify_obj
===========unchanged ref 0===========
at: glob
iglob(pathname: AnyStr, *, recursive: bool=...) -> Iterator[AnyStr]
at: os.path
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
basename(p: _PathLike[AnyStr]) -> AnyStr
basename(p: AnyStr) -> AnyStr
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier.Identifier.__init__
self.distribution = distribution
self.distribution = Distribution()
self._regex_id = RegexIdentifier()
self._file_sig = FileSignatures()
at: pywhat.magic_numbers.FileSignatures
open_file_loc(file_loc)
open_binary_scan_magic_nums(file_loc)
check_magic_nums(text)
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: pywhat.identifier
+
+
class Identifier:
+ def __init__(
+ self,
+ *,
+ dist: Optional[Distribution] = None,
+ key: Callable = Keys.NONE,
+ reverse=False
+ ):
- def __init__(self, distribution: Optional[Distribution] = None):
+ if dist is None:
- if distribution is None:
+ self.distribution = Distribution()
- self.distribution = Distribution()
+ else:
- else:
+ self.distribution = dist
- self.distribution = distribution
+ self._regex_id = RegexIdentifier()
- self._regex_id = RegexIdentifier()
+ self._file_sig = FileSignatures()
- self._file_sig = FileSignatures()
+ self._name_that_hash = Nth()
- self._name_that_hash = Nth()
+ self._key = key
+ self._reverse = reverse
===========changed ref 1===========
# module: pywhat.helper
+ class Keys(Enum):
+ NAME = lambda match: match["Regex Pattern"]["Name"]
+ RARITY = lambda match: match["Regex Pattern"]["Rarity"]
+ MATCHED = lambda match: match["Matched"]
+ NONE = auto()
+
|
pywhat.what/What_Object.__init__
|
Modified
|
bee-san~pyWhat
|
aa61f3629db441cf4e0b0e65ab525d0b024f8340
|
Merge branch 'main' into sort
|
<0>:<add> self.id = identifier.Identifier(dist=distribution)
<del> self.id = identifier.Identifier(distribution)
|
# module: pywhat.what
class What_Object:
def __init__(self, distribution):
<0> self.id = identifier.Identifier(distribution)
<1>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: pywhat
pywhat_tags = AvailableTags().get_tags()
+ __all__ = ["Identifier", "Distribution", "pywhat_tags", "Keys"]
- __all__ = ["Identifier", "Distribution", "pywhat_tags"]
===========changed ref 1===========
# module: pywhat.helper
+ class Keys(Enum):
+ NAME = lambda match: match["Regex Pattern"]["Name"]
+ RARITY = lambda match: match["Regex Pattern"]["Rarity"]
+ MATCHED = lambda match: match["Matched"]
+ NONE = auto()
+
===========changed ref 2===========
# module: pywhat.identifier
+
+
class Identifier:
+ def __init__(
+ self,
+ *,
+ dist: Optional[Distribution] = None,
+ key: Callable = Keys.NONE,
+ reverse=False
+ ):
- def __init__(self, distribution: Optional[Distribution] = None):
+ if dist is None:
- if distribution is None:
+ self.distribution = Distribution()
- self.distribution = Distribution()
+ else:
- else:
+ self.distribution = dist
- self.distribution = distribution
+ self._regex_id = RegexIdentifier()
- self._regex_id = RegexIdentifier()
+ self._file_sig = FileSignatures()
- self._file_sig = FileSignatures()
+ self._name_that_hash = Nth()
- self._name_that_hash = Nth()
+ self._key = key
+ self._reverse = reverse
===========changed ref 3===========
# module: pywhat.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ if key is None:
+ key = self._key
+ if reverse is None:
+ reverse = self._reverse
+ identify_obj = {"File Signatures": {}, "Regexes": {}}
- identify_obj = {"File Signatures": {}, "Regexes":{}}
+ search = []
- search = []
+
+ if not only_text and os.path.isdir(text):
+ # if input is a directory, recursively search for all of the files
+ for myfile in glob.iglob(text + "**/**", recursive=True):
+ if os.path.isfile(myfile):
+ search.append(myfile)
+ else:
+ search = [text]
+
+ for string in search:
+ if not only_text and os.path.isfile(string):
+ short_name = os.path.basename(string)
+ magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
+ text = self._file_sig.open_file_loc(string)
+ text.append(short_name)
+ regex = self._regex_id.check(text, dist)
+ short_name = os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self</s>
===========changed ref 4===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 1
<s> os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self._file_sig.check_magic_nums(string)
+
+ if magic_numbers:
+ identify_obj["File Signatures"][short_name] = magic_numbers
+ else:
+ short_name = "text"
+ regex = self._regex_id.check(search, dist)
+
+ if regex:
+ identify_obj["Regexes"][short_name] = regex
+
+ for key_, value in identify_obj.items():
+ # if there are zero regex or file signature matches, set it to None
+ if len(identify_obj[key_]) == 0:
+ identify_obj[key_] = None
+
+ if key != Keys.NONE:
+ identify_obj["Regexes"][short_name] = sorted(
+ identify_obj["Regexes"][short_name], key=key, reverse=reverse
+ )
+
+ return identify_obj
- if not only_text and os.path.isdir(text):
- # if input is a directory, recursively search for all of the files
- for myfile in glob.iglob(text + "**/**", recursive=True):
- if os.path.isfile(myfile</s>
===========changed ref 5===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 2
<s> <del> search.append(myfile)
- else:
- search = [text]
-
- for string in search:
- if not only_text and os.path.isfile(string):
- short_name = os.path.basename(string)
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
- text = self._file_sig.open_file_loc(string)
- text.append(short_name)
- regex = self._regex_id.check(text, dist)
- short_name = os.path.basename(string)
-
- if not magic_numbers:
- magic_numbers = self._file_sig.check_magic_nums(string)
-
- if magic_numbers:
- identify_obj["File Signatures"][short_name] = magic_numbers
- else:
- short_name = "text"
- regex = self._regex_id.check(search, dist)
-
- if regex:
- identify_obj["Regexes"][short_name] = regex
-
- for key, value in identify_obj.items():
- # if there are zero regex or file signature matches, set it to None
- if len(identify_obj[key]) == 0:
- identify_obj[key] = None
-
- return identify_obj
-
|
tests.test_identifier/test_identifier_filtration
|
Modified
|
bee-san~pyWhat
|
aa61f3629db441cf4e0b0e65ab525d0b024f8340
|
Merge branch 'main' into sort
|
<0>:<add> filter = {"Tags": ["Password"]}
<del> filter = {"Tags": ["Password"]}
<1>:<add> r = identifier.Identifier(dist=Distribution(filter))
<del> r = identifier.Identifier(Distribution(filter))
<2>:<add> regexes = r.identify("fixtures/file")["Regexes"]["file"]
<del> regexes = r.identify('fixtures/file')["Regexes"]["file"]
<3>:<add> for regex in regexes:
<del> for regex in regexes:
<4>:<add> assert "Password" in regex["Regex Pattern"]["Tags"]
<del> assert "Password" in regex["Regex Pattern"]["Tags"]
|
# module: tests.test_identifier
+
+
def test_identifier_filtration():
<0> filter = {"Tags": ["Password"]}
<1> r = identifier.Identifier(Distribution(filter))
<2> regexes = r.identify('fixtures/file')["Regexes"]["file"]
<3> for regex in regexes:
<4> assert "Password" in regex["Regex Pattern"]["Tags"]
<5>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(text: str, only_text=False, dist: Distribution=None) -> dict
===========changed ref 0===========
# module: pywhat.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ if key is None:
+ key = self._key
+ if reverse is None:
+ reverse = self._reverse
+ identify_obj = {"File Signatures": {}, "Regexes": {}}
- identify_obj = {"File Signatures": {}, "Regexes":{}}
+ search = []
- search = []
+
+ if not only_text and os.path.isdir(text):
+ # if input is a directory, recursively search for all of the files
+ for myfile in glob.iglob(text + "**/**", recursive=True):
+ if os.path.isfile(myfile):
+ search.append(myfile)
+ else:
+ search = [text]
+
+ for string in search:
+ if not only_text and os.path.isfile(string):
+ short_name = os.path.basename(string)
+ magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
+ text = self._file_sig.open_file_loc(string)
+ text.append(short_name)
+ regex = self._regex_id.check(text, dist)
+ short_name = os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self</s>
===========changed ref 1===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 1
<s> os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self._file_sig.check_magic_nums(string)
+
+ if magic_numbers:
+ identify_obj["File Signatures"][short_name] = magic_numbers
+ else:
+ short_name = "text"
+ regex = self._regex_id.check(search, dist)
+
+ if regex:
+ identify_obj["Regexes"][short_name] = regex
+
+ for key_, value in identify_obj.items():
+ # if there are zero regex or file signature matches, set it to None
+ if len(identify_obj[key_]) == 0:
+ identify_obj[key_] = None
+
+ if key != Keys.NONE:
+ identify_obj["Regexes"][short_name] = sorted(
+ identify_obj["Regexes"][short_name], key=key, reverse=reverse
+ )
+
+ return identify_obj
- if not only_text and os.path.isdir(text):
- # if input is a directory, recursively search for all of the files
- for myfile in glob.iglob(text + "**/**", recursive=True):
- if os.path.isfile(myfile</s>
===========changed ref 2===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 2
<s> <del> search.append(myfile)
- else:
- search = [text]
-
- for string in search:
- if not only_text and os.path.isfile(string):
- short_name = os.path.basename(string)
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
- text = self._file_sig.open_file_loc(string)
- text.append(short_name)
- regex = self._regex_id.check(text, dist)
- short_name = os.path.basename(string)
-
- if not magic_numbers:
- magic_numbers = self._file_sig.check_magic_nums(string)
-
- if magic_numbers:
- identify_obj["File Signatures"][short_name] = magic_numbers
- else:
- short_name = "text"
- regex = self._regex_id.check(search, dist)
-
- if regex:
- identify_obj["Regexes"][short_name] = regex
-
- for key, value in identify_obj.items():
- # if there are zero regex or file signature matches, set it to None
- if len(identify_obj[key]) == 0:
- identify_obj[key] = None
-
- return identify_obj
-
===========changed ref 3===========
# module: pywhat.what
class What_Object:
def __init__(self, distribution):
+ self.id = identifier.Identifier(dist=distribution)
- self.id = identifier.Identifier(distribution)
===========changed ref 4===========
# module: pywhat
pywhat_tags = AvailableTags().get_tags()
+ __all__ = ["Identifier", "Distribution", "pywhat_tags", "Keys"]
- __all__ = ["Identifier", "Distribution", "pywhat_tags"]
===========changed ref 5===========
# module: pywhat.helper
+ class Keys(Enum):
+ NAME = lambda match: match["Regex Pattern"]["Name"]
+ RARITY = lambda match: match["Regex Pattern"]["Rarity"]
+ MATCHED = lambda match: match["Matched"]
+ NONE = auto()
+
===========changed ref 6===========
# module: pywhat.identifier
+
+
class Identifier:
+ def __init__(
+ self,
+ *,
+ dist: Optional[Distribution] = None,
+ key: Callable = Keys.NONE,
+ reverse=False
+ ):
- def __init__(self, distribution: Optional[Distribution] = None):
+ if dist is None:
- if distribution is None:
+ self.distribution = Distribution()
- self.distribution = Distribution()
+ else:
- else:
+ self.distribution = dist
- self.distribution = distribution
+ self._regex_id = RegexIdentifier()
- self._regex_id = RegexIdentifier()
+ self._file_sig = FileSignatures()
- self._file_sig = FileSignatures()
+ self._name_that_hash = Nth()
- self._name_that_hash = Nth()
+ self._key = key
+ self._reverse = reverse
|
tests.test_identifier/test_identifier_filtration2
|
Modified
|
bee-san~pyWhat
|
aa61f3629db441cf4e0b0e65ab525d0b024f8340
|
Merge branch 'main' into sort
|
<0>:<add> filter1 = {"ExcludeTags": ["Identifiers"]}
<del> filter1 = {"ExcludeTags": ["Identifiers"]}
<1>:<add> filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
<del> filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
<2>:<add> r = identifier.Identifier(dist=Distribution(filter1))
<del> r = identifier.Identifier(Distribution(filter1))
<3>:<add> regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
<del> regexes = r.identify('fixtures/file', dist=Distribution(filter2))["Regexes"]["file"]
<4>:<add> for regex in regexes:
<del> for regex in regexes:
<5>:<add> assert "Identifiers" in regex["Regex Pattern"]["Tags"]
<del> assert "Identifiers" in regex["Regex Pattern"]["Tags"]
<6>:<add> assert regex["Regex Pattern"]["Rarity"] >= 0.6
<del> assert regex["Regex Pattern"]["Rarity"] >= 0.6
|
# module: tests.test_identifier
+
+
def test_identifier_filtration2():
<0> filter1 = {"ExcludeTags": ["Identifiers"]}
<1> filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
<2> r = identifier.Identifier(Distribution(filter1))
<3> regexes = r.identify('fixtures/file', dist=Distribution(filter2))["Regexes"]["file"]
<4> for regex in regexes:
<5> assert "Identifiers" in regex["Regex Pattern"]["Tags"]
<6> assert regex["Regex Pattern"]["Rarity"] >= 0.6
<7>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(text: str, only_text=False, dist: Distribution=None) -> dict
===========changed ref 0===========
# module: pywhat.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ if key is None:
+ key = self._key
+ if reverse is None:
+ reverse = self._reverse
+ identify_obj = {"File Signatures": {}, "Regexes": {}}
- identify_obj = {"File Signatures": {}, "Regexes":{}}
+ search = []
- search = []
+
+ if not only_text and os.path.isdir(text):
+ # if input is a directory, recursively search for all of the files
+ for myfile in glob.iglob(text + "**/**", recursive=True):
+ if os.path.isfile(myfile):
+ search.append(myfile)
+ else:
+ search = [text]
+
+ for string in search:
+ if not only_text and os.path.isfile(string):
+ short_name = os.path.basename(string)
+ magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
+ text = self._file_sig.open_file_loc(string)
+ text.append(short_name)
+ regex = self._regex_id.check(text, dist)
+ short_name = os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self</s>
===========changed ref 1===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 1
<s> os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self._file_sig.check_magic_nums(string)
+
+ if magic_numbers:
+ identify_obj["File Signatures"][short_name] = magic_numbers
+ else:
+ short_name = "text"
+ regex = self._regex_id.check(search, dist)
+
+ if regex:
+ identify_obj["Regexes"][short_name] = regex
+
+ for key_, value in identify_obj.items():
+ # if there are zero regex or file signature matches, set it to None
+ if len(identify_obj[key_]) == 0:
+ identify_obj[key_] = None
+
+ if key != Keys.NONE:
+ identify_obj["Regexes"][short_name] = sorted(
+ identify_obj["Regexes"][short_name], key=key, reverse=reverse
+ )
+
+ return identify_obj
- if not only_text and os.path.isdir(text):
- # if input is a directory, recursively search for all of the files
- for myfile in glob.iglob(text + "**/**", recursive=True):
- if os.path.isfile(myfile</s>
===========changed ref 2===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 2
<s> <del> search.append(myfile)
- else:
- search = [text]
-
- for string in search:
- if not only_text and os.path.isfile(string):
- short_name = os.path.basename(string)
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
- text = self._file_sig.open_file_loc(string)
- text.append(short_name)
- regex = self._regex_id.check(text, dist)
- short_name = os.path.basename(string)
-
- if not magic_numbers:
- magic_numbers = self._file_sig.check_magic_nums(string)
-
- if magic_numbers:
- identify_obj["File Signatures"][short_name] = magic_numbers
- else:
- short_name = "text"
- regex = self._regex_id.check(search, dist)
-
- if regex:
- identify_obj["Regexes"][short_name] = regex
-
- for key, value in identify_obj.items():
- # if there are zero regex or file signature matches, set it to None
- if len(identify_obj[key]) == 0:
- identify_obj[key] = None
-
- return identify_obj
-
===========changed ref 3===========
# module: tests.test_identifier
+
+
def test_identifier_filtration():
+ filter = {"Tags": ["Password"]}
- filter = {"Tags": ["Password"]}
+ r = identifier.Identifier(dist=Distribution(filter))
- r = identifier.Identifier(Distribution(filter))
+ regexes = r.identify("fixtures/file")["Regexes"]["file"]
- regexes = r.identify('fixtures/file')["Regexes"]["file"]
+ for regex in regexes:
- for regex in regexes:
+ assert "Password" in regex["Regex Pattern"]["Tags"]
- assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 4===========
# module: pywhat.what
class What_Object:
def __init__(self, distribution):
+ self.id = identifier.Identifier(dist=distribution)
- self.id = identifier.Identifier(distribution)
===========changed ref 5===========
# module: pywhat
pywhat_tags = AvailableTags().get_tags()
+ __all__ = ["Identifier", "Distribution", "pywhat_tags", "Keys"]
- __all__ = ["Identifier", "Distribution", "pywhat_tags"]
===========changed ref 6===========
# module: pywhat.helper
+ class Keys(Enum):
+ NAME = lambda match: match["Regex Pattern"]["Name"]
+ RARITY = lambda match: match["Regex Pattern"]["Rarity"]
+ MATCHED = lambda match: match["Matched"]
+ NONE = auto()
+
|
tests.test_identifier/test_only_text
|
Modified
|
bee-san~pyWhat
|
aa61f3629db441cf4e0b0e65ab525d0b024f8340
|
Merge branch 'main' into sort
|
<0>:<add> r = identifier.Identifier()
<del> r = identifier.Identifier()
<1>:<add> out = r.identify("fixtures/file", only_text=True)
<del> out = r.identify("fixtures/file", True)
<2>:<add> assert None == out["Regexes"]
<del> assert None == out["Regexes"]
<3>:<add>
<add> out = r.identify("THM{7281j}}", only_text=True)
<add> assert "TryHackMe Flag Format" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
<4>:<del> out = r.identify("THM{7281j}}", True)
<5>:<del> assert "TryHackMe Flag Format" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
<6>:<del>
|
# module: tests.test_identifier
+
+
def test_only_text():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file", True)
<2> assert None == out["Regexes"]
<3>
<4> out = r.identify("THM{7281j}}", True)
<5> assert "TryHackMe Flag Format" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
<6>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier
Identifier(distribution: Optional[Distribution]=None)
at: pywhat.identifier.Identifier
identify(text: str, only_text=False, dist: Distribution=None) -> dict
===========changed ref 0===========
# module: pywhat.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
+ if dist is None:
- if dist is None:
+ dist = self.distribution
- dist = self.distribution
+ if key is None:
+ key = self._key
+ if reverse is None:
+ reverse = self._reverse
+ identify_obj = {"File Signatures": {}, "Regexes": {}}
- identify_obj = {"File Signatures": {}, "Regexes":{}}
+ search = []
- search = []
+
+ if not only_text and os.path.isdir(text):
+ # if input is a directory, recursively search for all of the files
+ for myfile in glob.iglob(text + "**/**", recursive=True):
+ if os.path.isfile(myfile):
+ search.append(myfile)
+ else:
+ search = [text]
+
+ for string in search:
+ if not only_text and os.path.isfile(string):
+ short_name = os.path.basename(string)
+ magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
+ text = self._file_sig.open_file_loc(string)
+ text.append(short_name)
+ regex = self._regex_id.check(text, dist)
+ short_name = os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self</s>
===========changed ref 1===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 1
<s> os.path.basename(string)
+
+ if not magic_numbers:
+ magic_numbers = self._file_sig.check_magic_nums(string)
+
+ if magic_numbers:
+ identify_obj["File Signatures"][short_name] = magic_numbers
+ else:
+ short_name = "text"
+ regex = self._regex_id.check(search, dist)
+
+ if regex:
+ identify_obj["Regexes"][short_name] = regex
+
+ for key_, value in identify_obj.items():
+ # if there are zero regex or file signature matches, set it to None
+ if len(identify_obj[key_]) == 0:
+ identify_obj[key_] = None
+
+ if key != Keys.NONE:
+ identify_obj["Regexes"][short_name] = sorted(
+ identify_obj["Regexes"][short_name], key=key, reverse=reverse
+ )
+
+ return identify_obj
- if not only_text and os.path.isdir(text):
- # if input is a directory, recursively search for all of the files
- for myfile in glob.iglob(text + "**/**", recursive=True):
- if os.path.isfile(myfile</s>
===========changed ref 2===========
<s>.identifier
+
+
class Identifier:
+
+ def identify(
+ self,
+ text: str,
+ *,
+ only_text=False,
+ dist: Distribution = None,
+ key: Optional[Callable] = None,
+ reverse: Optional[bool] = None
+ ) -> dict:
- def identify(self, text: str, only_text = False, dist: Distribution = None) -> dict:
# offset: 2
<s> <del> search.append(myfile)
- else:
- search = [text]
-
- for string in search:
- if not only_text and os.path.isfile(string):
- short_name = os.path.basename(string)
- magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
- text = self._file_sig.open_file_loc(string)
- text.append(short_name)
- regex = self._regex_id.check(text, dist)
- short_name = os.path.basename(string)
-
- if not magic_numbers:
- magic_numbers = self._file_sig.check_magic_nums(string)
-
- if magic_numbers:
- identify_obj["File Signatures"][short_name] = magic_numbers
- else:
- short_name = "text"
- regex = self._regex_id.check(search, dist)
-
- if regex:
- identify_obj["Regexes"][short_name] = regex
-
- for key, value in identify_obj.items():
- # if there are zero regex or file signature matches, set it to None
- if len(identify_obj[key]) == 0:
- identify_obj[key] = None
-
- return identify_obj
-
===========changed ref 3===========
# module: tests.test_identifier
+
+
def test_identifier_filtration():
+ filter = {"Tags": ["Password"]}
- filter = {"Tags": ["Password"]}
+ r = identifier.Identifier(dist=Distribution(filter))
- r = identifier.Identifier(Distribution(filter))
+ regexes = r.identify("fixtures/file")["Regexes"]["file"]
- regexes = r.identify('fixtures/file')["Regexes"]["file"]
+ for regex in regexes:
- for regex in regexes:
+ assert "Password" in regex["Regex Pattern"]["Tags"]
- assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 4===========
# module: tests.test_identifier
+
+
def test_identifier_filtration2():
+ filter1 = {"ExcludeTags": ["Identifiers"]}
- filter1 = {"ExcludeTags": ["Identifiers"]}
+ filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
- filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
+ r = identifier.Identifier(dist=Distribution(filter1))
- r = identifier.Identifier(Distribution(filter1))
+ regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify('fixtures/file', dist=Distribution(filter2))["Regexes"]["file"]
+ for regex in regexes:
- for regex in regexes:
+ assert "Identifiers" in regex["Regex Pattern"]["Tags"]
- assert "Identifiers" in regex["Regex Pattern"]["Tags"]
+ assert regex["Regex Pattern"]["Rarity"] >= 0.6
- assert regex["Regex Pattern"]["Rarity"] >= 0.6
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
a42cf5690126e454d8b5e9c31936d1d465e1a1b0
|
Merge branch 'main' into rec-fix
|
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<10> --include_tags list\n
<11> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<12> --exclude_tags list\n
<13> Exclude specified tags. List is a comma separated list.\n
<14>
<15> Examples:
<16>
<17> * what 'HTB{this is a flag}'
<18>
<19> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<20>
<21> * what -- 52.6169586, -1.9779857
<22>
<23> * what --rarity 0.6: [email protected]
<24>
<25> Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
<26>
<27>
<28> pyWhat can also search files or even a whole directory with recursion:
<29>
<30> * what 'secret.txt'
<31>
<32> * what 'this/is/a/path'
<33>
</s>
|
===========below chunk 0===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.printer
Printing()
at: pywhat.printer.Printing
pretty_print(text: dict)
at: pywhat.what
print_tags(ctx, opts, value)
parse_options(rarity, include_tags, exclude_tags)
What_Object(distribution)
at: pywhat.what.What_Object
what_is_this(text: str) -> dict
|
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
a42cf5690126e454d8b5e9c31936d1d465e1a1b0
|
Merge branch 'main' into rec-fix
|
<21>:<add> if os.path.isdir(text_input):
<del> if list(text["Regexes"].keys())[0] == text:
<22>:<add> # if input is a folder, add a filename column
<del> # if input was text, do not add a filename column
|
# module: pywhat.printer
class Printing:
+ def pretty_print(self, text: dict, text_input):
- def pretty_print(self, text: dict):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"] and text["Regexes"]:
<5> for key, value in text["File Signatures"].items():
<6> if value:
<7> to_out += "\n"
<8> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff]: [bold]{key}[/bold] with Magic Numbers {value['ISO 8859-1']}."
<9> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {value['Description']}."
<10> to_out += "\n"
<11>
<12> if text["Regexes"]:
<13> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<14> table = Table(
<15> show_header=True, header_style="bold #D7Afff", show_lines=True
<16> )
<17> table.add_column("Matched Text", overflow="fold")
<18> table.add_column("Identified as", overflow="fold")
<19> table.add_column("Description", overflow="fold")
<20>
<21> if list(text["Regexes"].keys())[0] == text:
<22> # if input was text, do not add a filename column
<23> table.add_column("Filename", overflow="fold")
<24>
<25> for key, value in text["Regexes"].items():
<26> for i in value:
<27> matched = i["Matched"]
<28> name = i["Regex Pattern"]["Name"]
<29> description = None
<30> filename = key
<31>
<32> if "URL" in i["Regex Pattern"]:
<33> description = (
<34> "Click here to analyse in the browser\n"
<35> + i["Regex Pattern"]["URL"]
<36> + matched.replace(" ", ""</s>
|
===========below chunk 0===========
# module: pywhat.printer
class Printing:
+ def pretty_print(self, text: dict, text_input):
- def pretty_print(self, text: dict):
# offset: 1
)
if i["Regex Pattern"]["Description"]:
if description:
description = (
description + "\n" + i["Regex Pattern"]["Description"]
)
else:
description = i["Regex Pattern"]["Description"]
if not description:
description = "None"
if key == "text":
table.add_row(
matched,
name,
description,
)
else:
table.add_row(
matched,
name,
description,
filename,
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
===========unchanged ref 0===========
at: os.path
isdir(s: AnyPath) -> bool
===========changed ref 0===========
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
--exclude_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- 52.6169586, -1.9779857
* what --rarity 0.6: [email protected]
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even a whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)</s>
===========changed ref 1===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s>
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
+ p.pretty_print(identified_output, text_input)
- p.pretty_print(identified_output)
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
9b65a5555640a7f1cc01e4a86625888a4864684d
|
Detection for credit cards with spaces and more regex
|
<23>:<add> * what --rarity 0.6: '[email protected]'
<del> * what --rarity 0.6: [email protected]
|
<s>Show available tags and exit.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<10> --include_tags list\n
<11> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<12> --exclude_tags list\n
<13> Exclude specified tags. List is a comma separated list.\n
<14>
<15> Examples:
<16>
<17> * what 'HTB{this is a flag}'
<18>
<19> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<20>
<21> * what -- 52.6169586, -1.9779857
<22>
<23> * what --rarity 0.6: [email protected]
<24>
<25> Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
<26>
<27>
<28> pyWhat can also search files or even a whole directory with recursion:
<29>
<30> * what 'secret.txt'
<31>
<32> * what 'this/is/a/path'
<33>
</s>
|
===========below chunk 0===========
<s>.")
@click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output, text_input)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.printer
Printing()
at: pywhat.printer.Printing
pretty_print(text: dict, text_input)
at: pywhat.what
print_tags(ctx, opts, value)
parse_options(rarity, include_tags, exclude_tags)
What_Object(distribution)
at: pywhat.what.What_Object
what_is_this(text: str) -> dict
|
pywhat.distribution/Distribution.__init__
|
Modified
|
bee-san~pyWhat
|
6da099f34317154b35ae4dae68bf19a600e27efa
|
Changed default rarity to 0.1:1, updated docs and tests
|
<6>:<add> self._dict["ExcludeTags"] = CaseInsensitiveSet(
<add> filters_dict.setdefault("ExcludeTags", set())
<add> )
<add> # We have regex with 0 rarity which trip false positive alarms all the time
<del> self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
<7>:<add> self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0.1)
<del> self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
<9>:<add> if not self._dict["Tags"].issubset(tags) or not self._dict[
<del> if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
<10>:<add> "ExcludeTags"
<add> ].issubset(tags):
|
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
<0> tags = CaseInsensitiveSet(AvailableTags().get_tags())
<1> self._dict = dict()
<2> if filters_dict is None:
<3> filters_dict = dict()
<4>
<5> self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
<6> self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
<7> self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
<8> self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
<9> if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
<10> raise InvalidTag("Passed filter contains tags that are not used by 'what'")
<11>
<12> self._regexes = load_regexes()
<13> self._filter()
<14>
|
===========unchanged ref 0===========
at: pywhat.helper
AvailableTags()
CaseInsensitiveSet(iterable=None)
at: pywhat.helper.AvailableTags
get_tags()
|
pywhat.what/parse_options
|
Modified
|
bee-san~pyWhat
|
6da099f34317154b35ae4dae68bf19a600e27efa
|
Changed default rarity to 0.1:1, updated docs and tests
|
<15>:<add> filter["Tags"] = list(map(str.strip, include_tags.split(",")))
<del> filter["Tags"] = list(map(str.strip, include_tags.split(',')))
<17>:<add> filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(",")))
<del> filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
<22>:<add> print(
<add> "Passed tags are not valid.\n"
<del> print("Passed tags are not valid.\n" \
<23>:<add> "You can check available tags by using: 'pywhat --tags'"
<del> "You can check available tags by using: 'pywhat --tags'")
<24>:<add> )
|
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
<0> filter = dict()
<1> if rarity is not None:
<2> rarities = rarity.split(":")
<3> if len(rarities) != 2:
<4> print("Invalid rarity range format ('min:max' expected)")
<5> sys.exit(1)
<6> try:
<7> if not rarities[0].isspace() and rarities[0]:
<8> filter["MinRarity"] = float(rarities[0])
<9> if not rarities[1].isspace() and rarities[1]:
<10> filter["MaxRarity"] = float(rarities[1])
<11> except ValueError:
<12> print("Invalid rarity argument (float expected)")
<13> sys.exit(1)
<14> if include_tags is not None:
<15> filter["Tags"] = list(map(str.strip, include_tags.split(',')))
<16> if exclude_tags is not None:
<17> filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
<18>
<19> try:
<20> distribution = Distribution(filter)
<21> except InvalidTag:
<22> print("Passed tags are not valid.\n" \
<23> "You can check available tags by using: 'pywhat --tags'")
<24> sys.exit(1)
<25>
<26> return distribution
<27>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.helper
InvalidTag(*args: object)
at: sys
exit(status: object=..., /) -> NoReturn
===========changed ref 0===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
tags = CaseInsensitiveSet(AvailableTags().get_tags())
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(
+ filters_dict.setdefault("ExcludeTags", set())
+ )
+ # We have regex with 0 rarity which trip false positive alarms all the time
- self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
+ self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0.1)
- self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
+ if not self._dict["Tags"].issubset(tags) or not self._dict[
- if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
+ "ExcludeTags"
+ ].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
6da099f34317154b35ae4dae68bf19a600e27efa
|
Changed default rarity to 0.1:1, updated docs and tests
|
<9>:<add> Rarity is how unlikely something is to be a false-positive. The higher the number, the more unlikely.\n
<10>:<add> Note: PyWhat by default has a rarity of 0.1. To see all matches, with many potential false positives use `0:`.\n
<21>:<add> * what -- '52.6169586, -1.9779857'
<del> * what -- 52.6169586, -1.9779857
<24>:<add>
<add> * what --rarity 0: --include_tags "credentials, username, password" --exclude_tags "aws, credentials" 'James:SecretPassword'
|
<s> available tags and exit.")
- @click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<10> --include_tags list\n
<11> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<12> --exclude_tags list\n
<13> Exclude specified tags. List is a comma separated list.\n
<14>
<15> Examples:
<16>
<17> * what 'HTB{this is a flag}'
<18>
<19> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<20>
<21> * what -- 52.6169586, -1.9779857
<22>
<23> * what --rarity 0.6: '[email protected]'
<24>
<25> Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
<26>
<27>
<28> pyWhat can also search files or even a whole directory with recursion:
<29>
<30> * what 'secret.txt'
<31>
<32> * what 'this/is/a/path'
</s>
|
===========below chunk 0===========
<s>)
- @click.option("-r", "--rarity", help="Filter by rarity. This is in the range of 0:1. To filter only items past 0.5, use 0.5: with the colon on the end.")
@click.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
"""
what_obj = What_Object(
parse_options(rarity, include_tags, exclude_tags)
)
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output, text_input)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.what
print_tags(ctx, opts, value)
at: pywhat.what.parse_options
distribution = Distribution(filter)
===========changed ref 0===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
+ filter["Tags"] = list(map(str.strip, include_tags.split(",")))
- filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
+ filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(",")))
- filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
try:
distribution = Distribution(filter)
except InvalidTag:
+ print(
+ "Passed tags are not valid.\n"
- print("Passed tags are not valid.\n" \
+ "You can check available tags by using: 'pywhat --tags'"
- "You can check available tags by using: 'pywhat --tags'")
+ )
sys.exit(1)
return distribution
===========changed ref 1===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
tags = CaseInsensitiveSet(AvailableTags().get_tags())
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(
+ filters_dict.setdefault("ExcludeTags", set())
+ )
+ # We have regex with 0 rarity which trip false positive alarms all the time
- self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
+ self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0.1)
- self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
+ if not self._dict["Tags"].issubset(tags) or not self._dict[
- if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
+ "ExcludeTags"
+ ].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
6da099f34317154b35ae4dae68bf19a600e27efa
|
Changed default rarity to 0.1:1, updated docs and tests
|
<32>:<add> if "URL" in i["Regex Pattern"] and i["Regex Pattern"]["URL"]:
<del> if "URL" in i["Regex Pattern"]:
|
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict, text_input):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"] and text["Regexes"]:
<5> for key, value in text["File Signatures"].items():
<6> if value:
<7> to_out += "\n"
<8> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff]: [bold]{key}[/bold] with Magic Numbers {value['ISO 8859-1']}."
<9> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {value['Description']}."
<10> to_out += "\n"
<11>
<12> if text["Regexes"]:
<13> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<14> table = Table(
<15> show_header=True, header_style="bold #D7Afff", show_lines=True
<16> )
<17> table.add_column("Matched Text", overflow="fold")
<18> table.add_column("Identified as", overflow="fold")
<19> table.add_column("Description", overflow="fold")
<20>
<21> if os.path.isdir(text_input):
<22> # if input is a folder, add a filename column
<23> table.add_column("Filename", overflow="fold")
<24>
<25> for key, value in text["Regexes"].items():
<26> for i in value:
<27> matched = i["Matched"]
<28> name = i["Regex Pattern"]["Name"]
<29> description = None
<30> filename = key
<31>
<32> if "URL" in i["Regex Pattern"]:
<33> description = (
<34> "Click here to analyse in the browser\n"
<35> + i["Regex Pattern"]["URL"]
<36> + matched.replace(" ", "")
<37> )
<38>
<39> if i["Regex Pattern"]["Description"]:</s>
|
===========below chunk 0===========
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict, text_input):
# offset: 1
description = (
description + "\n" + i["Regex Pattern"]["Description"]
)
else:
description = i["Regex Pattern"]["Description"]
if not description:
description = "None"
if os.path.isdir(text_input):
table.add_row(
matched,
name,
description,
filename,
)
else:
table.add_row(
matched,
name,
description,
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
===========unchanged ref 0===========
at: os.path
isdir(s: AnyPath) -> bool
===========changed ref 0===========
# module: tests.test_click
+
+
+ def test_key_value_min_rarity_0_2():
+ runner = CliRunner()
+ result = runner.invoke(main, ["--rarity", "0:", "key: value"])
+ assert result.exit_code == 0
+ assert re.findall("Key:Value", str(result.output))
+
===========changed ref 1===========
# module: tests.test_click
+
+
+ def test_key_value_min_rarity_0_1():
+ runner = CliRunner()
+ result = runner.invoke(main, ["--rarity", "0:", "key : value"])
+ assert result.exit_code == 0
+ assert re.findall("Key:Value", str(result.output))
+
===========changed ref 2===========
# module: tests.test_click
+
+
+ def test_key_value_min_rarity_0():
+ runner = CliRunner()
+ result = runner.invoke(main, ["--rarity", "0:", "key:value"])
+ assert result.exit_code == 0
+ assert re.findall("Key:Value", str(result.output))
+
===========changed ref 3===========
# module: pywhat.distribution
class Distribution:
def __init__(self, filters_dict: Optional[dict] = None):
tags = CaseInsensitiveSet(AvailableTags().get_tags())
self._dict = dict()
if filters_dict is None:
filters_dict = dict()
self._dict["Tags"] = CaseInsensitiveSet(filters_dict.setdefault("Tags", tags))
+ self._dict["ExcludeTags"] = CaseInsensitiveSet(
+ filters_dict.setdefault("ExcludeTags", set())
+ )
+ # We have regex with 0 rarity which trip false positive alarms all the time
- self._dict["ExcludeTags"] = CaseInsensitiveSet(filters_dict.setdefault("ExcludeTags", set()))
+ self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0.1)
- self._dict["MinRarity"] = filters_dict.setdefault("MinRarity", 0)
self._dict["MaxRarity"] = filters_dict.setdefault("MaxRarity", 1)
+ if not self._dict["Tags"].issubset(tags) or not self._dict[
- if not self._dict["Tags"].issubset(tags) or not self._dict["ExcludeTags"].issubset(tags):
+ "ExcludeTags"
+ ].issubset(tags):
raise InvalidTag("Passed filter contains tags that are not used by 'what'")
self._regexes = load_regexes()
self._filter()
===========changed ref 4===========
# module: pywhat.what
def parse_options(rarity, include_tags, exclude_tags):
filter = dict()
if rarity is not None:
rarities = rarity.split(":")
if len(rarities) != 2:
print("Invalid rarity range format ('min:max' expected)")
sys.exit(1)
try:
if not rarities[0].isspace() and rarities[0]:
filter["MinRarity"] = float(rarities[0])
if not rarities[1].isspace() and rarities[1]:
filter["MaxRarity"] = float(rarities[1])
except ValueError:
print("Invalid rarity argument (float expected)")
sys.exit(1)
if include_tags is not None:
+ filter["Tags"] = list(map(str.strip, include_tags.split(",")))
- filter["Tags"] = list(map(str.strip, include_tags.split(',')))
if exclude_tags is not None:
+ filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(",")))
- filter["ExcludeTags"] = list(map(str.strip, exclude_tags.split(',')))
try:
distribution = Distribution(filter)
except InvalidTag:
+ print(
+ "Passed tags are not valid.\n"
- print("Passed tags are not valid.\n" \
+ "You can check available tags by using: 'pywhat --tags'"
- "You can check available tags by using: 'pywhat --tags'")
+ )
sys.exit(1)
return distribution
|
pywhat.identifier/Identifier.identify
|
Modified
|
bee-san~pyWhat
|
a42781ee44b37a61993ab14e97e65fac87b5da7d
|
Merge branch 'main' into print-folder
|
<11>:<add> for myfile in glob.iglob(text + "/**", recursive=True):
<del> for myfile in glob.iglob(text + "**/**", recursive=True):
<19>:<add> if os.path.isdir(text):
<add> short_name = string.replace(os.path.abspath(text), "")
<add> else:
<add> short_name = os.path.basename(string)
<del> short_name = os.path.basename(string)
<20>:<add>
<21>:<add> contents = self._file_sig.open_file_loc(string)
<del> text = self._file_sig.open_file_loc(string)
<22>:<add> contents.append(os.path.basename(string))
<del> text.append(short_name)
<23>:<add> regex = self._regex_id.check(contents, dist)
<del> regex = self._regex_id.check(text, dist)
<24>:<del> short_name = os.path.basename(string)
|
# module: pywhat.identifier
class Identifier:
def identify(
self,
text: str,
*,
only_text=False,
dist: Distribution = None,
key: Optional[Callable] = None,
reverse: Optional[bool] = None
) -> dict:
<0> if dist is None:
<1> dist = self.distribution
<2> if key is None:
<3> key = self._key
<4> if reverse is None:
<5> reverse = self._reverse
<6> identify_obj = {"File Signatures": {}, "Regexes": {}}
<7> search = []
<8>
<9> if not only_text and os.path.isdir(text):
<10> # if input is a directory, recursively search for all of the files
<11> for myfile in glob.iglob(text + "**/**", recursive=True):
<12> if os.path.isfile(myfile):
<13> search.append(myfile)
<14> else:
<15> search = [text]
<16>
<17> for string in search:
<18> if not only_text and os.path.isfile(string):
<19> short_name = os.path.basename(string)
<20> magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
<21> text = self._file_sig.open_file_loc(string)
<22> text.append(short_name)
<23> regex = self._regex_id.check(text, dist)
<24> short_name = os.path.basename(string)
<25>
<26> if not magic_numbers:
<27> magic_numbers = self._file_sig.check_magic_nums(string)
<28>
<29> if magic_numbers:
<30> identify_obj["File Signatures"][short_name] = magic_numbers
<31> else:
<32> short_name = "text"
<33> regex = self._regex_id.check(search, dist</s>
|
===========below chunk 0===========
# module: pywhat.identifier
class Identifier:
def identify(
self,
text: str,
*,
only_text=False,
dist: Distribution = None,
key: Optional[Callable] = None,
reverse: Optional[bool] = None
) -> dict:
# offset: 1
if regex:
identify_obj["Regexes"][short_name] = regex
for key_, value in identify_obj.items():
# if there are zero regex or file signature matches, set it to None
if len(identify_obj[key_]) == 0:
identify_obj[key_] = None
if key != Keys.NONE:
identify_obj["Regexes"][short_name] = sorted(
identify_obj["Regexes"][short_name], key=key, reverse=reverse
)
return identify_obj
===========unchanged ref 0===========
at: glob
iglob(pathname: AnyStr, *, recursive: bool=...) -> Iterator[AnyStr]
at: os.path
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
basename(p: _PathLike[AnyStr]) -> AnyStr
basename(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.helper
Keys()
at: pywhat.identifier.Identifier.__init__
self.distribution = Distribution()
self.distribution = dist
self._regex_id = RegexIdentifier()
self._file_sig = FileSignatures()
self._key = key
self._reverse = reverse
at: pywhat.magic_numbers.FileSignatures
open_file_loc(file_loc)
open_binary_scan_magic_nums(file_loc)
check_magic_nums(text)
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
at: typing
Callable = _CallableType(collections.abc.Callable, 2)
|
pywhat.printer/Printing.pretty_print
|
Modified
|
bee-san~pyWhat
|
a42781ee44b37a61993ab14e97e65fac87b5da7d
|
Merge branch 'main' into print-folder
|
<23>:<add> table.add_column("File", overflow="fold")
<del> table.add_column("Filename", overflow="fold")
|
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict, text_input):
<0> console = Console(highlight=False)
<1>
<2> to_out = ""
<3>
<4> if text["File Signatures"] and text["Regexes"]:
<5> for key, value in text["File Signatures"].items():
<6> if value:
<7> to_out += "\n"
<8> to_out += f"[bold #D7Afff]File Identified[/bold #D7Afff]: [bold]{key}[/bold] with Magic Numbers {value['ISO 8859-1']}."
<9> to_out += f"\n[bold #D7Afff]File Description:[/bold #D7Afff] {value['Description']}."
<10> to_out += "\n"
<11>
<12> if text["Regexes"]:
<13> to_out += "\n[bold #D7Afff]Possible Identification[/bold #D7Afff]"
<14> table = Table(
<15> show_header=True, header_style="bold #D7Afff", show_lines=True
<16> )
<17> table.add_column("Matched Text", overflow="fold")
<18> table.add_column("Identified as", overflow="fold")
<19> table.add_column("Description", overflow="fold")
<20>
<21> if os.path.isdir(text_input):
<22> # if input is a folder, add a filename column
<23> table.add_column("Filename", overflow="fold")
<24>
<25> for key, value in text["Regexes"].items():
<26> for i in value:
<27> matched = i["Matched"]
<28> name = i["Regex Pattern"]["Name"]
<29> description = None
<30> filename = key
<31>
<32> if "URL" in i["Regex Pattern"] and i["Regex Pattern"]["URL"]:
<33> description = (
<34> "Click here to analyse in the browser\n"
<35> + i["Regex Pattern"]["URL"]
<36> + matched.replace(" ", "")
<37> )
<38>
<39> if</s>
|
===========below chunk 0===========
# module: pywhat.printer
class Printing:
def pretty_print(self, text: dict, text_input):
# offset: 1
if description:
description = (
description + "\n" + i["Regex Pattern"]["Description"]
)
else:
description = i["Regex Pattern"]["Description"]
if not description:
description = "None"
if os.path.isdir(text_input):
table.add_row(
matched,
name,
description,
filename,
)
else:
table.add_row(
matched,
name,
description,
)
console.print(to_out, table)
if to_out == "":
console.print("Nothing found!")
"""
# This is commented out because there's too many possible hash idenfications
# This is fixed by https://github.com/HashPals/Name-That-Hash/issues/89
if text["Hashes"]:
to_out = "\n[bold #D7Afff]Hashes Identified[/bold #D7Afff]"
table = Table(
show_header=True, header_style="bold #D7Afff", show_lines=True
)
table.add_column("Matched Text")
table.add_column("Possible Hash Type")
table.add_column("Description")
for hash_text in text["Hashes"].keys():
for types in text["Hashes"][hash_text]:
table.add_row(
hash_text,
types["name"],
types["description"],
)
console.print(to_out, table)
"""
===========unchanged ref 0===========
at: os.path
isdir(s: AnyPath) -> bool
===========changed ref 0===========
# module: pywhat.identifier
class Identifier:
def identify(
self,
text: str,
*,
only_text=False,
dist: Distribution = None,
key: Optional[Callable] = None,
reverse: Optional[bool] = None
) -> dict:
if dist is None:
dist = self.distribution
if key is None:
key = self._key
if reverse is None:
reverse = self._reverse
identify_obj = {"File Signatures": {}, "Regexes": {}}
search = []
if not only_text and os.path.isdir(text):
# if input is a directory, recursively search for all of the files
+ for myfile in glob.iglob(text + "/**", recursive=True):
- for myfile in glob.iglob(text + "**/**", recursive=True):
if os.path.isfile(myfile):
search.append(myfile)
else:
search = [text]
for string in search:
if not only_text and os.path.isfile(string):
+ if os.path.isdir(text):
+ short_name = string.replace(os.path.abspath(text), "")
+ else:
+ short_name = os.path.basename(string)
- short_name = os.path.basename(string)
+
magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
+ contents = self._file_sig.open_file_loc(string)
- text = self._file_sig.open_file_loc(string)
+ contents.append(os.path.basename(string))
- text.append(short_name)
+ regex = self._regex_id.check(contents, dist)
- regex = self._regex_id.check(text, dist</s>
===========changed ref 1===========
# module: pywhat.identifier
class Identifier:
def identify(
self,
text: str,
*,
only_text=False,
dist: Distribution = None,
key: Optional[Callable] = None,
reverse: Optional[bool] = None
) -> dict:
# offset: 1
<s> = self._regex_id.check(contents, dist)
- regex = self._regex_id.check(text, dist)
- short_name = os.path.basename(string)
if not magic_numbers:
magic_numbers = self._file_sig.check_magic_nums(string)
if magic_numbers:
identify_obj["File Signatures"][short_name] = magic_numbers
else:
short_name = "text"
regex = self._regex_id.check(search, dist)
if regex:
identify_obj["Regexes"][short_name] = regex
for key_, value in identify_obj.items():
# if there are zero regex or file signature matches, set it to None
if len(identify_obj[key_]) == 0:
identify_obj[key_] = None
if key != Keys.NONE:
identify_obj["Regexes"][short_name] = sorted(
identify_obj["Regexes"][short_name], key=key, reverse=reverse
)
return identify_obj
|
pywhat.identifier/Identifier.identify
|
Modified
|
bee-san~pyWhat
|
bae223cc2d112406910128f01ed9c853accdf49d
|
Added a test
|
<13>:<add> search.append(os.path.abspath(myfile))
<del> search.append(myfile)
|
# module: pywhat.identifier
class Identifier:
def identify(
self,
text: str,
*,
only_text=False,
dist: Distribution = None,
key: Optional[Callable] = None,
reverse: Optional[bool] = None
) -> dict:
<0> if dist is None:
<1> dist = self.distribution
<2> if key is None:
<3> key = self._key
<4> if reverse is None:
<5> reverse = self._reverse
<6> identify_obj = {"File Signatures": {}, "Regexes": {}}
<7> search = []
<8>
<9> if not only_text and os.path.isdir(text):
<10> # if input is a directory, recursively search for all of the files
<11> for myfile in glob.iglob(text + "/**", recursive=True):
<12> if os.path.isfile(myfile):
<13> search.append(myfile)
<14> else:
<15> search = [text]
<16>
<17> for string in search:
<18> if not only_text and os.path.isfile(string):
<19> if os.path.isdir(text):
<20> short_name = string.replace(os.path.abspath(text), "")
<21> else:
<22> short_name = os.path.basename(string)
<23>
<24> magic_numbers = self._file_sig.open_binary_scan_magic_nums(string)
<25> contents = self._file_sig.open_file_loc(string)
<26> contents.append(os.path.basename(string))
<27> regex = self._regex_id.check(contents, dist)
<28>
<29> if not magic_numbers:
<30> magic_numbers = self._file_sig.check_magic_nums(string)
<31>
<32> if magic_numbers:
<33> identify_obj["File Signatures"][short_name] = magic_numbers</s>
|
===========below chunk 0===========
# module: pywhat.identifier
class Identifier:
def identify(
self,
text: str,
*,
only_text=False,
dist: Distribution = None,
key: Optional[Callable] = None,
reverse: Optional[bool] = None
) -> dict:
# offset: 1
else:
short_name = "text"
regex = self._regex_id.check(search, dist)
if regex:
identify_obj["Regexes"][short_name] = regex
for key_, value in identify_obj.items():
# if there are zero regex or file signature matches, set it to None
if len(identify_obj[key_]) == 0:
identify_obj[key_] = None
if key != Keys.NONE:
identify_obj["Regexes"][short_name] = sorted(
identify_obj["Regexes"][short_name], key=key, reverse=reverse
)
return identify_obj
===========unchanged ref 0===========
at: glob
iglob(pathname: AnyStr, *, recursive: bool=...) -> Iterator[AnyStr]
at: os.path
isfile(path: AnyPath) -> bool
isdir(s: AnyPath) -> bool
basename(p: _PathLike[AnyStr]) -> AnyStr
basename(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.helper
Keys()
at: pywhat.identifier.Identifier.__init__
self.distribution = Distribution()
self.distribution = dist
self._regex_id = RegexIdentifier()
self._file_sig = FileSignatures()
self._key = key
self._reverse = reverse
at: pywhat.magic_numbers.FileSignatures
open_file_loc(file_loc)
open_binary_scan_magic_nums(file_loc)
check_magic_nums(text)
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
at: typing
Callable = _CallableType(collections.abc.Callable, 2)
|
tests.test_identifier/test_recursion
|
Modified
|
bee-san~pyWhat
|
854a088b1109e27c99f4b668a5497dc3accabcea
|
Updated tests, so they also work on Windows
|
<2>:<add> assert "ETH" in out["Regexes"][list(out["Regexes"].keys())[1]][0]["Regex Pattern"]["Name"]
<del> assert "ETH" in out["Regexes"]["/file"][0]["Regex Pattern"]["Name"]
<4>:<add> assert "URL" in out["Regexes"][list(out["Regexes"].keys())[0]][0]["Regex Pattern"]["Name"]
<del> assert "URL" in out["Regexes"]["/test/file"][0]["Regex Pattern"]["Name"]
|
# module: tests.test_identifier
def test_recursion():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures")
<2> assert "ETH" in out["Regexes"]["/file"][0]["Regex Pattern"]["Name"]
<3>
<4> assert "URL" in out["Regexes"]["/test/file"][0]["Regex Pattern"]["Name"]
<5>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
|
tests.test_identifier/test_recursion
|
Modified
|
bee-san~pyWhat
|
1259f12a9edbca33a903c0cc5ae09669360a0777
|
Updated tests
|
<2>:<del> assert "ETH" in out["Regexes"][list(out["Regexes"].keys())[1]][0]["Regex Pattern"]["Name"]
<4>:<add> for file in list(out["Regexes"].keys()):
<add> if "/file" == file or r"\file" == file:
<add> assert "ETH" in out["Regexes"][file][0]["Regex Pattern"]["Name"]
<add>
<add> elif "/tests/file" == file or r"\tests\file" == file:
<add> assert "URL" in out["Regexes"][file][0]["Regex Pattern"]["Name"]
<del> assert "URL" in out["Regexes"][list(out["Regexes"].keys())[0]][0]["Regex Pattern"]["Name"]
|
# module: tests.test_identifier
def test_recursion():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures")
<2> assert "ETH" in out["Regexes"][list(out["Regexes"].keys())[1]][0]["Regex Pattern"]["Name"]
<3>
<4> assert "URL" in out["Regexes"][list(out["Regexes"].keys())[0]][0]["Regex Pattern"]["Name"]
<5>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
|
pywhat.what/What_Object.what_is_this
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<3>:<add> return self.id.identify(text, only_text=False)
<del> return self.id.identify(text)
|
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
<0> """
<1> Returns a Python dictionary of everything that has been identified
<2> """
<3> return self.id.identify(text)
<4>
|
===========unchanged ref 0===========
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: pywhat.what.What_Object.__init__
self.id = identifier.Identifier(dist=distribution)
|
tests.test_identifier/test_identifier_works2
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False)
<del> out = r.identify("fixtures/file")
|
# module: tests.test_identifier
def test_identifier_works2():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file")
<2> assert (
<3> "Ethereum (ETH) Wallet Address"
<4> in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
<5> )
<6>
|
===========unchanged ref 0===========
at: tests.test_identifier.test_check_keys_in_json
database = json.load(file)
===========changed ref 0===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 1===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_works3
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False)
<del> out = r.identify("fixtures/file")
|
# module: tests.test_identifier
def test_identifier_works3():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file")
<2> assert (
<3> "Dogecoin (DOGE) Wallet Address"
<4> in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
<5> )
<6>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: tests.test_identifier.test_check_keys_in_json
keys = list(entry.keys())
entry_name = entry["Name"]
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 1===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 2===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_filtration
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<2>:<add> regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
<del> regexes = r.identify("fixtures/file")["Regexes"]["file"]
|
# module: tests.test_identifier
def test_identifier_filtration():
<0> filter = {"Tags": ["Password"]}
<1> r = identifier.Identifier(dist=Distribution(filter))
<2> regexes = r.identify("fixtures/file")["Regexes"]["file"]
<3> for regex in regexes:
<4> assert "Password" in regex["Regex Pattern"]["Tags"]
<5>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: tests.test_identifier.test_identifier_works
out = r.identify("DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o")
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 2===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 3===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_filtration2
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<3>:<add> regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
<del> regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
|
# module: tests.test_identifier
def test_identifier_filtration2():
<0> filter1 = {"ExcludeTags": ["Identifiers"]}
<1> filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
<2> r = identifier.Identifier(dist=Distribution(filter1))
<3> regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
<4> for regex in regexes:
<5> assert "Identifiers" in regex["Regex Pattern"]["Tags"]
<6> assert regex["Regex Pattern"]["Rarity"] >= 0.6
<7>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: tests.test_identifier.test_identifier_works2
out = r.identify("fixtures/file", only_text=False)
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 3===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 4===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_sorting
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False)
<del> out = r.identify("fixtures/file")
|
# module: tests.test_identifier
def test_identifier_sorting():
<0> r = identifier.Identifier(key=Keys.NAME, reverse=True)
<1> out = r.identify("fixtures/file")
<2> assert out["Regexes"]["file"]
<3>
|
===========unchanged ref 0===========
at: tests.test_identifier.test_identifier_works3
out = r.identify("fixtures/file", only_text=False)
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 4===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 5===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_sorting2
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
<del> out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
|
# module: tests.test_identifier
def test_identifier_sorting2():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
<2> prev = None
<3> for match in out["Regexes"]["file"]:
<4> if prev is not None:
<5> assert prev >= match["Regex Pattern"]["Rarity"]
<6> prev = match["Regex Pattern"]["Rarity"]
<7>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: tests.test_identifier.test_identifier_filtration
filter = {"Tags": ["Password"]}
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 5===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 6===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_sorting3
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False, key=Keys.NAME)
<del> out = r.identify("fixtures/file", key=Keys.NAME)
|
# module: tests.test_identifier
def test_identifier_sorting3():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file", key=Keys.NAME)
<2> prev = None
<3> for match in out["Regexes"]["file"]:
<4> if prev is not None:
<5> assert prev <= match["Regex Pattern"]["Name"]
<6> prev = match["Regex Pattern"]["Name"]
<7>
|
===========unchanged ref 0===========
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.helper
Keys()
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: tests.test_identifier.test_identifier_filtration2
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_sorting2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
- out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Rarity"]
prev = match["Regex Pattern"]["Rarity"]
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 5===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 6===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 7===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_sorting4
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False)
<del> out = r.identify("fixtures/file")
|
# module: tests.test_identifier
def test_identifier_sorting4():
<0> r = identifier.Identifier(key=Keys.NAME, reverse=True)
<1> out = r.identify("fixtures/file")
<2> prev = None
<3> for match in out["Regexes"]["file"]:
<4> if prev is not None:
<5> assert prev >= match["Regex Pattern"]["Name"]
<6> prev = match["Regex Pattern"]["Name"]
<7>
|
===========unchanged ref 0===========
at: pywhat.helper
Keys()
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_sorting3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.NAME)
- out = r.identify("fixtures/file", key=Keys.NAME)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_sorting2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
- out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Rarity"]
prev = match["Regex Pattern"]["Rarity"]
===========changed ref 5===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 6===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 7===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 8===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_sorting5
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED)
<del> out = r.identify("fixtures/file", key=Keys.MATCHED)
|
# module: tests.test_identifier
def test_identifier_sorting5():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file", key=Keys.MATCHED)
<2> prev = None
<3> for match in out["Regexes"]["file"]:
<4> if prev is not None:
<5> assert prev <= match["Matched"]
<6> prev = match["Matched"]
<7>
|
===========unchanged ref 0===========
at: pywhat.helper
Keys()
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_sorting4():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_sorting3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.NAME)
- out = r.identify("fixtures/file", key=Keys.NAME)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 5===========
# module: tests.test_identifier
def test_identifier_sorting2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
- out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Rarity"]
prev = match["Regex Pattern"]["Rarity"]
===========changed ref 6===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 7===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 8===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 9===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_identifier_sorting6
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED, reverse=True)
<del> out = r.identify("fixtures/file", key=Keys.MATCHED, reverse=True)
|
# module: tests.test_identifier
def test_identifier_sorting6():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file", key=Keys.MATCHED, reverse=True)
<2> prev = None
<3> for match in out["Regexes"]["file"]:
<4> if prev is not None:
<5> assert prev >= match["Matched"]
<6> prev = match["Matched"]
<7>
|
===========unchanged ref 0===========
at: pywhat.helper
Keys()
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_sorting5():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED)
- out = r.identify("fixtures/file", key=Keys.MATCHED)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Matched"]
prev = match["Matched"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_sorting4():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_sorting3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.NAME)
- out = r.identify("fixtures/file", key=Keys.NAME)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 5===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 6===========
# module: tests.test_identifier
def test_identifier_sorting2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
- out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Rarity"]
prev = match["Regex Pattern"]["Rarity"]
===========changed ref 7===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 8===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 9===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 10===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_only_text
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures/file")
<del> out = r.identify("fixtures/file", only_text=True)
|
# module: tests.test_identifier
def test_only_text():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures/file", only_text=True)
<2> assert None == out["Regexes"]
<3>
<4> out = r.identify("THM{7281j}}", only_text=True)
<5> assert "TryHackMe Flag Format" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
<6>
|
===========unchanged ref 0===========
at: pywhat.helper
Keys()
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_identifier_sorting6():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED, reverse=True)
- out = r.identify("fixtures/file", key=Keys.MATCHED, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Matched"]
prev = match["Matched"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_sorting5():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED)
- out = r.identify("fixtures/file", key=Keys.MATCHED)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Matched"]
prev = match["Matched"]
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_sorting4():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_sorting3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.NAME)
- out = r.identify("fixtures/file", key=Keys.NAME)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 6===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 7===========
# module: tests.test_identifier
def test_identifier_sorting2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
- out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Rarity"]
prev = match["Regex Pattern"]["Rarity"]
===========changed ref 8===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 9===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 10===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 11===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_recursion
|
Modified
|
bee-san~pyWhat
|
b5737df67a4f4aee0105ceeb564d692073d6a672
|
only_text is set to True by default, updated tests
|
<1>:<add> out = r.identify("fixtures", only_text=False)
<del> out = r.identify("fixtures")
<3>:<del> for file in list(out["Regexes"].keys()):
<4>:<del> if "/file" == file or r"\file" == file:
<5>:<del> assert "ETH" in out["Regexes"][file][0]["Regex Pattern"]["Name"]
<6>:<del>
<7>:<del> elif "/tests/file" == file or r"\tests\file" == file:
<8>:<del> assert "URL" in out["Regexes"][file][0]["Regex Pattern"]["Name"]
<9>:<add> assert re.findall(r"\'(?:\/|\\)file\'", str(list(out["Regexes"].keys())))
<add> assert re.findall(r"\'(?:\/|\\)test(?:\/|\\)file\'", str(list(out["Regexes"].keys())))
|
# module: tests.test_identifier
def test_recursion():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures")
<2>
<3> for file in list(out["Regexes"].keys()):
<4> if "/file" == file or r"\file" == file:
<5> assert "ETH" in out["Regexes"][file][0]["Regex Pattern"]["Name"]
<6>
<7> elif "/tests/file" == file or r"\tests\file" == file:
<8> assert "URL" in out["Regexes"][file][0]["Regex Pattern"]["Name"]
<9>
|
===========unchanged ref 0===========
at: pywhat.helper
Keys()
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=False, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
===========changed ref 0===========
# module: tests.test_identifier
def test_only_text():
r = identifier.Identifier()
+ out = r.identify("fixtures/file")
- out = r.identify("fixtures/file", only_text=True)
assert None == out["Regexes"]
out = r.identify("THM{7281j}}", only_text=True)
assert "TryHackMe Flag Format" in out["Regexes"]["text"][0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_identifier
def test_identifier_sorting6():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED, reverse=True)
- out = r.identify("fixtures/file", key=Keys.MATCHED, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Matched"]
prev = match["Matched"]
===========changed ref 2===========
# module: tests.test_identifier
def test_identifier_sorting():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert out["Regexes"]["file"]
===========changed ref 3===========
# module: tests.test_identifier
def test_identifier_sorting5():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.MATCHED)
- out = r.identify("fixtures/file", key=Keys.MATCHED)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Matched"]
prev = match["Matched"]
===========changed ref 4===========
# module: tests.test_identifier
def test_identifier_sorting4():
r = identifier.Identifier(key=Keys.NAME, reverse=True)
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_identifier
def test_identifier_sorting3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.NAME)
- out = r.identify("fixtures/file", key=Keys.NAME)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev <= match["Regex Pattern"]["Name"]
prev = match["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_identifier
def test_identifier_works3():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Dogecoin (DOGE) Wallet Address"
in out["Regexes"]["file"][1]["Regex Pattern"]["Name"]
)
===========changed ref 7===========
# module: tests.test_identifier
def test_identifier_filtration():
filter = {"Tags": ["Password"]}
r = identifier.Identifier(dist=Distribution(filter))
+ regexes = r.identify("fixtures/file", only_text=False)["Regexes"]["file"]
- regexes = r.identify("fixtures/file")["Regexes"]["file"]
for regex in regexes:
assert "Password" in regex["Regex Pattern"]["Tags"]
===========changed ref 8===========
# module: tests.test_identifier
def test_identifier_sorting2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False, key=Keys.RARITY, reverse=True)
- out = r.identify("fixtures/file", key=Keys.RARITY, reverse=True)
prev = None
for match in out["Regexes"]["file"]:
if prev is not None:
assert prev >= match["Regex Pattern"]["Rarity"]
prev = match["Regex Pattern"]["Rarity"]
===========changed ref 9===========
# module: tests.test_identifier
def test_identifier_works2():
r = identifier.Identifier()
+ out = r.identify("fixtures/file", only_text=False)
- out = r.identify("fixtures/file")
assert (
"Ethereum (ETH) Wallet Address"
in out["Regexes"]["file"][0]["Regex Pattern"]["Name"]
)
===========changed ref 10===========
# module: tests.test_identifier
def test_identifier_filtration2():
filter1 = {"ExcludeTags": ["Identifiers"]}
filter2 = {"Tags": ["Identifiers"], "MinRarity": 0.6}
r = identifier.Identifier(dist=Distribution(filter1))
+ regexes = r.identify("fixtures/file", only_text=False, dist=Distribution(filter2))["Regexes"]["file"]
- regexes = r.identify("fixtures/file", dist=Distribution(filter2))["Regexes"]["file"]
for regex in regexes:
assert "Identifiers" in regex["Regex Pattern"]["Tags"]
assert regex["Regex Pattern"]["Rarity"] >= 0.6
===========changed ref 11===========
# module: tests.test_identifier
+
+
+ def test_check_keys_in_json():
+ with open("pywhat/Data/regex.json", "r") as file:
+ database = json.load(file)
+
+ for entry in database:
+ keys = list(entry.keys())
+ entry_name = entry["Name"]
+
+ assert "Name" in keys, entry_name
+ assert "Regex" in keys, entry_name
+ assert "plural_name" in keys, entry_name
+ assert "Description" in keys, entry_name
+ assert "Rarity" in keys, entry_name
+ assert "URL" in keys, entry_name
+ assert "Tags" in keys, entry_name
+
===========changed ref 12===========
# module: pywhat.what
class What_Object:
def what_is_this(self, text: str) -> dict:
"""
Returns a Python dictionary of everything that has been identified
"""
+ return self.id.identify(text, only_text=False)
- return self.id.identify(text)
|
tests.test_identifier/test_recursion
|
Modified
|
bee-san~pyWhat
|
6d9eac01bb6af244c507ecfa9c50a7d946de4760
|
Update tests for Windows
|
<3>:<add> assert re.findall(r"\'(?:\/|\\\\)file\'", str(list(out["Regexes"].keys())))
<del> assert re.findall(r"\'(?:\/|\\)file\'", str(list(out["Regexes"].keys())))
<4>:<add> assert re.findall(r"\'(?:\/|\\\\)test(?:\/|\\\\)file\'", str(list(out["Regexes"].keys())))
<del> assert re.findall(r"\'(?:\/|\\)test(?:\/|\\)file\'", str(list(out["Regexes"].keys())))
|
# module: tests.test_identifier
def test_recursion():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures", only_text=False)
<2>
<3> assert re.findall(r"\'(?:\/|\\)file\'", str(list(out["Regexes"].keys())))
<4> assert re.findall(r"\'(?:\/|\\)test(?:\/|\\)file\'", str(list(out["Regexes"].keys())))
<5>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=True, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: re
findall(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> List[Any]
findall(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> List[Any]
|
tests.test_identifier/test_check_keys_in_json
|
Modified
|
bee-san~pyWhat
|
a4954ef6c3531c5ce87169de13b829d1fea68746
|
Use a helper function instead
|
<0>:<del> with open("pywhat/Data/regex.json", "r") as file:
<1>:<del> database = json.load(file)
<2>:<add> database = load_regexes()
|
# module: tests.test_identifier
def test_check_keys_in_json():
<0> with open("pywhat/Data/regex.json", "r") as file:
<1> database = json.load(file)
<2>
<3> for entry in database:
<4> keys = list(entry.keys())
<5> entry_name = entry["Name"]
<6>
<7> assert "Name" in keys, entry_name
<8> assert "Regex" in keys, entry_name
<9> assert "plural_name" in keys, entry_name
<10> assert "Description" in keys, entry_name
<11> assert "Rarity" in keys, entry_name
<12> assert "URL" in keys, entry_name
<13> assert "Tags" in keys, entry_name
<14>
|
===========unchanged ref 0===========
at: pywhat.helper
load_regexes() -> list
|
pywhat.regex_identifier/RegexIdentifier.check
|
Modified
|
bee-san~pyWhat
|
a56b77b3e5ea66fd91005665759b394e59c0bcb0
|
Merge branch 'main' into regex-tlds
|
<4>:<add> with open("pywhat/Data/tld_list.txt", "r") as file:
<add> tlds = file.read()
<add>
<6>:<add> if reg["Name"] == "Uniform Resource Locator (URL)":
<add> # add all valid TLDs to the URL regex
<add> reg["Regex"] = reg["Regex"].replace("TLD", tlds)
<add>
|
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
<0> if distribution is None:
<1> distribution = self.distribution
<2> matches = []
<3>
<4> for string in text:
<5> for reg in distribution.get_regexes():
<6> matched_regex = re.search(reg["Regex"], string, re.UNICODE)
<7>
<8> if matched_regex:
<9> reg = copy.copy(reg) # necessary, when checking phone
<10> # numbers from file that may contain
<11> # non-international numbers
<12> matched = self.clean_text(matched_regex.group(0))
<13>
<14> if "Phone Number" in reg["Name"]:
<15> number = re.sub(r"[-() ]", "", matched)
<16> codes_path = "Data/phone_codes.json"
<17> codes_fullpath = os.path.join(
<18> os.path.dirname(os.path.abspath(__file__)), codes_path
<19> )
<20> with open(codes_fullpath, "r", encoding="utf-8") as myfile:
<21> codes = json.load(myfile)
<22>
<23> locations = []
<24> for code in codes:
<25> if number.startswith(code["dial_code"]):
<26> locations.append(code["name"])
<27> if len(locations) > 0:
<28> reg["Description"] = (
<29> "Location(s)" + ": " + ", ".join(locations)
<30> )
<31>
<32> matches.append(
<33> {
<34> "Matched": matched,
<35> "Regex Pattern": reg,
<36> }
<37> )
<38>
<39> return matches
<40>
|
===========unchanged ref 0===========
at: copy
copy(x: _T) -> _T
at: json
load(fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]]=..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]]=..., parse_float: Optional[Callable[[str], Any]]=..., parse_int: Optional[Callable[[str], Any]]=..., parse_constant: Optional[Callable[[str], Any]]=..., object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]]=..., **kwds: Any) -> Any
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
dirname(p: _PathLike[AnyStr]) -> AnyStr
dirname(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.regex_identifier.RegexIdentifier
clean_text(text)
at: pywhat.regex_identifier.RegexIdentifier.__init__
self.distribution = Distribution()
at: re
UNICODE = RegexFlag.UNICODE
search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
search(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
===========unchanged ref 1===========
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
at: typing.Match
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
string: AnyStr
re: Pattern[AnyStr]
group(group1: Union[str, int], group2: Union[str, int], /, *groups: Union[str, int]) -> Tuple[AnyStr, ...]
group(group: Union[str, int]=..., /) -> AnyStr
|
tests.test_regex_identifier/test_ip
|
Modified
|
bee-san~pyWhat
|
a56b77b3e5ea66fd91005665759b394e59c0bcb0
|
Merge branch 'main' into regex-tlds
|
<1>:<add> res = r.check(["http://10.1.1.1/just/a/test"])
<del> res = r.check(["http://10.1.1.1"])
<2>:<add> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<add> assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
<del> assert "Internet Protocol (IP) Address Version 4" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ip():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["http://10.1.1.1"])
<2> assert "Internet Protocol (IP) Address Version 4" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
if distribution is None:
distribution = self.distribution
matches = []
+ with open("pywhat/Data/tld_list.txt", "r") as file:
+ tlds = file.read()
+
for string in text:
for reg in distribution.get_regexes():
+ if reg["Name"] == "Uniform Resource Locator (URL)":
+ # add all valid TLDs to the URL regex
+ reg["Regex"] = reg["Regex"].replace("TLD", tlds)
+
matched_regex = re.search(reg["Regex"], string, re.UNICODE)
if matched_regex:
reg = copy.copy(reg) # necessary, when checking phone
# numbers from file that may contain
# non-international numbers
matched = self.clean_text(matched_regex.group(0))
if "Phone Number" in reg["Name"]:
number = re.sub(r"[-() ]", "", matched)
codes_path = "Data/phone_codes.json"
codes_fullpath = os.path.join(
os.path.dirname(os.path.abspath(__file__)), codes_path
)
with open(codes_fullpath, "r", encoding="utf-8") as myfile:
codes = json.load(myfile)
locations = []
for code in codes:
if number.startswith(code["dial_code"]):
locations.append(code["name"])
if len(locations) > 0:
reg["Description"] = (
"Location(s)" + ": " + ", ".join(locations)
)
matches.append(
{
"Matched": matched,
"Regex Pattern": reg,
}
)
return matches
===========changed ref 1===========
# module: tests.test_regex_identifier
+ def test_invalid_tld():
+ r = regex_identifier.RegexIdentifier()
+ res = r.check(["tryhackme.comm"])
+ assert "Uniform Resource Locator (URL)" not in res
+
===========changed ref 2===========
# module: tests.test_regex_identifier
+ def test_url_2():
+ r = regex_identifier.RegexIdentifier()
+ res = r.check(["http://username:[email protected]/"])
+ assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 3===========
# module: scripts.get_tlds
tdls = requests.get("https://data.iana.org/TLD/tlds-alpha-by-domain.txt")
final_string = "|".join(tdls.text.split("\n")[1:-1])
+ file = open("pywhat/Data/tld_list.txt", "w")
- file = open("tld_list.txt", "w")
file.write(final_string)
file.close()
|
pywhat.regex_identifier/RegexIdentifier.check
|
Modified
|
bee-san~pyWhat
|
9d7a47cffdd088c1a8b1b7346d4c4ccf1fe9e33a
|
Script adds TLD list to the regex.json
|
<4>:<del> with open("pywhat/Data/tld_list.txt", "r") as file:
<5>:<del> tlds = file.read()
<6>:<del>
<9>:<del> if reg["Name"] == "Uniform Resource Locator (URL)":
<10>:<del> # add all valid TLDs to the URL regex
<11>:<del> reg["Regex"] = reg["Regex"].replace("TLD", tlds)
<12>:<del>
|
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
<0> if distribution is None:
<1> distribution = self.distribution
<2> matches = []
<3>
<4> with open("pywhat/Data/tld_list.txt", "r") as file:
<5> tlds = file.read()
<6>
<7> for string in text:
<8> for reg in distribution.get_regexes():
<9> if reg["Name"] == "Uniform Resource Locator (URL)":
<10> # add all valid TLDs to the URL regex
<11> reg["Regex"] = reg["Regex"].replace("TLD", tlds)
<12>
<13> matched_regex = re.search(reg["Regex"], string, re.UNICODE)
<14>
<15> if matched_regex:
<16> reg = copy.copy(reg) # necessary, when checking phone
<17> # numbers from file that may contain
<18> # non-international numbers
<19> matched = self.clean_text(matched_regex.group(0))
<20>
<21> if "Phone Number" in reg["Name"]:
<22> number = re.sub(r"[-() ]", "", matched)
<23> codes_path = "Data/phone_codes.json"
<24> codes_fullpath = os.path.join(
<25> os.path.dirname(os.path.abspath(__file__)), codes_path
<26> )
<27> with open(codes_fullpath, "r", encoding="utf-8") as myfile:
<28> codes = json.load(myfile)
<29>
<30> locations = []
<31> for code in codes:
<32> if number.startswith(code["dial_code"]):
<33> locations.append(code["name"])
<34> if len(locations) > 0:
<35> reg["Description"] = (
<36> "Location(s)" + ": " + ", ".join(locations)
<37> )
<38>
<39> matches.append(
<40> {
<41> "Matched": matched,
<42> "Regex Pattern": reg,
<43> }
<44> )
<45> </s>
|
===========below chunk 0===========
# module: pywhat.regex_identifier
class RegexIdentifier:
def check(self, text, distribution: Optional[Distribution] = None):
# offset: 1
===========unchanged ref 0===========
at: copy
copy(x: _T) -> _T
at: json
load(fp: SupportsRead[Union[str, bytes]], *, cls: Optional[Type[JSONDecoder]]=..., object_hook: Optional[Callable[[Dict[Any, Any]], Any]]=..., parse_float: Optional[Callable[[str], Any]]=..., parse_int: Optional[Callable[[str], Any]]=..., parse_constant: Optional[Callable[[str], Any]]=..., object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]]=..., **kwds: Any) -> Any
at: os.path
join(a: StrPath, *paths: StrPath) -> str
join(a: BytesPath, *paths: BytesPath) -> bytes
dirname(p: _PathLike[AnyStr]) -> AnyStr
dirname(p: AnyStr) -> AnyStr
abspath(path: _PathLike[AnyStr]) -> AnyStr
abspath(path: AnyStr) -> AnyStr
abspath = _abspath_fallback
at: pywhat.distribution
Distribution(filters_dict: Optional[dict]=None)
at: pywhat.distribution.Distribution
get_regexes()
at: pywhat.regex_identifier.RegexIdentifier.__init__
self.distribution = Distribution()
at: re
UNICODE = RegexFlag.UNICODE
search(pattern: Pattern[AnyStr], string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
search(pattern: AnyStr, string: AnyStr, flags: _FlagsType=...) -> Optional[Match[AnyStr]]
===========unchanged ref 1===========
sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
sub(pattern: Pattern[AnyStr], repl: AnyStr, string: AnyStr, count: int=..., flags: _FlagsType=...) -> AnyStr
at: typing.Match
pos: int
endpos: int
lastindex: Optional[int]
lastgroup: Optional[AnyStr]
string: AnyStr
re: Pattern[AnyStr]
group(group1: Union[str, int], group2: Union[str, int], /, *groups: Union[str, int]) -> Tuple[AnyStr, ...]
group(group: Union[str, int]=..., /) -> AnyStr
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
7e54c5403829d66a931ebc7d6a6fda09d21a90f4
|
Add only_text to CLI
|
<s>.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
+ @click.option(
+ "-o", "--only-text", is_flag=True, help="Do not scan files or folders."
+ )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text):
- def main(text_input, rarity, include_tags, exclude_tags):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Rarity is how unlikely something is to be a false-positive. The higher the number, the more unlikely.\n
<10> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<11> Note: PyWhat by default has a rarity of 0.1. To see all matches, with many potential false positives use `0:`.\n
<12> --include_tags list\n
<13> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<14> --exclude_tags list\n
<15> Exclude specified tags. List is a comma separated list.\n
<16>
<17> Examples:
<18>
<19> * what 'HTB{this is a flag}'
<20>
<21> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<22>
<23> * what -- '52.6169586, -1.9779857'
<24>
<25> * what --rarity 0.6: '[email protected]'
<26>
<27> * what --rarity 0: --include_tags "credentials, username, password" --exclude</s>
|
===========below chunk 0===========
<s>", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
+ @click.option(
+ "-o", "--only-text", is_flag=True, help="Do not scan files or folders."
+ )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text):
- def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even a whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(parse_options(rarity, include_tags, exclude_tags))
identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output, text_input)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.what
print_tags(ctx, opts, value)
parse_options(rarity, include_tags, exclude_tags)
What_Object(distribution)
at: pywhat.what.What_Object
what_is_this(self, text: str, only_text: bool) -> dict
what_is_this(text: str, only_text: bool) -> dict
|
|
pywhat.what/What_Object.what_is_this
|
Modified
|
bee-san~pyWhat
|
7e54c5403829d66a931ebc7d6a6fda09d21a90f4
|
Add only_text to CLI
|
<3>:<add> return self.id.identify(text, only_text=only_text)
<del> return self.id.identify(text, only_text=False)
|
# module: pywhat.what
class What_Object:
+ def what_is_this(self, text: str, only_text: bool) -> dict:
- def what_is_this(self, text: str) -> dict:
<0> """
<1> Returns a Python dictionary of everything that has been identified
<2> """
<3> return self.id.identify(text, only_text=False)
<4>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
===========changed ref 0===========
<s>.option("-i", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
+ @click.option(
+ "-o", "--only-text", is_flag=True, help="Do not scan files or folders."
+ )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text):
- def main(text_input, rarity, include_tags, exclude_tags):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Rarity is how unlikely something is to be a false-positive. The higher the number, the more unlikely.\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
Note: PyWhat by default has a rarity of 0.1. To see all matches, with many potential false positives use `0:`.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
--exclude_tags list\n
Exclude specified tags. List is a comma separated list.\n
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- '52.6169586, -1.9779857'
* what --rarity 0.6: '[email protected]'
* what --rarity 0: --include_tags "credentials, username, password" --exclude_tags "aws, credentials" 'James:SecretPassword'
Your text must either be in quotation marks</s>
===========changed ref 1===========
<s>", "--include_tags", help="Only print entries with included tags.")
@click.option("-e", "--exclude_tags", help="Exclude tags.")
+ @click.option(
+ "-o", "--only-text", is_flag=True, help="Do not scan files or folders."
+ )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text):
- def main(text_input, rarity, include_tags, exclude_tags):
# offset: 1
<s> --exclude_tags "aws, credentials" 'James:SecretPassword'
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even a whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(parse_options(rarity, include_tags, exclude_tags))
+ identified_output = what_obj.what_is_this(text_input, only_text)
- identified_output = what_obj.what_is_this(text_input)
p = printer.Printing()
p.pretty_print(identified_output, text_input)
|
pywhat.what/main
|
Modified
|
bee-san~pyWhat
|
802ae283d4a3f0c636fa148196aa46007819d7c7
|
Add sorting to CLI
|
<16>:<add>
<add> Sorting:
<add>
<add> --key key_name
<add>
<add> Sort by the given key.
<add>
<add> --reverse
<add>
<add> Sort in reverse order.
<add>
<add> Available keys:
<add>
<add> name - Sort by the name of regex pattern
<add>
<add> rarity - Sort by rarity
<add>
<add> matched - Sort by a matched string
<add>
<add> none - No sorting is done (the default)
<add>
|
<s>", "--only-text", is_flag=True, help="Do not scan files or folders."
+ @click.option("-k", "--key", help="Sort by the specified key.")
+ @click.option("--reverse", is_flag=True, help="Sort in reverse order.")
- )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text, key, reverse):
- def main(text_input, rarity, include_tags, exclude_tags, only_text):
<0> """
<1> pyWhat - Identify what something is.\n
<2>
<3> Made by Bee https://twitter.com/bee_sec_san\n
<4>
<5> https://github.com/bee-san\n
<6>
<7> Filtration:\n
<8> --rarity min:max\n
<9> Rarity is how unlikely something is to be a false-positive. The higher the number, the more unlikely.\n
<10> Only print entries with rarity in range [min,max]. min and max can be omitted.\n
<11> Note: PyWhat by default has a rarity of 0.1. To see all matches, with many potential false positives use `0:`.\n
<12> --include_tags list\n
<13> Only include entries containing at least one tag in a list. List is a comma separated list.\n
<14> --exclude_tags list\n
<15> Exclude specified tags. List is a comma separated list.\n
<16>
<17> Examples:
<18>
<19> * what 'HTB{this is a flag}'
<20>
<21> * what '0x52908400098527886E0F7030069857D2E4169EE7'
<22>
<23> * what -- '52.6169586, -1.9779857'
<24>
<25> * what --rarity 0.6: '[email protected]'
<26>
<27> * what --rarity 0: --include_tags "credentials, username, password" --exclude</s>
|
===========below chunk 0===========
<s>", is_flag=True, help="Do not scan files or folders."
+ @click.option("-k", "--key", help="Sort by the specified key.")
+ @click.option("--reverse", is_flag=True, help="Sort in reverse order.")
- )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text, key, reverse):
- def main(text_input, rarity, include_tags, exclude_tags, only_text):
# offset: 1
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even a whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(parse_options(rarity, include_tags, exclude_tags))
identified_output = what_obj.what_is_this(text_input, only_text)
p = printer.Printing()
p.pretty_print(identified_output, text_input)
===========unchanged ref 0===========
at: click.decorators
command(name: Optional[str]=..., cls: Optional[Type[Command]]=..., context_settings: Optional[Dict[Any, Any]]=..., help: Optional[str]=..., epilog: Optional[str]=..., short_help: Optional[str]=..., options_metavar: str=..., add_help_option: bool=..., hidden: bool=..., deprecated: bool=...) -> Callable[[Callable[..., Any]], Command]
argument(*param_decls: Text, cls: Type[Argument]=..., required: Optional[bool]=..., type: Optional[_ConvertibleType]=..., default: Optional[Any]=..., callback: Optional[_Callback]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]]=...) -> _IdentityFunction
===========unchanged ref 1===========
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: _T=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: str, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=..., hide_input: bool=..., is_flag: Optional[bool]=..., flag_value: Optional[Any]=..., multiple: bool=..., count: bool=..., allow_from_autoenv: bool=..., type: Type[int]=..., help: Optional[str]=..., show_choices: bool=..., default: Optional[Any]=..., required: bool=..., callback: Callable[[Context, Union[Option, Parameter], int], Any]=..., nargs: Optional[int]=..., metavar: Optional[str]=..., expose_value: bool=..., is_eager: bool=..., envvar: Optional[Union[str, List[str]]]=..., **kwargs: Any) -> _IdentityFunction
option(*param_decls: Text, cls: Type[Option]=..., show_default: Union[bool, Text]=..., prompt: Union[bool, Text]=..., confirmation_prompt: bool=...,</s>
===========unchanged ref 2===========
at: pywhat.what
print_tags(ctx, opts, value)
===========changed ref 0===========
# module: pywhat.helper
+ def str_to_key(s: str):
+ try:
+ return getattr(Keys, s.upper())
+ except AttributeError:
+ raise ValueError
+
|
pywhat.what/What_Object.what_is_this
|
Modified
|
bee-san~pyWhat
|
802ae283d4a3f0c636fa148196aa46007819d7c7
|
Add sorting to CLI
|
<3>:<add> return self.id.identify(text, only_text=only_text, key=key, reverse=reverse)
<del> return self.id.identify(text, only_text=only_text)
|
# module: pywhat.what
class What_Object:
+ def what_is_this(self, text: str, only_text: bool, key, reverse) -> dict:
- def what_is_this(self, text: str, only_text: bool) -> dict:
<0> """
<1> Returns a Python dictionary of everything that has been identified
<2> """
<3> return self.id.identify(text, only_text=only_text)
<4>
|
===========changed ref 0===========
<s>", "--only-text", is_flag=True, help="Do not scan files or folders."
+ @click.option("-k", "--key", help="Sort by the specified key.")
+ @click.option("--reverse", is_flag=True, help="Sort in reverse order.")
- )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text, key, reverse):
- def main(text_input, rarity, include_tags, exclude_tags, only_text):
"""
pyWhat - Identify what something is.\n
Made by Bee https://twitter.com/bee_sec_san\n
https://github.com/bee-san\n
Filtration:\n
--rarity min:max\n
Rarity is how unlikely something is to be a false-positive. The higher the number, the more unlikely.\n
Only print entries with rarity in range [min,max]. min and max can be omitted.\n
Note: PyWhat by default has a rarity of 0.1. To see all matches, with many potential false positives use `0:`.\n
--include_tags list\n
Only include entries containing at least one tag in a list. List is a comma separated list.\n
--exclude_tags list\n
Exclude specified tags. List is a comma separated list.\n
+
+ Sorting:
+
+ --key key_name
+
+ Sort by the given key.
+
+ --reverse
+
+ Sort in reverse order.
+
+ Available keys:
+
+ name - Sort by the name of regex pattern
+
+ rarity - Sort by rarity
+
+ matched - Sort by a matched string
+
+ none - No sorting is done (the default)
+
Examples:
* what 'HTB{this is a flag}'
* what</s>
===========changed ref 1===========
<s>", is_flag=True, help="Do not scan files or folders."
+ @click.option("-k", "--key", help="Sort by the specified key.")
+ @click.option("--reverse", is_flag=True, help="Sort in reverse order.")
- )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text, key, reverse):
- def main(text_input, rarity, include_tags, exclude_tags, only_text):
# offset: 1
<s>
Examples:
* what 'HTB{this is a flag}'
* what '0x52908400098527886E0F7030069857D2E4169EE7'
* what -- '52.6169586, -1.9779857'
* what --rarity 0.6: '[email protected]'
* what --rarity 0: --include_tags "credentials, username, password" --exclude_tags "aws, credentials" 'James:SecretPassword'
Your text must either be in quotation marks, or use the POSIX standard of "--" to mean "anything after -- is textual input".
pyWhat can also search files or even a whole directory with recursion:
* what 'secret.txt'
* what 'this/is/a/path'
"""
what_obj = What_Object(parse_options(rarity, include_tags, exclude_tags))
+ if key is None:
+ key = Keys.NONE
+ else:
+ try:
+ key = str_to_key(key)
+ except ValueError:
+ print("Invalid key")
+ sys.exit(1)
+ identified_output = what_obj.what_is_this</s>
===========changed ref 2===========
<s>", is_flag=True, help="Do not scan files or folders."
+ @click.option("-k", "--key", help="Sort by the specified key.")
+ @click.option("--reverse", is_flag=True, help="Sort in reverse order.")
- )
+ def main(text_input, rarity, include_tags, exclude_tags, only_text, key, reverse):
- def main(text_input, rarity, include_tags, exclude_tags, only_text):
# offset: 2
<s>_input, only_text, key, reverse)
- identified_output = what_obj.what_is_this(text_input, only_text)
p = printer.Printing()
p.pretty_print(identified_output, text_input)
===========changed ref 3===========
# module: pywhat.helper
+ def str_to_key(s: str):
+ try:
+ return getattr(Keys, s.upper())
+ except AttributeError:
+ raise ValueError
+
|
tests.test_identifier/test_recursion
|
Modified
|
bee-san~pyWhat
|
2ac916c5e7eade61b0ef822e5063b2b003a930a2
|
Merge branch 'main' into style
|
<4>:<add> assert re.findall(
<add> r"\'(?:\/|\\\\)test(?:\/|\\\\)file\'", str(list(out["Regexes"].keys()))
<del> assert re.findall(r"\'(?:\/|\\\\)test(?:\/|\\\\)file\'", str(list(out["Regexes"].keys())))
<5>:<add> )
|
# module: tests.test_identifier
def test_recursion():
<0> r = identifier.Identifier()
<1> out = r.identify("fixtures", only_text=False)
<2>
<3> assert re.findall(r"\'(?:\/|\\\\)file\'", str(list(out["Regexes"].keys())))
<4> assert re.findall(r"\'(?:\/|\\\\)test(?:\/|\\\\)file\'", str(list(out["Regexes"].keys())))
<5>
|
===========unchanged ref 0===========
at: pywhat.identifier
Identifier(*, dist: Optional[Distribution]=None, key: Callable=Keys.NONE, reverse=False)
at: pywhat.identifier.Identifier
identify(text: str, *, only_text=True, dist: Distribution=None, key: Optional[Callable]=None, reverse: Optional[bool]=None) -> dict
at: tests.test_identifier.test_only_text
r = identifier.Identifier()
|
tests.test_regex_identifier/test_regex_runs
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
<del> assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_regex_runs():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
<2> assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
|
tests.test_regex_identifier/test_url
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Uniform Resource Locator (URL)", res)
<del> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_url():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["tryhackme.com"])
<2> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_url_2
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Uniform Resource Locator (URL)", res)
<del> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_url_2():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["http://username:[email protected]/"])
<2> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_https
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Uniform Resource Locator (URL)", res)
<del> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_https():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["hTTPs://tryhackme.com"])
<2> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_lat_long
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Latitude & Longitude Coordinates", res)
<del> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_lat_long():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["52.6169586, -1.9779857"])
<2> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_lat_long2
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Latitude & Longitude Coordinates", res)
<del> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_lat_long2():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["53.76297,-1.9388732"])
<2> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_lat_long3
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Latitude & Longitude Coordinates", res)
<del> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_lat_long3():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["77\u00B0 30' 29.9988\" N"])
<2> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_lat_long4
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<3>:<add> _assert_match_first_item("Latitude & Longitude Coordinates", res)
<del> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_lat_long4():
<0> r = regex_identifier.RegexIdentifier()
<1> # degree symbol has to be a unicode character, otherwise Windows will not understand it
<2> res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
<3> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
<4>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_lat_long5
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Latitude & Longitude Coordinates", res)
<del> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_lat_long5():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
<2> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_lat_long6
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Latitude & Longitude Coordinates", res)
<del> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_lat_long6():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["40.741895,-73.989308"])
<2> assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_ip
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Uniform Resource Locator (URL)", res)
<del> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ip():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["http://10.1.1.1/just/a/test"])
<2> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<3> assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
<4>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_ip3
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
<del> assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ip3():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
<2> assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_international_url
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Uniform Resource Locator (URL)", res)
<del> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["http://папироска.рф"])
<2> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: _pytest.mark.structures
MARK_GEN = MarkGenerator(_ispytest=True)
at: _pytest.mark.structures.MarkGenerator
skip: _SkipMarkDecorator
skipif: _SkipifMarkDecorator
xfail: _XfailMarkDecorator
parametrize: _ParametrizeMarkDecorator
usefixtures: _UsefixturesMarkDecorator
filterwarnings: _FilterwarningsMarkDecorator
at: pywhat.regex_identifier
RegexIdentifier()
at: tests.test_regex_identifier.test_mac6
res = r.check(["00:00:0G:00:00:00"])
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_same_international_url_in_punycode
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Uniform Resource Locator (URL)", res)
<del> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
<2> assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_ctf_flag
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("TryHackMe Flag Format", res)
<del> assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ctf_flag():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["thm{hello}"])
<2> assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_ctf_flag_uppercase
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Capture The Flag (CTF) Flag", res)
<del> assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["FLAG{hello}"])
<2> assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_ethereum
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
<del> assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ethereum():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
<2> assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_bitcoin
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Bitcoin", res)
<del> assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_bitcoin():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
<2> assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 17===========
# module: tests.test_regex_identifier
def test_regex_runs():
r = regex_identifier.RegexIdentifier()
res = r.check(["DANHz6EQVoWyZ9rER56DwTXHWUxfkv9k2o"])
+ _assert_match_first_item("Dogecoin (DOGE) Wallet Address", res)
- assert "Dogecoin (DOGE) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_monero
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<6>:<add> _assert_match_first_item("Monero (XMR) Wallet Address", res)
<del> assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_monero():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(
<2> [
<3> "47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
<4> ]
<5> )
<6> assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
<7>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
at: pywhat.regex_identifier.RegexIdentifier
check(text, distribution: Optional[Distribution]=None)
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 17===========
# module: tests.test_regex_identifier
def test_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_litecoin
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
<del> assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_litecoin():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
<2> assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_lat_long4():
r = regex_identifier.RegexIdentifier()
# degree symbol has to be a unicode character, otherwise Windows will not understand it
res = r.check(["N 32\u00B0 53.733 W 096\u00B0 48.358"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 17===========
# module: tests.test_regex_identifier
def test_url_2():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://username:[email protected]/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_bitcoincash
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
<del> assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_bitcoincash():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
<2> assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_https():
r = regex_identifier.RegexIdentifier()
res = r.check(["hTTPs://tryhackme.com"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_ripple
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Ripple (XRP) Wallet Address", res)
<del> assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_ripple():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
<2> assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_lat_long():
r = regex_identifier.RegexIdentifier()
res = r.check(["52.6169586, -1.9779857"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_visa
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Visa", res)
<del> assert "Visa" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_visa():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["4111111111111111"])
<2> assert "Visa" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
+ _assert_match_first_item("Ripple (XRP) Wallet Address", res)
- assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_lat_long2():
r = regex_identifier.RegexIdentifier()
res = r.check(["53.76297,-1.9388732"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_visa_spaces
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("Visa", res)
<del> assert "Visa" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_visa_spaces():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["4607 0000 0000 0009"])
<2> assert "Visa" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_visa():
r = regex_identifier.RegexIdentifier()
res = r.check(["4111111111111111"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
+ _assert_match_first_item("Ripple (XRP) Wallet Address", res)
- assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_ip():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://10.1.1.1/just/a/test"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
assert "Internet Protocol (IP) Address Version 4" in res[1]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_master_Card
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("MasterCard", res)
<del> assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_master_Card():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["5500000000000004"])
<2> assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_visa_spaces():
r = regex_identifier.RegexIdentifier()
res = r.check(["4607 0000 0000 0009"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_visa():
r = regex_identifier.RegexIdentifier()
res = r.check(["4111111111111111"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
+ _assert_match_first_item("Ripple (XRP) Wallet Address", res)
- assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_master_card_spaces
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("MasterCard", res)
<del> assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_master_card_spaces():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["5555 5555 5555 4444"])
<2> assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_master_Card():
r = regex_identifier.RegexIdentifier()
res = r.check(["5500000000000004"])
+ _assert_match_first_item("MasterCard", res)
- assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_visa_spaces():
r = regex_identifier.RegexIdentifier()
res = r.check(["4607 0000 0000 0009"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_visa():
r = regex_identifier.RegexIdentifier()
res = r.check(["4111111111111111"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
+ _assert_match_first_item("Ripple (XRP) Wallet Address", res)
- assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 17===========
# module: tests.test_regex_identifier
def test_lat_long3():
r = regex_identifier.RegexIdentifier()
res = r.check(["77\u00B0 30' 29.9988\" N"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_american_express
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("American Express", res)
<del> assert "American Express" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_american_express():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["340000000000009"])
<2> assert "American Express" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_master_card_spaces():
r = regex_identifier.RegexIdentifier()
res = r.check(["5555 5555 5555 4444"])
+ _assert_match_first_item("MasterCard", res)
- assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_master_Card():
r = regex_identifier.RegexIdentifier()
res = r.check(["5500000000000004"])
+ _assert_match_first_item("MasterCard", res)
- assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_visa_spaces():
r = regex_identifier.RegexIdentifier()
res = r.check(["4607 0000 0000 0009"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_visa():
r = regex_identifier.RegexIdentifier()
res = r.check(["4111111111111111"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
+ _assert_match_first_item("Ripple (XRP) Wallet Address", res)
- assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
===========changed ref 17===========
# module: tests.test_regex_identifier
def test_lat_long5():
r = regex_identifier.RegexIdentifier()
res = r.check(["41\u00B024'12.2\" N 2\u00B010'26.5\" E"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
|
tests.test_regex_identifier/test_american_express_spaces
|
Modified
|
bee-san~pyWhat
|
98de8f5db92f4335a3207d11c0af39e6a30d7509
|
Merge branch 'main' into feature/api-keys
|
<2>:<add> _assert_match_first_item("American Express", res)
<del> assert "American Express" in res[0]["Regex Pattern"]["Name"]
|
# module: tests.test_regex_identifier
def test_american_express_spaces():
<0> r = regex_identifier.RegexIdentifier()
<1> res = r.check(["3714 4963 5398 431"])
<2> assert "American Express" in res[0]["Regex Pattern"]["Name"]
<3>
|
===========unchanged ref 0===========
at: pywhat.regex_identifier
RegexIdentifier()
===========changed ref 0===========
# module: tests.test_regex_identifier
def test_american_express():
r = regex_identifier.RegexIdentifier()
res = r.check(["340000000000009"])
+ _assert_match_first_item("American Express", res)
- assert "American Express" in res[0]["Regex Pattern"]["Name"]
===========changed ref 1===========
# module: tests.test_regex_identifier
def test_master_card_spaces():
r = regex_identifier.RegexIdentifier()
res = r.check(["5555 5555 5555 4444"])
+ _assert_match_first_item("MasterCard", res)
- assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
===========changed ref 2===========
# module: tests.test_regex_identifier
def test_master_Card():
r = regex_identifier.RegexIdentifier()
res = r.check(["5500000000000004"])
+ _assert_match_first_item("MasterCard", res)
- assert "MasterCard" in res[0]["Regex Pattern"]["Name"]
===========changed ref 3===========
# module: tests.test_regex_identifier
def test_visa_spaces():
r = regex_identifier.RegexIdentifier()
res = r.check(["4607 0000 0000 0009"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 4===========
# module: tests.test_regex_identifier
def test_visa():
r = regex_identifier.RegexIdentifier()
res = r.check(["4111111111111111"])
+ _assert_match_first_item("Visa", res)
- assert "Visa" in res[0]["Regex Pattern"]["Name"]
===========changed ref 5===========
# module: tests.test_regex_identifier
def test_ripple():
r = regex_identifier.RegexIdentifier()
res = r.check(["rBPAQmwMrt7FDDPNyjwFgwSqbWZPf6SLkk"])
+ _assert_match_first_item("Ripple (XRP) Wallet Address", res)
- assert "Ripple (XRP) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 6===========
# module: tests.test_regex_identifier
def test_bitcoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY"])
+ _assert_match_first_item("Bitcoin", res)
- assert "Bitcoin" in res[0]["Regex Pattern"]["Name"]
===========changed ref 7===========
# module: tests.test_regex_identifier
def test_litecoin():
r = regex_identifier.RegexIdentifier()
res = r.check(["LRX8rSPVjifTxoLeoJtLf2JYdJFTQFcE7m"])
+ _assert_match_first_item("Litecoin (LTC) Wallet Address", res)
- assert "Litecoin (LTC) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 8===========
# module: tests.test_regex_identifier
def test_ctf_flag_uppercase():
r = regex_identifier.RegexIdentifier()
res = r.check(["FLAG{hello}"])
+ _assert_match_first_item("Capture The Flag (CTF) Flag", res)
- assert "Capture The Flag (CTF) Flag" in res[0]["Regex Pattern"]["Name"]
===========changed ref 9===========
# module: tests.test_regex_identifier
def test_ctf_flag():
r = regex_identifier.RegexIdentifier()
res = r.check(["thm{hello}"])
+ _assert_match_first_item("TryHackMe Flag Format", res)
- assert "TryHackMe Flag Format" in res[0]["Regex Pattern"]["Name"]
===========changed ref 10===========
# module: tests.test_regex_identifier
def test_bitcoincash():
r = regex_identifier.RegexIdentifier()
res = r.check(["bitcoincash:qzlg6uvceehgzgtz6phmvy8gtdqyt6vf359at4n3lq"])
+ _assert_match_first_item("Bitcoin Cash (BCH) Wallet Address", res)
- assert "Bitcoin Cash (BCH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 11===========
# module: tests.test_regex_identifier
def test_ethereum():
r = regex_identifier.RegexIdentifier()
res = r.check(["0x52908400098527886E0F7030069857D2E4169EE7"])
+ _assert_match_first_item("Ethereum (ETH) Wallet Address", res)
- assert "Ethereum (ETH) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 12===========
# module: tests.test_regex_identifier
def test_same_international_url_in_punycode():
r = regex_identifier.RegexIdentifier()
res = r.check(["https://xn--80aaxitdbjk.xn--p1ai/"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 13===========
# module: tests.test_regex_identifier
@pytest.mark.skip(
reason="Fails because not a valid TLD. If presented in punycode, it works."
)
def test_international_url():
r = regex_identifier.RegexIdentifier()
res = r.check(["http://папироска.рф"])
+ _assert_match_first_item("Uniform Resource Locator (URL)", res)
- assert "Uniform Resource Locator (URL)" in res[0]["Regex Pattern"]["Name"]
===========changed ref 14===========
# module: tests.test_regex_identifier
def test_monero():
r = regex_identifier.RegexIdentifier()
res = r.check(
[
"47DF8D9NwtmefhFUghynYRMqrexiZTsm48T1hhi2jZcbfcwoPbkhMrrED6zqJRfeYpXFfdaqAT3jnBEwoMwCx6BYDJ1W3ub"
]
)
+ _assert_match_first_item("Monero (XMR) Wallet Address", res)
- assert "Monero (XMR) Wallet Address" in res[0]["Regex Pattern"]["Name"]
===========changed ref 15===========
# module: tests.test_regex_identifier
def test_ip3():
r = regex_identifier.RegexIdentifier()
res = r.check(["2001:0db8:85a3:0000:0000:8a2e:0370:7334"])
+ _assert_match_first_item("Internet Protocol (IP) Address Version 6", res)
- assert "Internet Protocol (IP) Address Version 6" in res[0]["Regex Pattern"]["Name"]
===========changed ref 16===========
# module: tests.test_regex_identifier
def test_lat_long6():
r = regex_identifier.RegexIdentifier()
res = r.check(["40.741895,-73.989308"])
+ _assert_match_first_item("Latitude & Longitude Coordinates", res)
- assert "Latitude & Longitude Coordinates" in res[0]["Regex Pattern"]["Name"]
===========changed ref 17===========
# module: tests.test_regex_identifier
+ def _assert_match_first_item(name, res):
+ assert name in res[0]["Regex Pattern"]["Name"]
+
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.