Skip to content

Commit

Permalink
Merge branch 'feature/nessus_import' of https://github.com/vace-sec/P…
Browse files Browse the repository at this point in the history
…atrowlManager into vace-sec-feature/nessus_import
  • Loading branch information
MaKyOtOx committed Oct 18, 2018
2 parents 90bfcc1 + 2df4ead commit 700ea39
Show file tree
Hide file tree
Showing 32 changed files with 1,050 additions and 379 deletions.
3 changes: 2 additions & 1 deletion assets/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

assets = []


class AssetForm(forms.ModelForm):
class Meta:
model = Asset
Expand All @@ -13,7 +14,7 @@ class Meta:
'value': forms.TextInput(attrs={'class': 'form-control form-control-sm'}),
'name': forms.TextInput(attrs={'class': 'form-control form-control-sm'}),
'description': forms.Textarea(attrs={'class': 'form-control form-control-sm', 'rows': '4'}),
'categories': forms.SelectMultiple(attrs={'class': 'form-control form-control-sm'})
'categories': forms.SelectMultiple(attrs={'class': 'form-control form-control-sm', 'size': '10'})
}

type = forms.CharField(widget=forms.Select(choices=ASSET_TYPES, attrs={'class': 'form-control form-control-sm'}))
Expand Down
28 changes: 15 additions & 13 deletions assets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@
('person', 'person'),
('organisation', 'organisation'),
('path', 'path'),
('application', 'application'),
)

ASSET_CRITICITIES = (
('low', 'low'),
('medium', 'medium'),
('high', 'high')
('high', 'high'),
)

