forked from p34709852/monkey
Findings resource is now real data from the DB instead of mock data.
This commit is contained in:
parent
2eb34821f8
commit
47375efe42
|
@ -1,9 +1,12 @@
|
||||||
import httplib
|
import httplib
|
||||||
|
import json
|
||||||
|
|
||||||
import flask_restful
|
import flask_restful
|
||||||
from flask import jsonify
|
from flask import jsonify
|
||||||
|
|
||||||
|
from common.data.zero_trust_consts import TESTS_MAP, EXPLANATION_KEY, PILLARS_KEY
|
||||||
from monkey_island.cc.auth import jwt_required
|
from monkey_island.cc.auth import jwt_required
|
||||||
|
from monkey_island.cc.models.finding import Finding
|
||||||
from monkey_island.cc.services.reporting.report import ReportService
|
from monkey_island.cc.services.reporting.report import ReportService
|
||||||
|
|
||||||
ZERO_TRUST_REPORT_TYPE = "zero_trust"
|
ZERO_TRUST_REPORT_TYPE = "zero_trust"
|
||||||
|
@ -35,37 +38,25 @@ class Report(flask_restful.Resource):
|
||||||
|
|
||||||
|
|
||||||
def get_all_findings():
|
def get_all_findings():
|
||||||
return [
|
all_findings = Finding.objects()
|
||||||
{
|
enriched_findings = [get_enriched_finding(f) for f in all_findings]
|
||||||
"test": "Monkey 8 found a machine with no AV software active.",
|
return enriched_findings
|
||||||
"conclusive": False,
|
|
||||||
"pillars": ["Devices"],
|
|
||||||
"events": [
|
def get_events_as_dict(events):
|
||||||
{
|
return [json.loads(event.to_json()) for event in events]
|
||||||
"timestamp": "2019-08-01 14:48:46.112000",
|
|
||||||
"title": "Monkey performed an action",
|
|
||||||
"type": "MonkeyAction",
|
def get_enriched_finding(finding):
|
||||||
"message": "log1"
|
test_info = TESTS_MAP[finding.test]
|
||||||
}, {
|
enriched_finding = {
|
||||||
"timestamp": "2019-08-01 14:48:42.112000",
|
# TODO add test explanation per status.
|
||||||
"title": "Analysis",
|
"test": test_info[EXPLANATION_KEY],
|
||||||
"type": "IslandAction",
|
"pillars": test_info[PILLARS_KEY],
|
||||||
"message": "log2"
|
"status": finding.status,
|
||||||
}]
|
"events": get_events_as_dict(finding.events)
|
||||||
},
|
|
||||||
{
|
|
||||||
"test": "Monkey 6 successfully exploited machine XXX with shellshock.",
|
|
||||||
"conclusive": True,
|
|
||||||
"pillars": ["Devices", "Networks"],
|
|
||||||
"events": [
|
|
||||||
{
|
|
||||||
"timestamp": "2019-08-01 14:48:46.112000",
|
|
||||||
"title": "Analysis",
|
|
||||||
"type": "MonkeyAction",
|
|
||||||
"message": "log3"
|
|
||||||
}]
|
|
||||||
}
|
}
|
||||||
]
|
return enriched_finding
|
||||||
|
|
||||||
|
|
||||||
def get_recommendations_status():
|
def get_recommendations_status():
|
||||||
|
|
|
@ -2,8 +2,9 @@ import React, {Component} from "react";
|
||||||
import {Timeline, TimelineEvent} from "react-event-timeline";
|
import {Timeline, TimelineEvent} from "react-event-timeline";
|
||||||
|
|
||||||
const eventTypeToIcon = {
|
const eventTypeToIcon = {
|
||||||
"MonkeyAction": "fa fa-exclamation-circle fa-2x icon-warning",
|
"monkey_local": "fa fa-exclamation-circle fa-2x icon-warning",
|
||||||
"IslandAction": "fa fa-server fa-2x icon-info",
|
"monkey_network": "fa fa-exclamation-circle fa-2x icon-warning",
|
||||||
|
"island": "fa fa-server fa-2x icon-info",
|
||||||
null: "fa fa-question-circle fa-2x icon-info",
|
null: "fa fa-question-circle fa-2x icon-info",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,15 +14,16 @@ export class EventsTimeline extends Component {
|
||||||
<div>
|
<div>
|
||||||
<Timeline>
|
<Timeline>
|
||||||
{
|
{
|
||||||
this.props["events"].map(event => (
|
this.props["events"].map(event => {
|
||||||
<TimelineEvent
|
const event_time = new Date(event.timestamp['$date']).toString();
|
||||||
key={event.timestamp}
|
return (<TimelineEvent
|
||||||
createdAt={event.timestamp}
|
key={event.timestamp['$date']}
|
||||||
|
createdAt={event_time}
|
||||||
title={event.title}
|
title={event.title}
|
||||||
icon={<i className={eventTypeToIcon[event.type]} />}>
|
icon={<i className={eventTypeToIcon[event.event_type]} />}>
|
||||||
{event.message}
|
{event.message}
|
||||||
</TimelineEvent>
|
</TimelineEvent>)
|
||||||
))
|
})
|
||||||
}
|
}
|
||||||
</Timeline>
|
</Timeline>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue