Skip to content

Commit 1ea3258

Browse files
committed
Misp and ntop in so-manager-api work
1 parent deb483f commit 1ea3258

File tree

6 files changed

+62
-3
lines changed

6 files changed

+62
-3
lines changed

.env.example

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ AUTH_PASS=password
2020
### Services
2121
## MISP
2222
MISP_HOSTNAME=misp-sopoc.example.com
23+
MISP_API_KEY=apikey
2324

2425
## Netdata
2526
NETDATA_HOSTNAME=netdata-sopoc.example.com

Setup.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The host device needs to be reachable over the internet to acquire https certifi
2727

2828
### MISP
2929

30-
MISP needs to know the external hostname. T
30+
MISP needs to know the external hostname.
3131
This is set in `MISP_HOSTNAME`, for example `misp-sopoc.duckdns.org`.
3232

3333
### Ntop
@@ -109,7 +109,8 @@ Misp starts with a default login:
109109
- Open the "Edit my profile" page.
110110
- Change email to "`AUTH_USER`@`MISP_HOSTNAME`", both set earlier in `.env`.
111111
- Go to the "My profile" page.
112-
- Copy the AuthKey, this is the api key used by securityonion-misp.
112+
- Copy the AuthKey, change the `MISP_API_KEY` in `.env` to this key.
113+
- This is also the api key used by securityonion-misp.
113114

114115
### Security Onion
115116

docker-compose.so-manager.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ services:
1111
build: so-manager/react
1212
so-manager-api:
1313
build: so-manager/api
14+
environment:
15+
- MISP_API_KEY=${MISP_API_KEY}
1416
so-manager-gotty-host:
1517
build: so-manager/gotty
1618
command: gotty -p 80 -w ssh debian@${DOCKER_GATEWAY}

so-manager/api/source/apis/misp.d

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module apis.misp;
2+
3+
import vibe.data.json;
4+
import vibe.web.rest;
5+
import vibe.http.common : HTTPMethod;
6+
7+
import std.process : environment;
8+
import std.exception : enforce;
9+
10+
import std.algorithm : map, uniq;
11+
import std.array : array;
12+
13+
@safe:
14+
15+
@path("/")
16+
interface IMispAPI
17+
{
18+
@headerParam("auth", "Authorization")
19+
{
20+
// POST /attributes/restSearch
21+
@path("attributes/restSearch")
22+
@method(HTTPMethod.POST)
23+
@bodyParam("value", "value")
24+
Json searchAttributes(string auth, string value);
25+
}
26+
}
27+
28+
auto getMispApi()
29+
{
30+
return new RestInterfaceClient!IMispAPI("http://misp-proxy/");
31+
}
32+
33+
void queryMisp(string value, ref Json result)
34+
{
35+
import vibe.core.log : logInfo;
36+
37+
Json response;
38+
response = getMispApi().searchAttributes(environment["MISP_API_KEY"], value);
39+
40+
Json attributes = response["response"]["Attribute"];
41+
enforce(attributes.type == Json.Type.array);
42+
43+
if (attributes.length == 0)
44+
{
45+
result["errors"] ~= "Host not found in MISP";
46+
return;
47+
}
48+
49+
response["mispMatches"] = attributes.length;
50+
response["mispEvents"] = attributes.get!(Json[])
51+
.map!(a => a["Event"]["uuid"])
52+
.uniq
53+
.array;
54+
}

so-manager/api/source/apis/ntop.d

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module apis.ntop;
22

3-
//import std.exception;
43
import std.datetime : SysTime;
54

65
import vibe.data.json;

so-manager/api/source/app.d

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import std.exception;
1414
import std.datetime;
1515

1616
import apis.ntop;
17+
import apis.misp;
1718

1819
@safe:
1920

@@ -32,6 +33,7 @@ class RestAPI : IRestAPI
3233
result["errors"] = Json.emptyArray;
3334

3435
queryNtopIP(_ip, result);
36+
queryMisp(_ip, result);
3537

3638
return result;
3739
}

0 commit comments

Comments
 (0)