Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
noms-de-domaine-organismes-secteur-public
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
DINUM
noms-de-domaine-organismes-secteur-public
Commits
a233a5d7
Verified
Commit
a233a5d7
authored
1 month ago
by
Julien Palard
Browse files
Options
Downloads
Patches
Plain Diff
Bump psycopg.
parent
84f9a4b8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/import-from-ct-logs.py
+15
-12
15 additions, 12 deletions
scripts/import-from-ct-logs.py
scripts/requirements.txt
+1
-1
1 addition, 1 deletion
scripts/requirements.txt
with
16 additions
and
13 deletions
scripts/import-from-ct-logs.py
+
15
−
12
View file @
a233a5d7
...
...
@@ -17,9 +17,9 @@ So the next maintainer can import using:
import
argparse
from
pathlib
import
Path
import
psycopg
2
import
psycopg
from
public_domain
import
Domain
,
NON_PUBLIC_DOMAINS
,
parse_csv_file
,
write_csv_file
from
public_domain
import
NON_PUBLIC_DOMAINS
,
Domain
,
parse_csv_file
,
write_csv_file
ROOT
=
Path
(
__file__
).
resolve
().
parent
.
parent
FILE
=
ROOT
/
"
domains.csv
"
...
...
@@ -27,19 +27,22 @@ FILE = ROOT / "domains.csv"
def
query_ct_logs
(
last_id
):
"""
Query crt.sh using their postgres public API.
"""
conn
=
psycopg2
.
connect
(
dbname
=
"
certwatch
"
,
user
=
"
guest
"
,
host
=
"
crt.sh
"
)
conn
.
set_session
(
readonly
=
True
,
autocommit
=
True
)
cur
=
conn
.
cursor
()
cur
.
execute
(
"""
SELECT id, altnames.*, x509_subjectname(certificate) subject
FROM certificate, LATERAL (SELECT * FROM x509_altnames(certificate)) altnames
WHERE plainto_tsquery(
'
gouv.fr
'
) @@ identities(certificate) AND id > %s
"""
,
(
last_id
,),
)
with
psycopg
.
connect
(
dbname
=
"
certwatch
"
,
user
=
"
guest
"
,
host
=
"
crt.sh
"
,
autocommit
=
True
)
as
conn
:
conn
.
read_only
=
True
with
conn
.
cursor
()
as
cur
:
cur
.
execute
(
"""
SELECT id, altnames.*, x509_subjectname(certificate) subject
FROM certificate, LATERAL (
SELECT * FROM x509_altnames(certificate)
) altnames
WHERE plainto_tsquery(
'
gouv.fr
'
) @@ identities(certificate)
AND id > %s
"""
,
(
last_id
,),
)
results
=
cur
.
fetchall
()
domains
=
parse_csv_file
(
FILE
)
primary_key
=
None
results
=
cur
.
fetchall
()
for
primary_key
,
domain
,
subject
in
results
:
domain
=
Domain
(
domain
.
lower
(),
...
...
This diff is collapsed.
Click to expand it.
scripts/requirements.txt
+
1
−
1
View file @
a233a5d7
tqdm
aiohttp
validators>=0.24.0 # where they introduced rfc_2782.
psycopg
2
psycopg
[binary]
requests
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment