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 json
|
||||
|
||||
import flask_restful
|
||||
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.models.finding import Finding
|
||||
from monkey_island.cc.services.reporting.report import ReportService
|
||||
|
||||
ZERO_TRUST_REPORT_TYPE = "zero_trust"
|
||||
|
@ -35,37 +38,25 @@ class Report(flask_restful.Resource):
|
|||
|
||||
|
||||
def get_all_findings():
|
||||
return [
|
||||
{
|
||||
"test": "Monkey 8 found a machine with no AV software active.",
|
||||
"conclusive": False,
|
||||
"pillars": ["Devices"],
|
||||
"events": [
|
||||
{
|
||||
"timestamp": "2019-08-01 14:48:46.112000",
|
||||
"title": "Monkey performed an action",
|
||||
"type": "MonkeyAction",
|
||||
"message": "log1"
|
||||
}, {
|
||||
"timestamp": "2019-08-01 14:48:42.112000",
|
||||
"title": "Analysis",
|
||||
"type": "IslandAction",
|
||||
"message": "log2"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"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"
|
||||
}]
|
||||
all_findings = Finding.objects()
|
||||
enriched_findings = [get_enriched_finding(f) for f in all_findings]
|
||||
return enriched_findings
|
||||
|
||||
|
||||
def get_events_as_dict(events):
|
||||
return [json.loads(event.to_json()) for event in events]
|
||||
|
||||
|
||||
def get_enriched_finding(finding):
|
||||
test_info = TESTS_MAP[finding.test]
|
||||
enriched_finding = {
|
||||
# TODO add test explanation per status.
|
||||
"test": test_info[EXPLANATION_KEY],
|
||||
"pillars": test_info[PILLARS_KEY],
|
||||
"status": finding.status,
|
||||
"events": get_events_as_dict(finding.events)
|
||||
}
|
||||
]
|
||||
return enriched_finding
|
||||
|
||||
|
||||
def get_recommendations_status():
|
||||
|
|
|
@ -2,8 +2,9 @@ import React, {Component} from "react";
|
|||
import {Timeline, TimelineEvent} from "react-event-timeline";
|
||||
|
||||
const eventTypeToIcon = {
|
||||
"MonkeyAction": "fa fa-exclamation-circle fa-2x icon-warning",
|
||||
"IslandAction": "fa fa-server fa-2x icon-info",
|
||||
"monkey_local": "fa fa-exclamation-circle fa-2x icon-warning",
|
||||
"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",
|
||||
};
|
||||
|
||||
|
@ -13,15 +14,16 @@ export class EventsTimeline extends Component {
|
|||
<div>
|
||||
<Timeline>
|
||||
{
|
||||
this.props["events"].map(event => (
|
||||
<TimelineEvent
|
||||
key={event.timestamp}
|
||||
createdAt={event.timestamp}
|
||||
this.props["events"].map(event => {
|
||||
const event_time = new Date(event.timestamp['$date']).toString();
|
||||
return (<TimelineEvent
|
||||
key={event.timestamp['$date']}
|
||||
createdAt={event_time}
|
||||
title={event.title}
|
||||
icon={<i className={eventTypeToIcon[event.type]} />}>
|
||||
icon={<i className={eventTypeToIcon[event.event_type]} />}>
|
||||
{event.message}
|
||||
</TimelineEvent>
|
||||
))
|
||||
</TimelineEvent>)
|
||||
})
|
||||
}
|
||||
</Timeline>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue