Skip to content

Commit 40a3518

Browse files
committed
Adds intelmq-api sources. Just copypasted.
1 parent 6d3bdbc commit 40a3518

29 files changed

+1442
-0
lines changed

contrib/app/api/api-apache.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: 2022 CERT.at GmbH <https://cert.at/>
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
5+
# If you want to change default location, please align the ROOT_PATH in the service configuration
6+
<Location /intelmq/>
7+
ProxyPass unix:/usr/lib/python3/dist-packages/intelmq_api/intelmq_api.sock|http://127.0.0.1/
8+
ProxyPassReverse unix:/usr/lib/python3/dist-packages/intelmq_api/intelmq_api.sock|http://127.0.0.1/
9+
</Location>

contrib/app/api/api-config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"intelmq_ctl_cmd": ["sudo", "-u", "intelmq", "intelmqctl"],
3+
"allowed_path": "/opt/intelmq/var/lib/bots/",
4+
"session_store": "/etc/intelmq/api-session.sqlite",
5+
"session_duration": 86400,
6+
"allow_origins": ["*"]
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2020 Birger Schacht
2+
3+
SPDX-License-Identifier: AGPL-3.0-or-later

contrib/app/api/api-session.sql

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- Session database structure for intelmq-api
2+
--
3+
-- SPDX-FileCopyrightText: 2021 Birger Schacht <schacht@cert.at>
4+
-- SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
CREATE TABLE version (version INTEGER);
7+
INSERT INTO version (version) VALUES (1);
8+
9+
CREATE TABLE session (
10+
session_id TEXT PRIMARY KEY,
11+
modified TIMESTAMP,
12+
data BLOB
13+
);
14+
15+
CREATE TABLE user(
16+
username TEXT PRIMARY KEY,
17+
password TEXT,
18+
salt TEXT
19+
);

contrib/app/api/api-sudoers.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-FileCopyrightText: 2020 Birger Schacht
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
#
5+
# intelmq-api sudoers file, allowing the intelmq-api which usually
6+
# is run by a webserver, to run intelmqctl as user intelmq
7+
www-data ALL=(intelmq) NOPASSWD: /usr/bin/intelmqctl

contrib/app/api/initesqlite.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
""" Initialize session database for intelmq-api
2+
3+
SPDX-FileCopyrightText: 2021 Birger Schacht <schacht@cert.at>
4+
SPDX-License-Identifier: AGPL-3.0-or-later
5+
6+
"""
7+
8+
import sqlite3
9+
import pathlib
10+
import sys
11+
12+
folder = pathlib.Path(__file__).parent
13+
14+
if len(sys.argv) > 1:
15+
folder = pathlib.Path(sys.argv[1])
16+
17+
conn = sqlite3.connect(folder / 'api-session.sqlite')
18+
19+
INIT_DB_SQL = """
20+
BEGIN;
21+
CREATE TABLE version (version INTEGER);
22+
INSERT INTO version (version) VALUES (1);
23+
24+
CREATE TABLE session (
25+
session_id TEXT PRIMARY KEY,
26+
modified TIMESTAMP,
27+
data BLOB
28+
);
29+
30+
CREATE TABLE user(
31+
username TEXT PRIMARY KEY,
32+
password TEXT,
33+
salt TEXT
34+
);
35+
36+
COMMIT;
37+
"""
38+
39+
c = conn.cursor()
40+
c.executescript(INIT_DB_SQL)

contrib/app/api/intelmq-api.service

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: 2022 CERT.at GmbH <https://cert.at/>
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
[Unit]
5+
Description=Gunicorn deamon to serve the IntelMQ API
6+
Requires=intelmq-api.socket
7+
After=network.target
8+
9+
[Service]
10+
11+
# To override settings path, use e.g.:
12+
# Environment="INTELMQ_API_CONFIG=/etc/intelmq/api-config.json"
13+
14+
Environment="ROOT_PATH=/intelmq"
15+
User=www-data
16+
Group=www-data
17+
RuntimeDirectory=gunicorn
18+
WorkingDirectory=/usr/lib/python3/dist-packages/intelmq_api/
19+
ExecStart=/usr/bin/gunicorn intelmq_api.main:app --workers 4 --worker-class uvicorn.workers.UvicornWorker --bind unix:intelmq_api.sock
20+
ExecReload=/bin/kill -s HUP $MAINPID
21+
KillMode=mixed
22+
TimeoutStopSec=5
23+
PrivateTmp=true
24+
25+
[Install]
26+
WantedBy=multi-user.target

contrib/app/api/intelmq-api.socket

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# SPDX-FileCopyrightText: 2022 CERT.at GmbH <https://cert.at/>
2+
# SPDX-License-Identifier: CC0-1.0
3+
4+
[Unit]
5+
Description=The socket to handle IntelMQ API requests
6+
7+
[Socket]
8+
ListenStream=/usr/lib/python3/dist-packages/intelmq_api/intelmq_api.sock
9+
SocketUser=www-data
10+
11+
[Install]
12+
WantedBy=sockets.target

contrib/app/api/positions.conf

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"feodo-tracker-browse-parser": {
3+
"x": -304,
4+
"y": 250
5+
},
6+
"feodo-tracker-browse-collector": {
7+
"x": -508,
8+
"y": 282
9+
},
10+
"cymru-whois-expert": {
11+
"x": 510,
12+
"y": -407
13+
},
14+
"deduplicator-expert": {
15+
"x": -107,
16+
"y": 162
17+
},
18+
"file-output": {
19+
"x": 504,
20+
"y": -614
21+
},
22+
"gethostbyname-1-expert": {
23+
"x": 481,
24+
"y": -198
25+
},
26+
"gethostbyname-2-expert": {
27+
"x": 322,
28+
"y": -325
29+
},
30+
"malc0de-parser": {
31+
"x": -292,
32+
"y": 48
33+
},
34+
"malc0de-windows-format-collector": {
35+
"x": -477,
36+
"y": -46
37+
},
38+
"spamhaus-drop-collector": {
39+
"x": -88,
40+
"y": 589
41+
},
42+
"spamhaus-drop-parser": {
43+
"x": -114,
44+
"y": 381
45+
},
46+
"taxonomy-expert": {
47+
"x": 89,
48+
"y": 29
49+
},
50+
"url2fqdn-expert": {
51+
"x": 275,
52+
"y": -116
53+
},
54+
"settings": {
55+
"physics": false,
56+
"live": true
57+
}
58+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: 2020 Birger Schacht
2+
3+
SPDX-License-Identifier: CC0-1.0

0 commit comments

Comments
 (0)