Skip to content

Commit dc12012

Browse files
committed
Finish query page, remove asset dns query nyi notice
1 parent 087c9ea commit dc12012

File tree

3 files changed

+125
-20
lines changed

3 files changed

+125
-20
lines changed

so-manager/react/src/assets/index.js

-3
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import React from "react";
2+
13
function DNSQuery() {
2-
return null;
4+
return <h2>Single DNS lookup - Not yet implemented</h2>;
35
}
46

57
export default DNSQuery;

so-manager/react/src/pages/Query/queries/IPQuery.js

+122-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import React, { useState } from "react";
22

3-
import { TextField, Select, FormControl, InputLabel } from "@material-ui/core";
3+
import {
4+
TextField,
5+
Card,
6+
CardActionArea,
7+
CardContent,
8+
Typography,
9+
Grid,
10+
} from "@material-ui/core";
411
import { makeStyles } from "@material-ui/core/styles";
512

613
const useStyles = makeStyles((theme) => ({
@@ -9,16 +16,63 @@ const useStyles = makeStyles((theme) => ({
916
width: "25ch",
1017
},
1118
},
19+
card: {
20+
minWidth: 200,
21+
margin: 10,
22+
width: "fit-content",
23+
},
24+
actionArea: {
25+
height: "100%",
26+
width: "100%",
27+
},
1228
}));
1329

1430
function isIP(input) {
15-
// From https://github.com/lukehaas/RegexHub
31+
// From https://www.oreilly.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
1632
const regex =
17-
"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
33+
"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
1834

1935
return RegExp(regex).test(input);
2036
}
2137

38+
function DataCard(props) {
39+
const classes = useStyles();
40+
41+
return (
42+
<Card className={classes.card} elevation={3}>
43+
<CardContent>
44+
<Typography align="center" variant="h6">
45+
{props.name}
46+
</Typography>
47+
<Typography align="center" variant="body2">
48+
{props.data}
49+
</Typography>
50+
</CardContent>
51+
</Card>
52+
);
53+
}
54+
55+
function LinkCard(props) {
56+
const classes = useStyles();
57+
58+
return (
59+
<Card className={classes.card} elevation={3}>
60+
<CardActionArea className={classes.actionArea} href={props.link}>
61+
<CardContent>
62+
<Typography align="center" variant="h6">
63+
{props.name}
64+
</Typography>
65+
{props.data && (
66+
<Typography align="center" variant="body2">
67+
{props.data}
68+
</Typography>
69+
)}
70+
</CardContent>
71+
</CardActionArea>
72+
</Card>
73+
);
74+
}
75+
2276
function IPQuery() {
2377
const classes = useStyles();
2478

@@ -51,9 +105,9 @@ function IPQuery() {
51105
setResult((curr) => {
52106
return {
53107
...curr,
54-
data: body
55-
}
56-
})
108+
data: body,
109+
};
110+
});
57111
});
58112
}
59113

@@ -91,17 +145,69 @@ function IPQuery() {
91145
{/* Result */}
92146
{result.show && <h2>Result</h2>}
93147

94-
{result.show && result.links.kibanaIndicator && (
95-
<div>
96-
<a href={result.links.kibanaIndicator}>Kibana indicator dashboard</a>
97-
</div>
98-
)}
99-
{result.show && result.links.ntopHost && (
100-
<div>
101-
<a href={result.links.ntopHost}>Ntop host details</a>
102-
</div>
148+
{result.show && result.links && <h3>Links</h3>}
149+
<Grid container spacing={1}>
150+
{result.show && result.links && result.links.kibanaIndicator && (
151+
<LinkCard
152+
name="Kibana indicator"
153+
link={result.links.kibanaIndicator}
154+
/>
155+
)}
156+
157+
{result.show && result.links && result.links.ntopHost && (
158+
<LinkCard name="Ntop host details" link={result.links.ntopHost} />
159+
)}
160+
</Grid>
161+
162+
{result.show && result.data && <h3>Data</h3>}
163+
164+
<Grid container spacing={1}>
165+
{result.show && result.data && result.data.firstSeen && (
166+
<DataCard name="First seen by ntop" data={result.data.firstSeen} />
167+
)}
168+
169+
{result.show && result.data && result.data.lastSeen && (
170+
<DataCard name="Last seen by ntop" data={result.data.lastSeen} />
171+
)}
172+
173+
{result.show && result.data && result.data.mispMatches && (
174+
<DataCard
175+
name="Attribute search matches in MISP"
176+
data={result.data.mispMatches}
177+
/>
178+
)}
179+
180+
{result.show &&
181+
result.data &&
182+
result.data.mispEvents &&
183+
result.data.mispEvents.map((event) => {
184+
return (
185+
<LinkCard
186+
name="Misp event"
187+
data={event}
188+
link={`https://misp-sopoc.duckdns.org/events/view/${event}`}
189+
/>
190+
);
191+
})}
192+
193+
{result.show &&
194+
result.data &&
195+
result.data.errors &&
196+
result.data.errors.map((err) => {
197+
return <DataCard name="Error" data={err} />;
198+
})}
199+
200+
{result.show && result.data && result.data.statusMessage && (
201+
<DataCard name="Fetch error" value={result.data.statusMessage} />
202+
)}
203+
</Grid>
204+
205+
{result.show && (
206+
<React.Fragment>
207+
<h3>JSON</h3>
208+
<xmp>{JSON.stringify(result, null, 2)}</xmp>
209+
</React.Fragment>
103210
)}
104-
{result.show && JSON.stringify(result)}
105211
</React.Fragment>
106212
);
107213
}

0 commit comments

Comments
 (0)