PyFunceble-dev 4.3.0a23__py3-none-any.whl → 4.3.0a24__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyFunceble/checker/availability/base.py +5 -2
- PyFunceble/checker/availability/domain.py +18 -0
- PyFunceble/checker/availability/extras/base.py +4 -4
- PyFunceble/checker/availability/extras/dns.py +1 -1
- PyFunceble/checker/availability/extras/etoxic.py +3 -3
- PyFunceble/checker/availability/extras/parked.py +22 -20
- PyFunceble/checker/availability/extras/rules.py +5 -13
- PyFunceble/checker/availability/extras/subject_switch.py +4 -5
- PyFunceble/checker/availability/ip.py +18 -0
- PyFunceble/checker/availability/params.py +1 -1
- PyFunceble/checker/availability/status.py +9 -4
- PyFunceble/checker/availability/url.py +6 -0
- PyFunceble/checker/base.py +4 -0
- PyFunceble/checker/reputation/base.py +5 -2
- PyFunceble/checker/reputation/domain.py +11 -0
- PyFunceble/checker/reputation/ip.py +11 -0
- PyFunceble/checker/reputation/status.py +1 -1
- PyFunceble/checker/reputation/url.py +12 -1
- PyFunceble/checker/syntax/base.py +4 -1
- PyFunceble/checker/syntax/domain.py +4 -0
- PyFunceble/checker/syntax/ip.py +4 -0
- PyFunceble/checker/syntax/ipv4.py +10 -13
- PyFunceble/checker/syntax/ipv6.py +9 -11
- PyFunceble/checker/syntax/params.py +1 -1
- PyFunceble/checker/syntax/second_lvl_domain.py +3 -4
- PyFunceble/checker/syntax/subdomain.py +3 -4
- PyFunceble/checker/syntax/url.py +9 -6
- PyFunceble/checker/utils/whois.py +7 -11
- PyFunceble/cli/continuous_integration/base.py +14 -14
- PyFunceble/cli/credential_loader.py +4 -6
- PyFunceble/cli/entry_points/clean.py +0 -1
- PyFunceble/cli/entry_points/production.py +1 -1
- PyFunceble/cli/entry_points/pyfunceble/cli.py +1 -1
- PyFunceble/cli/execution_time.py +2 -2
- PyFunceble/cli/filesystem/cleanup.py +1 -3
- PyFunceble/cli/filesystem/dir_base.py +5 -1
- PyFunceble/cli/filesystem/dir_structure/backup.py +1 -2
- PyFunceble/cli/filesystem/dir_structure/base.py +0 -1
- PyFunceble/cli/filesystem/dir_structure/restore.py +5 -7
- PyFunceble/cli/filesystem/status_file.py +2 -3
- PyFunceble/cli/migrators/alembic.py +2 -4
- PyFunceble/cli/migrators/csv_file/inactive_source_delete.py +0 -1
- PyFunceble/cli/migrators/csv_file/whois_registrar_add.py +0 -1
- PyFunceble/cli/migrators/db_base.py +2 -2
- PyFunceble/cli/migrators/file_cleanup/base.py +3 -3
- PyFunceble/cli/migrators/file_cleanup/hashes_file.py +2 -3
- PyFunceble/cli/migrators/file_cleanup/mining_file.py +2 -3
- PyFunceble/cli/migrators/file_cleanup/production_config_file.py +2 -3
- PyFunceble/cli/migrators/mariadb/base.py +2 -4
- PyFunceble/cli/migrators/mariadb/file_and_status.py +1 -1
- PyFunceble/cli/migrators/mariadb/whois_record_idna_subject.py +0 -2
- PyFunceble/cli/processes/workers/base.py +0 -1
- PyFunceble/cli/processes/workers/chancy_producer.py +1 -2
- PyFunceble/cli/processes/workers/dir_files_sorter.py +6 -14
- PyFunceble/cli/processes/workers/file_sorter.py +2 -9
- PyFunceble/cli/processes/workers/migrator.py +0 -1
- PyFunceble/cli/processes/workers/producer.py +2 -4
- PyFunceble/cli/processes/workers/tester.py +2 -3
- PyFunceble/cli/scripts/iana.py +14 -10
- PyFunceble/cli/scripts/production.py +2 -2
- PyFunceble/cli/scripts/public_suffix.py +2 -2
- PyFunceble/cli/system/integrator.py +1 -1
- PyFunceble/cli/system/launcher.py +9 -10
- PyFunceble/cli/utils/stdout.py +1 -1
- PyFunceble/cli/utils/testing.py +6 -16
- PyFunceble/config/compare.py +10 -9
- PyFunceble/config/loader.py +7 -4
- PyFunceble/converter/input_line2subject.py +2 -2
- PyFunceble/converter/internal_url.py +1 -1
- PyFunceble/converter/rpz_input_line2subject.py +2 -4
- PyFunceble/converter/subject2complements.py +4 -1
- PyFunceble/converter/url2netloc.py +3 -3
- PyFunceble/converter/wildcard2subject.py +3 -3
- PyFunceble/helpers/command.py +1 -1
- PyFunceble/helpers/dict.py +4 -4
- PyFunceble/helpers/file.py +2 -2
- PyFunceble/helpers/list.py +10 -7
- PyFunceble/helpers/merge.py +2 -2
- PyFunceble/helpers/regex.py +9 -11
- PyFunceble/query/dns/nameserver.py +9 -19
- PyFunceble/query/dns/query_tool.py +64 -205
- PyFunceble/query/dns/resolver.py +64 -51
- PyFunceble/query/netinfo/address.py +4 -6
- PyFunceble/query/netinfo/base.py +1 -1
- PyFunceble/query/netinfo/hostbyaddr.py +5 -8
- PyFunceble/query/requests/adapter/base.py +3 -3
- PyFunceble/query/requests/adapter/http.py +0 -1
- PyFunceble/query/requests/requester.py +6 -6
- PyFunceble/query/whois/converter/expiration_date.py +19 -8
- PyFunceble/query/whois/converter/month2unified.py +4 -6
- PyFunceble/query/whois/converter/registrar.py +18 -5
- PyFunceble/query/whois/query_tool.py +15 -18
- PyFunceble/storage.py +1 -1
- {pyfunceble_dev-4.3.0a23.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/METADATA +107 -106
- {pyfunceble_dev-4.3.0a23.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/RECORD +99 -99
- {pyfunceble_dev-4.3.0a23.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/WHEEL +0 -0
- {pyfunceble_dev-4.3.0a23.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/entry_points.txt +0 -0
- {pyfunceble_dev-4.3.0a23.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/licenses/LICENSE +0 -0
- {pyfunceble_dev-4.3.0a23.dist-info → pyfunceble_dev-4.3.0a24.dist-info}/top_level.txt +0 -0
@@ -511,8 +511,11 @@ class AvailabilityCheckerBase(CheckerBase):
|
|
511
511
|
self.ip_syntax_checker.subject = self.idna_subject
|
512
512
|
self.url_syntax_checker.subject = self.idna_subject
|
513
513
|
|
514
|
-
self.status
|
515
|
-
|
514
|
+
if self.status.subject_kind is None:
|
515
|
+
self.status = AvailabilityCheckerStatus()
|
516
|
+
self.params = AvailabilityCheckerParams()
|
517
|
+
self.status.params = self.params
|
518
|
+
|
516
519
|
self.status.dns_lookup_record = self.dns_query_tool.lookup_record
|
517
520
|
self.status.whois_lookup_record = self.whois_query_tool.lookup_record
|
518
521
|
|
@@ -53,6 +53,8 @@ License:
|
|
53
53
|
import PyFunceble.facility
|
54
54
|
import PyFunceble.storage
|
55
55
|
from PyFunceble.checker.availability.base import AvailabilityCheckerBase
|
56
|
+
from PyFunceble.checker.availability.params import AvailabilityCheckerParams
|
57
|
+
from PyFunceble.checker.availability.status import AvailabilityCheckerStatus
|
56
58
|
from PyFunceble.checker.reputation.domain import DomainReputationChecker
|
57
59
|
|
58
60
|
|
@@ -87,6 +89,22 @@ class DomainAvailabilityChecker(AvailabilityCheckerBase):
|
|
87
89
|
WHOIS datasets.
|
88
90
|
"""
|
89
91
|
|
92
|
+
def subject_propagator(self) -> "DomainAvailabilityChecker":
|
93
|
+
"""
|
94
|
+
Propagate the currently set subject.
|
95
|
+
|
96
|
+
.. warning::
|
97
|
+
You are not invited to run this method directly.
|
98
|
+
"""
|
99
|
+
|
100
|
+
self.status = AvailabilityCheckerStatus()
|
101
|
+
self.params = AvailabilityCheckerParams()
|
102
|
+
self.status.params = self.params
|
103
|
+
|
104
|
+
self.status.subject_kind = "domain"
|
105
|
+
|
106
|
+
return super().subject_propagator()
|
107
|
+
|
90
108
|
def try_to_query_status_from_reputation(self) -> "DomainAvailabilityChecker":
|
91
109
|
"""
|
92
110
|
Tries to query the status from the reputation lookup.
|
@@ -67,7 +67,7 @@ class ExtraRuleHandlerBase:
|
|
67
67
|
"""
|
68
68
|
Provides the base of all extra rules handler.
|
69
69
|
|
70
|
-
:param
|
70
|
+
:param status:
|
71
71
|
The previously gathered status.
|
72
72
|
:type status:
|
73
73
|
:class:`~PyFunceble.checker.availability.status.AvailabilityCheckerStatus`
|
@@ -167,7 +167,7 @@ class ExtraRuleHandlerBase:
|
|
167
167
|
Provides a viable request URL.
|
168
168
|
"""
|
169
169
|
|
170
|
-
if
|
170
|
+
if self.status.idna_subject.startswith(("http:", "https:")):
|
171
171
|
return self.status.idna_subject
|
172
172
|
return f"http://{self.status.idna_subject}:80"
|
173
173
|
|
@@ -177,7 +177,7 @@ class ExtraRuleHandlerBase:
|
|
177
177
|
Provides a viable request URL that default to an HTTPS URL.
|
178
178
|
"""
|
179
179
|
|
180
|
-
if
|
180
|
+
if self.status.idna_subject.startswith(("http:", "https:")):
|
181
181
|
return self.status.idna_subject
|
182
182
|
return f"https://{self.status.idna_subject}:443"
|
183
183
|
|
@@ -226,7 +226,7 @@ class ExtraRuleHandlerBase:
|
|
226
226
|
Do a request and store its response into the `req` attribute.
|
227
227
|
|
228
228
|
:param bool allow_redirects:
|
229
|
-
Whether we
|
229
|
+
Whether we should follow the redirection - or not.
|
230
230
|
"""
|
231
231
|
|
232
232
|
self.req = self.requester.get(self.req_url, allow_redirects=allow_redirects)
|
@@ -132,7 +132,7 @@ class DNSRulesHandler(ExtraRuleHandlerBase):
|
|
132
132
|
if not self.regex_helper.set_regex(regex).match(
|
133
133
|
self.status.netloc, return_match=False
|
134
134
|
):
|
135
|
-
|
135
|
+
continue
|
136
136
|
|
137
137
|
for ruler, params in rulesets:
|
138
138
|
if self.status.status_after_extra_rules:
|
@@ -64,7 +64,7 @@ class EToxicHandler(ExtraRuleHandlerBase):
|
|
64
64
|
:class:`~PyFunceble.checker.availability.status.AvailabilityCheckerStatus`
|
65
65
|
"""
|
66
66
|
|
67
|
-
MATCHES =
|
67
|
+
MATCHES = (
|
68
68
|
".0wn0.com",
|
69
69
|
".123.st",
|
70
70
|
".1forum.biz",
|
@@ -282,7 +282,7 @@ class EToxicHandler(ExtraRuleHandlerBase):
|
|
282
282
|
".yoo7.com",
|
283
283
|
".ze-43eme.com",
|
284
284
|
".zxr7team.com",
|
285
|
-
|
285
|
+
)
|
286
286
|
|
287
287
|
@ExtraRuleHandlerBase.ensure_status_is_given
|
288
288
|
@ExtraRuleHandlerBase.setup_status_before
|
@@ -294,7 +294,7 @@ class EToxicHandler(ExtraRuleHandlerBase):
|
|
294
294
|
)
|
295
295
|
|
296
296
|
if self.status.status_before_extra_rules == PyFunceble.storage.STATUS.up:
|
297
|
-
if
|
297
|
+
if self.status.netloc.endswith(self.MATCHES):
|
298
298
|
self.do_on_header_match(
|
299
299
|
self.req_url,
|
300
300
|
matches={"location": [f"/{self.status.netloc}", "/search/"]},
|
@@ -65,6 +65,25 @@ class ParkedRulesHandler(ExtraRuleHandlerBase):
|
|
65
65
|
:class:`~PyFunceble.checker.availability.status.AvailabilityCheckerStatus`
|
66
66
|
"""
|
67
67
|
|
68
|
+
PARKED_CONTENT_PATTERNS = (
|
69
|
+
'class="parked-domains',
|
70
|
+
"buy-domain",
|
71
|
+
"this domain name is parked",
|
72
|
+
"this domain is parked",
|
73
|
+
"interested in this domain",
|
74
|
+
"really cool domain parked",
|
75
|
+
"domain is for sale",
|
76
|
+
'_trackpageview("/parked/[% parked_type %]/',
|
77
|
+
"| parked domain",
|
78
|
+
"parked banner",
|
79
|
+
"contact with domain owner",
|
80
|
+
"web page is parked",
|
81
|
+
"buy or lease this domain",
|
82
|
+
"parked domain name on ",
|
83
|
+
"it is currently parked by the owner",
|
84
|
+
"parked page for",
|
85
|
+
)
|
86
|
+
|
68
87
|
def _switch_down_by_cookie(self) -> "ParkedRulesHandler":
|
69
88
|
"""
|
70
89
|
Tries to switch the status to inactive if some special cookies where found.
|
@@ -75,31 +94,14 @@ class ParkedRulesHandler(ExtraRuleHandlerBase):
|
|
75
94
|
|
76
95
|
return self
|
77
96
|
|
78
|
-
def
|
97
|
+
def _switch_down_by_content(self) -> "ParkedRulesHandler":
|
79
98
|
"""
|
80
99
|
Tries to switch the status to inactive if some relative content were found.
|
81
100
|
"""
|
82
101
|
|
83
102
|
content = self.req.text.lower()
|
84
103
|
|
85
|
-
if (
|
86
|
-
'class="parked-domains' in content
|
87
|
-
or "buy-domain" in content
|
88
|
-
or "this domain name is parked" in content
|
89
|
-
or "this domain is parked" in content
|
90
|
-
or "interested in this domain" in content
|
91
|
-
or "really cool domain parked" in content
|
92
|
-
or "domain is for sale" in content
|
93
|
-
or '_trackpageview("/parked/[% parked_type %]/' in content
|
94
|
-
or "| parked domain" in content
|
95
|
-
or "parked banner" in content
|
96
|
-
or "contact with domain owner" in content
|
97
|
-
or "web page is parked" in content
|
98
|
-
or "buy or lease this domain" in content
|
99
|
-
or "parked domain name on " in content
|
100
|
-
or "it is currently parked by the owner" in content
|
101
|
-
or "parked page for" in content
|
102
|
-
):
|
104
|
+
if any(x in content for x in self.PARKED_CONTENT_PATTERNS):
|
103
105
|
self.switch_to_down()
|
104
106
|
|
105
107
|
return self
|
@@ -120,7 +122,7 @@ class ParkedRulesHandler(ExtraRuleHandlerBase):
|
|
120
122
|
self._switch_down_by_cookie()
|
121
123
|
|
122
124
|
if not self.status.status_after_extra_rules:
|
123
|
-
self.
|
125
|
+
self._switch_down_by_content()
|
124
126
|
|
125
127
|
PyFunceble.facility.Logger.info(
|
126
128
|
"Finished to check %r against our own set of parked rules.",
|
@@ -58,7 +58,6 @@ import PyFunceble.facility
|
|
58
58
|
import PyFunceble.storage
|
59
59
|
from PyFunceble.checker.availability.extras.base import ExtraRuleHandlerBase
|
60
60
|
from PyFunceble.checker.availability.status import AvailabilityCheckerStatus
|
61
|
-
from PyFunceble.helpers.regex import RegexHelper
|
62
61
|
|
63
62
|
|
64
63
|
class ExtraRulesHandler(ExtraRuleHandlerBase):
|
@@ -106,7 +105,7 @@ class ExtraRulesHandler(ExtraRuleHandlerBase):
|
|
106
105
|
r"\.translate\.goog$": [(self.switch_to_down_if_status_code, 403)],
|
107
106
|
r"\.tumblr\.com$": [(self.switch_to_down_if_status_code, 404)],
|
108
107
|
r"\.vercel\.app$": [
|
109
|
-
(self.switch_to_down_if_status_code,
|
108
|
+
(self.switch_to_down_if_status_code, 451),
|
110
109
|
self.handle_vercel_dot_app,
|
111
110
|
],
|
112
111
|
r"\.web\.app$": [(self.switch_to_down_if_status_code, 404)],
|
@@ -119,8 +118,8 @@ class ExtraRulesHandler(ExtraRuleHandlerBase):
|
|
119
118
|
(self.switch_to_down_if_status_code, 410),
|
120
119
|
self.handle_wordpress_dot_com,
|
121
120
|
],
|
122
|
-
r"\.weebly\.com$": [(self.switch_to_down_if_status_code, {
|
123
|
-
r"\.zzz\.com\.ua$": [(self.switch_to_down_if_status_code, {
|
121
|
+
r"\.weebly\.com$": [(self.switch_to_down_if_status_code, {404, 406})],
|
122
|
+
r"\.zzz\.com\.ua$": [(self.switch_to_down_if_status_code, {402})],
|
124
123
|
}
|
125
124
|
|
126
125
|
if PyFunceble.facility.ConfigLoader.is_already_loaded():
|
@@ -135,15 +134,12 @@ class ExtraRulesHandler(ExtraRuleHandlerBase):
|
|
135
134
|
Handles the standard regex lookup case.
|
136
135
|
"""
|
137
136
|
|
138
|
-
regex_helper = RegexHelper()
|
139
|
-
|
140
137
|
for (
|
141
138
|
regex,
|
142
139
|
data,
|
143
140
|
) in regex_registry.items():
|
144
|
-
broken = False
|
145
141
|
for element in data:
|
146
|
-
if not regex_helper.set_regex(regex).match(
|
142
|
+
if not self.regex_helper.set_regex(regex).match(
|
147
143
|
self.status.netloc, return_match=False
|
148
144
|
):
|
149
145
|
continue
|
@@ -154,11 +150,7 @@ class ExtraRulesHandler(ExtraRuleHandlerBase):
|
|
154
150
|
element()
|
155
151
|
|
156
152
|
if self.status.status_after_extra_rules:
|
157
|
-
|
158
|
-
break
|
159
|
-
|
160
|
-
if broken:
|
161
|
-
break
|
153
|
+
return self
|
162
154
|
|
163
155
|
return self
|
164
156
|
|
@@ -116,10 +116,9 @@ class SubjectSwitchRulesHandler(ExtraRuleHandlerBase):
|
|
116
116
|
if netloc == self.status.idna_subject and netloc not in variations:
|
117
117
|
continue
|
118
118
|
|
119
|
-
if not start_path
|
120
|
-
|
121
|
-
|
122
|
-
elif start_path != local_path:
|
119
|
+
if (not start_path and local_path != "/") or (
|
120
|
+
start_path and start_path != local_path
|
121
|
+
):
|
123
122
|
continue
|
124
123
|
|
125
124
|
self.switch_to_down()
|
@@ -141,7 +140,7 @@ class SubjectSwitchRulesHandler(ExtraRuleHandlerBase):
|
|
141
140
|
)
|
142
141
|
|
143
142
|
try:
|
144
|
-
if
|
143
|
+
if self.status.netloc.startswith(("www.", "m.")):
|
145
144
|
self.do_request()
|
146
145
|
|
147
146
|
if not self.status.status_after_extra_rules:
|
@@ -53,6 +53,8 @@ License:
|
|
53
53
|
import PyFunceble.facility
|
54
54
|
import PyFunceble.storage
|
55
55
|
from PyFunceble.checker.availability.base import AvailabilityCheckerBase
|
56
|
+
from PyFunceble.checker.availability.params import AvailabilityCheckerParams
|
57
|
+
from PyFunceble.checker.availability.status import AvailabilityCheckerStatus
|
56
58
|
from PyFunceble.checker.reputation.ip import IPReputationChecker
|
57
59
|
|
58
60
|
|
@@ -87,6 +89,22 @@ class IPAvailabilityChecker(AvailabilityCheckerBase):
|
|
87
89
|
WHOIS datasets.
|
88
90
|
"""
|
89
91
|
|
92
|
+
def subject_propagator(self) -> "IPAvailabilityChecker":
|
93
|
+
"""
|
94
|
+
Propagate the currently set subject.
|
95
|
+
|
96
|
+
.. warning::
|
97
|
+
You are not invited to run this method directly.
|
98
|
+
"""
|
99
|
+
|
100
|
+
self.status = AvailabilityCheckerStatus()
|
101
|
+
self.params = AvailabilityCheckerParams()
|
102
|
+
self.status.params = self.params
|
103
|
+
|
104
|
+
self.status.subject_kind = "ip"
|
105
|
+
|
106
|
+
return super().subject_propagator()
|
107
|
+
|
90
108
|
def try_to_query_status_from_reputation(self) -> "IPAvailabilityChecker":
|
91
109
|
"""
|
92
110
|
Tries to query the status from the reputation lookup.
|
@@ -60,7 +60,7 @@ from PyFunceble.checker.params_base import CheckerParamsBase
|
|
60
60
|
@dataclasses.dataclass
|
61
61
|
class AvailabilityCheckerParams(CheckerParamsBase):
|
62
62
|
"""
|
63
|
-
Provides the description of an availability checker
|
63
|
+
Provides the description of an availability checker parameters.
|
64
64
|
"""
|
65
65
|
|
66
66
|
use_extra_rules: Optional[bool] = None
|
@@ -64,7 +64,7 @@ from PyFunceble.query.record.whois import WhoisQueryToolRecord
|
|
64
64
|
@dataclasses.dataclass
|
65
65
|
class AvailabilityCheckerStatus(CheckerStatusBase):
|
66
66
|
"""
|
67
|
-
Provides the description of an
|
67
|
+
Provides the description of an availability status.
|
68
68
|
"""
|
69
69
|
|
70
70
|
# pylint: disable=too-many-instance-attributes
|
@@ -100,9 +100,14 @@ class AvailabilityCheckerStatus(CheckerStatusBase):
|
|
100
100
|
http_status_code: Optional[int] = None
|
101
101
|
|
102
102
|
def __post_init__(self) -> None:
|
103
|
-
self.dns_lookup_record
|
104
|
-
|
105
|
-
|
103
|
+
if self.dns_lookup_record is None:
|
104
|
+
self.dns_lookup_record = DNSQueryToolRecord()
|
105
|
+
|
106
|
+
if self.whois_lookup_record is None:
|
107
|
+
self.whois_lookup_record = WhoisQueryToolRecord()
|
108
|
+
|
109
|
+
if not hasattr(self, "params") or self.params is None:
|
110
|
+
self.params = AvailabilityCheckerParams()
|
106
111
|
|
107
112
|
def is_special(self) -> bool:
|
108
113
|
"""
|
@@ -53,6 +53,7 @@ License:
|
|
53
53
|
import PyFunceble.facility
|
54
54
|
import PyFunceble.storage
|
55
55
|
from PyFunceble.checker.availability.base import AvailabilityCheckerBase
|
56
|
+
from PyFunceble.checker.availability.params import AvailabilityCheckerParams
|
56
57
|
from PyFunceble.checker.availability.status import AvailabilityCheckerStatus
|
57
58
|
from PyFunceble.checker.reputation.url import URLReputationChecker
|
58
59
|
from PyFunceble.checker.syntax.url import URLSyntaxChecker
|
@@ -111,7 +112,11 @@ class URLAvailabilityChecker(AvailabilityCheckerBase):
|
|
111
112
|
self.url_syntax_checker.subject = self.idna_subject
|
112
113
|
|
113
114
|
self.status = AvailabilityCheckerStatus()
|
115
|
+
self.params = AvailabilityCheckerParams()
|
114
116
|
self.status.params = self.params
|
117
|
+
|
118
|
+
self.status.subject_kind = "url"
|
119
|
+
|
115
120
|
self.status.dns_lookup_record = self.dns_query_tool.lookup_record
|
116
121
|
self.status.whois_lookup_record = None
|
117
122
|
|
@@ -122,6 +127,7 @@ class URLAvailabilityChecker(AvailabilityCheckerBase):
|
|
122
127
|
).get_converted()
|
123
128
|
|
124
129
|
self.status.status = None
|
130
|
+
self.status.status_source = None
|
125
131
|
|
126
132
|
self.query_common_checker()
|
127
133
|
|
PyFunceble/checker/base.py
CHANGED
@@ -62,6 +62,7 @@ import PyFunceble.storage
|
|
62
62
|
from PyFunceble.checker.params_base import CheckerParamsBase
|
63
63
|
from PyFunceble.checker.status_base import CheckerStatusBase
|
64
64
|
from PyFunceble.converter.url2netloc import Url2Netloc
|
65
|
+
from PyFunceble.helpers.regex import RegexHelper
|
65
66
|
from PyFunceble.query.platform import PlatformQueryTool
|
66
67
|
|
67
68
|
|
@@ -88,6 +89,7 @@ class CheckerBase:
|
|
88
89
|
_idna_subject: Optional[str] = None
|
89
90
|
|
90
91
|
url2netloc: Optional[Url2Netloc] = None
|
92
|
+
regex_helper: Optional[RegexHelper] = None
|
91
93
|
|
92
94
|
db_session: Optional[Session] = None
|
93
95
|
platform_query_tool: Optional[PlatformQueryTool] = None
|
@@ -105,6 +107,7 @@ class CheckerBase:
|
|
105
107
|
) -> None:
|
106
108
|
self.platform_query_tool = PlatformQueryTool()
|
107
109
|
self.url2netloc = Url2Netloc()
|
110
|
+
self.regex_helper = RegexHelper()
|
108
111
|
|
109
112
|
if self.params is None:
|
110
113
|
self.params = CheckerParamsBase()
|
@@ -383,6 +386,7 @@ class CheckerBase:
|
|
383
386
|
self.idna_subject
|
384
387
|
).get_converted()
|
385
388
|
self.status.status = None
|
389
|
+
self.status.status_source = None
|
386
390
|
|
387
391
|
return self.query_common_checker()
|
388
392
|
|
@@ -130,8 +130,11 @@ class ReputationCheckerBase(CheckerBase):
|
|
130
130
|
self.ip_syntax_checker.subject = self.idna_subject
|
131
131
|
self.url_syntax_checker.subject = self.idna_subject
|
132
132
|
|
133
|
-
self.status
|
134
|
-
|
133
|
+
if self.status.subject_kind is None:
|
134
|
+
self.status = ReputationCheckerStatus()
|
135
|
+
self.params = ReputationCheckerParams()
|
136
|
+
self.status.params = self.params
|
137
|
+
|
135
138
|
self.status.dns_lookup_record = self.dns_query_tool.lookup_record
|
136
139
|
|
137
140
|
return super().subject_propagator()
|
@@ -53,6 +53,8 @@ License:
|
|
53
53
|
from typing import List, Optional
|
54
54
|
|
55
55
|
from PyFunceble.checker.reputation.base import ReputationCheckerBase
|
56
|
+
from PyFunceble.checker.reputation.params import ReputationCheckerParams
|
57
|
+
from PyFunceble.checker.reputation.status import ReputationCheckerStatus
|
56
58
|
|
57
59
|
|
58
60
|
class DomainReputationChecker(ReputationCheckerBase):
|
@@ -66,5 +68,14 @@ class DomainReputationChecker(ReputationCheckerBase):
|
|
66
68
|
status gathering.
|
67
69
|
"""
|
68
70
|
|
71
|
+
def subject_propagator(self) -> "DomainReputationChecker":
|
72
|
+
self.status = ReputationCheckerStatus()
|
73
|
+
self.params = ReputationCheckerParams()
|
74
|
+
self.status.params = self.params
|
75
|
+
|
76
|
+
self.status.subject_kind = "domain"
|
77
|
+
|
78
|
+
return super().subject_propagator()
|
79
|
+
|
69
80
|
def query_a_record(self) -> Optional[List[str]]:
|
70
81
|
return self.dns_query_tool.set_query_record_type("A").query()
|
@@ -53,6 +53,8 @@ License:
|
|
53
53
|
from typing import List, Optional
|
54
54
|
|
55
55
|
from PyFunceble.checker.reputation.base import ReputationCheckerBase
|
56
|
+
from PyFunceble.checker.reputation.params import ReputationCheckerParams
|
57
|
+
from PyFunceble.checker.reputation.status import ReputationCheckerStatus
|
56
58
|
|
57
59
|
|
58
60
|
class IPReputationChecker(ReputationCheckerBase):
|
@@ -66,6 +68,15 @@ class IPReputationChecker(ReputationCheckerBase):
|
|
66
68
|
status gathering.
|
67
69
|
"""
|
68
70
|
|
71
|
+
def subject_propagator(self) -> "IPReputationChecker":
|
72
|
+
self.status = ReputationCheckerStatus()
|
73
|
+
self.params = ReputationCheckerParams()
|
74
|
+
self.status.params = self.params
|
75
|
+
|
76
|
+
self.status.subject_kind = "ip"
|
77
|
+
|
78
|
+
return super().subject_propagator()
|
79
|
+
|
69
80
|
def query_a_record(self) -> Optional[List[str]]:
|
70
81
|
result = set()
|
71
82
|
|
@@ -62,7 +62,7 @@ from PyFunceble.query.record.dns import DNSQueryToolRecord
|
|
62
62
|
@dataclasses.dataclass
|
63
63
|
class ReputationCheckerStatus(CheckerStatusBase):
|
64
64
|
"""
|
65
|
-
Provides the description of
|
65
|
+
Provides the description of a reputation status.
|
66
66
|
"""
|
67
67
|
|
68
68
|
# pylint: disable=too-many-instance-attributes
|
@@ -53,6 +53,8 @@ License:
|
|
53
53
|
from typing import List, Optional
|
54
54
|
|
55
55
|
from PyFunceble.checker.reputation.base import ReputationCheckerBase
|
56
|
+
from PyFunceble.checker.reputation.params import ReputationCheckerParams
|
57
|
+
from PyFunceble.checker.reputation.status import ReputationCheckerStatus
|
56
58
|
from PyFunceble.checker.syntax.ip import IPSyntaxChecker
|
57
59
|
from PyFunceble.converter.url2netloc import Url2Netloc
|
58
60
|
|
@@ -68,6 +70,15 @@ class URLReputationChecker(ReputationCheckerBase):
|
|
68
70
|
status gathering.
|
69
71
|
"""
|
70
72
|
|
73
|
+
def subject_propagator(self) -> "URLReputationChecker":
|
74
|
+
self.status = ReputationCheckerStatus()
|
75
|
+
self.params = ReputationCheckerParams()
|
76
|
+
self.status.params = self.params
|
77
|
+
|
78
|
+
self.status.subject_kind = "url"
|
79
|
+
|
80
|
+
return super().subject_propagator()
|
81
|
+
|
71
82
|
def query_a_record(self) -> Optional[List[str]]:
|
72
83
|
url_base = Url2Netloc(self.status.subject).get_converted()
|
73
84
|
|
@@ -96,7 +107,7 @@ class URLReputationChecker(ReputationCheckerBase):
|
|
96
107
|
|
97
108
|
self.dns_query_tool.subject = self.idna_subject
|
98
109
|
|
99
|
-
return result
|
110
|
+
return list(result)
|
100
111
|
|
101
112
|
result = (
|
102
113
|
self.dns_query_tool.set_query_record_type("A").set_subject(url_base).query()
|
@@ -94,7 +94,10 @@ class SyntaxCheckerBase(CheckerBase):
|
|
94
94
|
You are not invited to run this method directly.
|
95
95
|
"""
|
96
96
|
|
97
|
-
self.status
|
97
|
+
if self.status.subject_kind is None:
|
98
|
+
self.status = SyntaxCheckerStatus()
|
99
|
+
self.params = SyntaxCheckerParams()
|
100
|
+
self.status.params = self.params
|
98
101
|
|
99
102
|
return super().subject_propagator()
|
100
103
|
|
@@ -56,6 +56,7 @@ from sqlalchemy.orm import Session
|
|
56
56
|
|
57
57
|
from PyFunceble.checker.syntax.base import SyntaxCheckerBase
|
58
58
|
from PyFunceble.checker.syntax.domain_base import DomainSyntaxCheckerBase
|
59
|
+
from PyFunceble.checker.syntax.params import SyntaxCheckerParams
|
59
60
|
from PyFunceble.checker.syntax.second_lvl_domain import SecondLvlDomainSyntaxChecker
|
60
61
|
from PyFunceble.checker.syntax.status import SyntaxCheckerStatus
|
61
62
|
from PyFunceble.checker.syntax.subdomain import SubDomainSyntaxChecker
|
@@ -95,6 +96,9 @@ class DomainSyntaxChecker(DomainSyntaxCheckerBase, SyntaxCheckerBase):
|
|
95
96
|
self.subdomain_checker.subject = self.idna_subject
|
96
97
|
|
97
98
|
self.status = SyntaxCheckerStatus()
|
99
|
+
self.params = SyntaxCheckerParams()
|
100
|
+
self.status.params = self.params
|
101
|
+
|
98
102
|
self.status.subject_kind = "domain"
|
99
103
|
|
100
104
|
return super().subject_propagator()
|
PyFunceble/checker/syntax/ip.py
CHANGED
@@ -56,6 +56,7 @@ from PyFunceble.checker.base import CheckerBase
|
|
56
56
|
from PyFunceble.checker.syntax.base import SyntaxCheckerBase
|
57
57
|
from PyFunceble.checker.syntax.ipv4 import IPv4SyntaxChecker
|
58
58
|
from PyFunceble.checker.syntax.ipv6 import IPv6SyntaxChecker
|
59
|
+
from PyFunceble.checker.syntax.params import SyntaxCheckerParams
|
59
60
|
from PyFunceble.checker.syntax.status import SyntaxCheckerStatus
|
60
61
|
|
61
62
|
|
@@ -88,6 +89,9 @@ class IPSyntaxChecker(SyntaxCheckerBase):
|
|
88
89
|
self.ipv6_checker.subject = self.idna_subject
|
89
90
|
|
90
91
|
self.status = SyntaxCheckerStatus()
|
92
|
+
self.params = SyntaxCheckerParams()
|
93
|
+
self.status.params = self.params
|
94
|
+
|
91
95
|
self.status.subject_kind = "ip"
|
92
96
|
|
93
97
|
return super().subject_propagator()
|
@@ -53,7 +53,6 @@ License:
|
|
53
53
|
import ipaddress
|
54
54
|
|
55
55
|
from PyFunceble.checker.base import CheckerBase
|
56
|
-
from PyFunceble.helpers.regex import RegexHelper
|
57
56
|
|
58
57
|
|
59
58
|
class IPv4SyntaxChecker(CheckerBase):
|
@@ -121,19 +120,17 @@ class IPv4SyntaxChecker(CheckerBase):
|
|
121
120
|
Validate the given subject.
|
122
121
|
"""
|
123
122
|
|
124
|
-
|
123
|
+
for method in (
|
124
|
+
ipaddress.ip_address,
|
125
|
+
ipaddress.ip_interface,
|
126
|
+
lambda x: ipaddress.ip_network(x, strict=False),
|
127
|
+
):
|
125
128
|
try:
|
126
|
-
return
|
129
|
+
return method(self.idna_subject).version == 4
|
127
130
|
except ValueError:
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
return (
|
132
|
-
ipaddress.ip_network(self.idna_subject, strict=False).version
|
133
|
-
== 4
|
134
|
-
)
|
135
|
-
except ValueError:
|
136
|
-
return False
|
131
|
+
continue
|
132
|
+
|
133
|
+
return False
|
137
134
|
|
138
135
|
@CheckerBase.ensure_subject_is_given
|
139
136
|
def is_valid_range(self) -> bool:
|
@@ -163,7 +160,7 @@ class IPv4SyntaxChecker(CheckerBase):
|
|
163
160
|
or address.is_loopback
|
164
161
|
or address.is_link_local
|
165
162
|
or not address.is_global
|
166
|
-
or
|
163
|
+
or self.regex_helper.set_regex(self._get_regex_reserved_ip()).match(
|
167
164
|
self.idna_subject, return_match=False
|
168
165
|
)
|
169
166
|
)
|
@@ -69,19 +69,17 @@ class IPv6SyntaxChecker(CheckerBase):
|
|
69
69
|
Validate the given subject.
|
70
70
|
"""
|
71
71
|
|
72
|
-
|
72
|
+
for method in (
|
73
|
+
ipaddress.ip_address,
|
74
|
+
ipaddress.ip_interface,
|
75
|
+
lambda x: ipaddress.ip_network(x, strict=False),
|
76
|
+
):
|
73
77
|
try:
|
74
|
-
return
|
78
|
+
return method(self.idna_subject).version == 6
|
75
79
|
except ValueError:
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
return (
|
80
|
-
ipaddress.ip_network(self.idna_subject, strict=False).version
|
81
|
-
== 6
|
82
|
-
)
|
83
|
-
except ValueError:
|
84
|
-
return False
|
80
|
+
continue
|
81
|
+
|
82
|
+
return False
|
85
83
|
|
86
84
|
@CheckerBase.ensure_subject_is_given
|
87
85
|
def is_valid_range(self) -> bool:
|
@@ -59,5 +59,5 @@ from PyFunceble.checker.params_base import CheckerParamsBase
|
|
59
59
|
@dataclasses.dataclass
|
60
60
|
class SyntaxCheckerParams(CheckerParamsBase):
|
61
61
|
"""
|
62
|
-
Provides the description of a syntax checker
|
62
|
+
Provides the description of a syntax checker parameters.
|
63
63
|
"""
|