Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
surykatka
Commits
e3422797
Commit
e3422797
authored
Jun 20, 2024
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Whois: handle connection error.
parent
9274f2be
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
25 deletions
+67
-25
src/surykatka/domain.py
src/surykatka/domain.py
+30
-25
tests/test_domain.py
tests/test_domain.py
+37
-0
No files found.
src/surykatka/domain.py
View file @
e3422797
...
@@ -125,9 +125,12 @@ def queryWhois(db, status_id, domain_text):
...
@@ -125,9 +125,12 @@ def queryWhois(db, status_id, domain_text):
# Error trying to connect to socket: closing socket
# Error trying to connect to socket: closing socket
_stdout
=
sys
.
stdout
_stdout
=
sys
.
stdout
sys
.
stdout
=
open
(
os
.
devnull
,
"w"
)
sys
.
stdout
=
open
(
os
.
devnull
,
"w"
)
try
:
whois_dict
=
whois
.
whois
(
domain_text
)
whois_dict
=
whois
.
whois
(
domain_text
)
sys
.
stdout
=
_stdout
except
ConnectionResetError
:
arg_list
=
[
""
]
*
16
whois_dict
=
{}
else
:
arg_list
=
[]
arg_list
=
[]
for
arg
in
[
for
arg
in
[
whois_dict
.
registrar
,
whois_dict
.
registrar
,
...
@@ -150,6 +153,8 @@ def queryWhois(db, status_id, domain_text):
...
@@ -150,6 +153,8 @@ def queryWhois(db, status_id, domain_text):
if
type
(
arg
)
==
list
:
if
type
(
arg
)
==
list
:
arg
=
arg
[
0
]
arg
=
arg
[
0
]
arg_list
.
append
(
arg
)
arg_list
.
append
(
arg
)
finally
:
sys
.
stdout
=
_stdout
logWhoisQuery
(
db
,
status_id
,
domain_text
,
*
arg_list
)
logWhoisQuery
(
db
,
status_id
,
domain_text
,
*
arg_list
)
return
whois_dict
return
whois_dict
tests/test_domain.py
View file @
e3422797
...
@@ -847,6 +847,43 @@ class SurykatkaDomainTestCase(unittest.TestCase):
...
@@ -847,6 +847,43 @@ class SurykatkaDomainTestCase(unittest.TestCase):
assert
self
.
db
.
DomainChange
.
get
().
status_id
==
status_id
assert
self
.
db
.
DomainChange
.
get
().
status_id
==
status_id
assert
result
==
mock_answer
assert
result
==
mock_answer
def
test_queryWhois_ConnectionResetError
(
self
):
domain
=
"http://example.org"
status_id
=
logStatus
(
self
.
db
,
"foo"
)
with
mock
.
patch
(
"surykatka.domain.whois.whois"
)
as
mock_whois
:
def
sideEffect
(
*
args
,
**
kw
):
raise
ConnectionResetError
()
mock_whois
.
side_effect
=
sideEffect
result
=
queryWhois
(
self
.
db
,
status_id
,
domain
)
assert
mock_whois
.
call_count
==
1
mock_whois
.
assert_called_with
(
domain
)
assert
self
.
db
.
DomainChange
.
select
().
count
()
==
1
assert
self
.
db
.
DomainChange
.
get
().
domain
==
domain
assert
self
.
db
.
DomainChange
.
get
().
registrar
==
""
assert
self
.
db
.
DomainChange
.
get
().
whois_server
==
""
assert
self
.
db
.
DomainChange
.
get
().
creation_date
==
""
assert
self
.
db
.
DomainChange
.
get
().
updated_date
==
""
assert
self
.
db
.
DomainChange
.
get
().
expiration_date
==
""
assert
self
.
db
.
DomainChange
.
get
().
name_servers
==
""
assert
self
.
db
.
DomainChange
.
get
().
whois_status
==
""
assert
self
.
db
.
DomainChange
.
get
().
emails
==
""
assert
self
.
db
.
DomainChange
.
get
().
dnssec
==
""
assert
self
.
db
.
DomainChange
.
get
().
name
==
""
assert
self
.
db
.
DomainChange
.
get
().
org
==
""
assert
self
.
db
.
DomainChange
.
get
().
address
==
""
assert
self
.
db
.
DomainChange
.
get
().
city
==
""
assert
self
.
db
.
DomainChange
.
get
().
state
==
""
assert
self
.
db
.
DomainChange
.
get
().
zipcode
==
""
assert
self
.
db
.
DomainChange
.
get
().
country
==
""
assert
self
.
db
.
DomainChange
.
get
().
status_id
==
status_id
assert
result
==
{}
################################################
################################################
# packDns
# packDns
################################################
################################################
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment