Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 20d332b

Browse files
committed
fix: ensure AS names are strings
While there, introduce a more comprehensive smoke test that ensures we will catch this issue in the future. Fixes ooni/probe#1836
1 parent 84e935d commit 20d332b

File tree

10 files changed

+591
-543
lines changed

10 files changed

+591
-543
lines changed

.github/workflows/generate.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ jobs:
2323
run: apt-get update
2424

2525
- name: Install deps
26-
run: apt-get install --no-install-recommends -y bgpdump ca-certificates curl libmaxmind-db-writer-perl python3 python3-gdbm
26+
run: apt-get install --no-install-recommends -y bgpdump ca-certificates curl libmaxmind-db-writer-perl python3 python3-gdbm python3-maxminddb
2727

2828
- name: Generate database using RIPE BGP dump and CAIDA AS names
2929
run: ./generator_ripe_caida.sh
3030

3131
- name: End
3232
run: ls -ltr
3333

34+
- name: Verify the generated file
35+
run: ./smoketest.py
36+
3437
- name: Upload
3538
uses: actions/upload-artifact@v1
3639
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/asn.mmdb
12
/caida_asn_to_name.dbm
23
/caida_input.gz
34
/dbdata

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,18 @@ them to an intermediate file for later consumption;
2222
choosing the most common occurrence _and_ merges routing
2323
data extracted using `bgpdump` to CAIDA ASN data;
2424

25-
- `./writedb.pl` writes the `output.mmdb` file.
25+
- `./writedb.pl` writes the `asn.mmdb` file.
2626

2727
Each individual script contains a comment explaining with
2828
greater detail what its input and output look like.
2929

3030
The `VERSION` file changes every time we bless a new release: we
3131
need something to change in the tree to make a release.
3232

33+
## Testing
34+
35+
Run `./smoketest.py` to smoke test `asn.mmdb`.
36+
3337
## Dependencies
3438

3539
This generator is designed to run on Debian GNU/Linux. It may work

dedupe_add_caida_orgname.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ def main():
4747
if current_net is not None:
4848
# Deduplicate ASNs using the most common occurrence
4949
oasn = c.most_common(1)[0][0]
50-
orgname = asn_to_orgname.get(oasn, "<unknown>")
50+
orgname = asn_to_orgname.get(oasn, b"<unknown>").decode()
5151
print(f"{current_net} {oasn} {orgname}")
5252
c = Counter()
5353
current_net = net
5454
c.update([asn])
5555

5656
# Deduplicate ASNs using the most common occurrence
5757
asn = c.most_common(1)[0][0]
58-
orgname = asn_to_orgname.get(asn, "<unknown>")
58+
orgname = asn_to_orgname.get(asn, b"<unknown>").decode()
5959
print(f"{current_net} {asn} {orgname}")
6060

6161
asn_to_orgname.close()

0 commit comments

Comments
 (0)