TLP_COLORS = (
Expand Down Expand Up @@ -138,7 +139,7 @@ class Asset(models.Model):
name = models.CharField(max_length=256)
type = models.CharField(choices=ASSET_TYPES, default='ip', max_length=15) # ipv4, ipv6, domain, fqdn, url
criticity = models.CharField(choices=ASSET_CRITICITIES, default='low', max_length=10) # low, medium, high
risk_level = JSONField(default=dict({ "info": 0, "low": 0, "medium": 0, "high": 0, "total": 0, "grade": "-" }))
risk_level = JSONField(default=dict({ "info": 0, "low": 0, "medium": 0, "high": 0, "critical": 0, "total": 0, "grade": "-" }))
owner = models.ForeignKey(User, null=True, on_delete=models.SET_NULL)
description = models.CharField(max_length=256, null=True, blank=True)
status = models.CharField(max_length=30, null=True, blank=True, default="new")
Expand Down Expand Up @@ -170,17 +171,18 @@ def save(self, *args, **kwargs):
def evaluate_risk(self):
criticity_factor = 0
if self.criticity == "low":
criticity_factor=1
criticity_factor = 1
elif self.criticity == "medium":
criticity_factor=5
criticity_factor = 5
elif self.criticity == "high":
criticity_factor=10
criticity_factor = 10

risk_data={
"info": 0,
"low": 0,
"medium": 0,
"high": 0,
"critical": 0,
"asset_criticity_level": self.criticity,
"asset_criticity_factor": criticity_factor
}
Expand All @@ -195,7 +197,7 @@ def get_risk_grade(self, history = None): # history= nb days before


def calc_risk_grade(self, history = None):
risk_level = { "info": 0, "low": 0, "medium": 0, "high": 0, "total": 0, "grade": "-" }
risk_level = { "info": 0, "low": 0, "medium": 0, "high": 0, "critical": 0, "total": 0, "grade": "-" }

if not history:
findings = self.finding_set.all()
Expand All @@ -208,19 +210,19 @@ def calc_risk_grade(self, history = None):
risk_level['total'] = risk_level.get('total', 0) + 1
risk_level[finding.severity] = risk_level.get(finding.severity, 0) + 1

if risk_level['high'] == 0 and risk_level['medium'] == 0 and risk_level['low'] == 0 and risk_level['info'] == 0:
if risk_level['critical'] == 0 and risk_level['high'] == 0 and risk_level['medium'] == 0 and risk_level['low'] == 0 and risk_level['info'] == 0:
risk_level['grade'] = "-"
elif risk_level['high'] == 0 and risk_level['medium'] == 0 and risk_level['low'] == 0:
elif risk_level['critical'] == 0 and risk_level['high'] == 0 and risk_level['medium'] == 0 and risk_level['low'] == 0:
risk_level['grade'] = "A"
elif risk_level['high'] == 0 and risk_level['medium'] <= 1 and risk_level['low'] <= 5:
elif risk_level['critical'] == 0 and risk_level['high'] == 0 and risk_level['medium'] <= 1 and risk_level['low'] <= 5:
risk_level['grade'] = "B"
elif risk_level['high'] == 0 and risk_level['medium'] <= 5:
elif risk_level['critical'] == 0 and risk_level['high'] == 0 and risk_level['medium'] <= 5:
risk_level['grade'] = "C"
elif risk_level['high'] <= 1 and risk_level['medium'] <= 5:
elif risk_level['critical'] == 0 and risk_level['high'] <= 1 and risk_level['medium'] <= 5:
risk_level['grade'] = "D"
elif risk_level['high'] <= 3:
elif risk_level['critical'] == 0 and risk_level['high'] <= 3:
risk_level['grade'] = "E"
elif risk_level['high'] > 3:
elif risk_level['critical'] >= 1 or risk_level['high'] > 3:
risk_level['grade'] = "F"
else:
risk_level['grade'] = "n/a"
Expand Down
126 changes: 69 additions & 57 deletions assets/templates/details-asset-group.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
margin: 0;
padding: 2px;
}
div.tile {
border-width: thin;
border-style: solid;
border-left-width: 1rem;
border-radius: 3px;
padding-bottom: 15px;
text-align: center;
}
div.tile div { font-size: large; }
div.tile-high { border-color: red; }
div.tile-medium { border-color: orange; }
/* div.tile-low { border-color: #3498db; } */
div.tile-low { border-color: #efe636; }
div.tile-info { border-color: lightgrey; }

span.badge-risk-grade-A { background-color: limegreen; }
span.badge-risk-grade-B { background-color: yellowgreen; }
Expand All @@ -45,6 +31,21 @@
div.risk-grade-E { background-color: orangered; }
div.risk-grade-F { background-color: red; }

div.tile {
border-width: thin;
border-style: solid;
border-left-width: 1rem;
border-radius: 3px;
padding-bottom: 15px;
text-align: center;
}
div.tile div { font-size: large; }
div.tile-critical { border-color: #cc0500; }
div.tile-high { border-color: #df3d03; }
div.tile-medium { border-color: #f9a009; }
div.tile-low { border-color: #ffcb0d; }
div.tile-info { border-color: #3498db; }

div.risk-trends {
border-top-color: lightgray;
border-top-style: solid;
Expand All @@ -65,7 +66,7 @@

<div class="container-fluid" asset-id="{{asset_group.id}}">
<div class="row">
<div class="col-md-5">
<div class="col-md-4">
<dl class="dl-horizontal">
<dt>Name</dt>
<dd><b>{{ asset_group.name }}</b></dd>
Expand All @@ -83,11 +84,11 @@

<dt>Criticity</dt>
{% if asset_group.criticity == 'low' %}
<dd><span class="label label-info">low</span></dd>
<dd><span class="label label-low">low</span></dd>
{% elif asset_group.criticity == 'medium' %}
<dd><span class="label label-warning">medium</span></dd>
<dd><span class="label label-medium">medium</span></dd>
{% elif asset_group.criticity == 'high' %}
<dd><span class="label label-danger">high</span></dd>
<dd><span class="label label-critical">high</span></dd>
{% endif %}

<dt>Created at</dt>
Expand All @@ -106,32 +107,36 @@
</dl>
</div><!-- End of first col -->

<div class="col-md-5 tiles"> <!-- Second col -->
<div class="col-md-6 tiles"> <!-- Second col -->
<div class="row">
<b>Findings Stats </b><span class="glyphicon glyphicon-stats"></span>
</div>
<div class="row finding-stats">
<!-- <div class="col-md-3 tile" style="outline: 1px solid red;"> -->
<div class="col-md-3">
<div class="col-md-2">
<div class="tile tile-critical">
<div>Critical:</div><span class="label label-critical">{{findings_stats.critical}}</span>
</div>
</div>
<div class="col-md-2">
<div class="tile tile-high">
<div>High:</div><span class="label label-danger">{{findings_stats.high}}</span>
<div>High:</div><span class="label label-high">{{findings_stats.high}}</span>
</div>
</div>
<div class="col-md-3">
</div>
<div class="col-md-2">
<div class="tile tile-medium">
<div>Medium:</div><span class="label label-warning">{{findings_stats.medium}}</span>
<div>Medium:</div><span class="label label-medium">{{findings_stats.medium}}</span>
</div>
</div>
<div class="col-md-3">
</div>
<div class="col-md-2">
<div class="tile tile-low">
<div>Low:</div><span class="label label-info">{{findings_stats.low}}</span>
<div>Low:</div><span class="label label-low">{{findings_stats.low}}</span>
</div>
</div>
<div class="col-md-3">
</div>
<div class="col-md-2">
<div class="tile tile-info">
<div>Info:</div><span class="label label-default">{{findings_stats.info}}</span>
<div>Info:</div><span class="label label-info">{{findings_stats.info}}</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
Expand Down Expand Up @@ -195,13 +200,13 @@
{% for scope, counter in asset_scopes %}
<a href="/findings/list?_scope={{ counter.id }}&_asset_group_id={{ asset_group.id }}" style="text-decoration:none;">
{% if counter.high > 0 %}
<span class="label label-danger">{{ scope }}: {{ counter.high }}/{{ counter.total }}</span>
<span class="label label-critical">{{ scope }}: {{ counter.high }}/{{ counter.total }}</span>
{% elif counter.medium > 0 %}
<span class="label label-warning">{{ scope }}: {{ counter.medium }}/{{ counter.total }}</span>
<span class="label label-medium">{{ scope }}: {{ counter.medium }}/{{ counter.total }}</span>
{% elif counter.low > 0 %}
<span class="label label-info">{{ scope }}: {{ counter.low }}/{{ counter.total }}</span>
<span class="label label-low">{{ scope }}: {{ counter.low }}/{{ counter.total }}</span>
{% else %}
<span class="label label-default">{{ scope }}: {{ counter.total }}</span>
<span class="label label-info">{{ scope }}: {{ counter.total }}</span>
{% endif %}
</a>
{% endfor %}
Expand Down Expand Up @@ -247,30 +252,30 @@
{% if asset.risk_level.high == 0 %}
0
{% else %}
<span class="label label-danger">{{ asset.risk_level.high }}</span>
<span class="label label-critical">{{ asset.risk_level.high }}</span>
{% endif %}/
{% if asset.risk_level.medium == 0 %}
0
{% else %}
<span class="label label-warning">{{ asset.risk_level.medium }}</span>
<span class="label label-medium">{{ asset.risk_level.medium }}</span>
{% endif %}/
{% if asset.risk_level.low == 0 %}
0
{% else %}
<span class="label label-info">{{ asset.risk_level.low }}</span>
<span class="label label-low">{{ asset.risk_level.low }}</span>
{% endif %}/
{% if asset.risk_level.info == 0 %}
0
{% else %}
<span class="label label-primary">{{ asset.risk_level.info }}</span>
<span class="label label-info">{{ asset.risk_level.info }}</span>
{% endif %}
</td>
{% if asset.criticity == 'low' %}
<td><span class="label label-info">Low</span></td>
{% elif asset.criticity == 'medium' %}
<td><span class="label label-warning">Medium</span></td>
<td><span class="label label-medium">Medium</span></td>
{% elif asset.criticity == 'high' %}
<td><span class="label label-danger">High</span></td>
<td><span class="label label-critical">High</span></td>
{% endif %}
<td><span class="badge badge-risk-grade-{{ asset.get_risk_grade }}">{{ asset.get_risk_grade }}</span></td>
<td>{{ asset.type }}</td>
Expand Down Expand Up @@ -323,16 +328,18 @@
<td>{{ finding.title }}</td>
<td>{{ finding.type }}</td>
<td>
{% if finding.severity == 'critical' or finding.severity == 'high' %}
<span class="label label-danger">{{ finding.severity }}</span>
{% if finding.severity == 'critical' %}
<span class="label label-critical">{{ finding.severity }}</span>
{% elif finding.severity == 'high' %}
<span class="label label-high">{{ finding.severity }}</span>
{% elif finding.severity == 'medium' or finding.severity == 'moderate' %}
<span class="label label-warning">{{ finding.severity }}</span>
<span class="label label-medium">{{ finding.severity }}</span>
{% elif finding.severity == 'low' %}
<span class="label label-info">{{ finding.severity }}</span>
<span class="label label-low">{{ finding.severity }}</span>
{% else %}
<span class="label label-default">{{ finding.severity }}</span>
<span class="label label-info">{{ finding.severity }}</span>
{% endif %}
</td>
</td>
{% if finding.status == 'new' %}
<td class="text-danger">{{ finding.status }}</td>
{% else %}
Expand Down Expand Up @@ -373,14 +380,16 @@
{% if finding.severity != "info" %}
<tr>
<td>
{% if finding.severity == 'critical' or finding.severity == 'high' %}
<span class="label label-danger">{{ finding.severity }}</span>
{% if finding.severity == 'critical' %}
<span class="label label-critical">{{ finding.severity }}</span>
{% elif finding.severity == 'high' %}
<span class="label label-high">{{ finding.severity }}</span>
{% elif finding.severity == 'medium' or finding.severity == 'moderate' %}
<span class="label label-warning">{{ finding.severity }}</span>
<span class="label label-medium">{{ finding.severity }}</span>
{% elif finding.severity == 'low' %}
<span class="label label-info">{{ finding.severity }}</span>
<span class="label label-low">{{ finding.severity }}</span>
{% else %}
<span class="label label-default">{{ finding.severity }}</span>
<span class="label label-info">{{ finding.severity }}</span>
{% endif %}
</td>
<td>{{ finding.solution }}</td>
Expand Down Expand Up @@ -496,16 +505,19 @@ <h5>Scans performed</h5>
<td class="scan-progress">
<div class="progress" id="pb-{{ scan.id }}">
{% if scan.status == "finished" %}
<div class="progress-bar progress-bar-striped progress-bar-high" role="progressbar" style="width:{{ scan.summary.high | perc:scan.summary.total }}%">
<div class="progress-bar progress-bar progress-bar-critical" role="progressbar" style="width:{{ scan.summary.critical | perc:scan.summary.total }}%">
{{ scan.summary.critical }}
</div>
<div class="progress-bar progress-bar progress-bar-high" role="progressbar" style="width:{{ scan.summary.high | perc:scan.summary.total }}%">
{{ scan.summary.high }}
</div>
<div class="progress-bar progress-bar-striped progress-bar-medium" role="progressbar" style="width:{{ scan.summary.medium | perc:scan.summary.total }}%">
<div class="progress-bar progress-barprogress-bar-medium" role="progressbar" style="width:{{ scan.summary.medium | perc:scan.summary.total }}%">
{{ scan.summary.medium }}
</div>
<div class="progress-bar progress-bar-striped progress-bar-low" role="progressbar" style="width:{{ scan.summary.low | perc:scan.summary.total }}%">
<div class="progress-bar progress-bar progress-bar-low" role="progressbar" style="width:{{ scan.summary.low | perc:scan.summary.total }}%">
{{ scan.summary.low }}
</div>
<div class="progress-bar progress-bar-striped progress-bar-info" role="progressbar" style="width:{{ scan.summary.info | perc:scan.summary.total }}%">
<div class="progress-bar progress-bar progress-bar-info" role="progressbar" style="width:{{ scan.summary.info | perc:scan.summary.total }}%">
{{ scan.summary.info }}
</div>
{% else %}
Expand Down
Loading

0 comments on commit 700ea39

Please sign in to comment.