Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Vulnerability Module and Upgraded to Django 2.0 #21

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
89a5d8d
- Change from Alpine to Ubuntu
Dec 22, 2017
267ec9b
Ignore package-lock.json and bag-of-holding.iml
Dec 22, 2017
a7cdaf3
Add sample mercari application list
Dec 22, 2017
4cb19ea
Remove django data
Dec 22, 2017
982f251
- Display the data elements in the application overview page.
Dec 22, 2017
86c60b9
- Add the 'Data Elements' field to the filter for Application search
Dec 25, 2017
2c0409c
delete mercari_data
yannarak Dec 25, 2017
e61f801
- Added the rel="noopener noreferrer" attribute to all links with tar…
Dec 25, 2017
45c6d78
Add the following fields to Application Model:
Dec 25, 2017
67d4c56
Implement the forms for updating Dependencies and Repository
Dec 26, 2017
b556cfd
Initial implementation of the Vulnerability Model
Dec 26, 2017
dc3a259
Implement vulnerability re-open feature.
Dec 27, 2017
99f7220
Implement vulnerabilty search feature.
Dec 27, 2017
3952d16
Implement vulnerabilty search feature for application page.
Dec 27, 2017
3ce7b7c
add favicon
Dec 27, 2017
22809f3
Add the attribute enctype="multipart/form-data" to the <form> element
Dec 27, 2017
ce6407c
- Implement the file upload feature.
Jan 4, 2018
cb0337a
- Add the date picker control to the vulnerability add and edit pages.
Jan 5, 2018
de0c1a9
- Implemented the attachment delete feature.
Jan 5, 2018
3e136ff
- Implemented the attachment delete feature.
Jan 9, 2018
4b554f0
- Implemented the attachment delete feature.
Jan 9, 2018
aab0223
- Implement Google Authentication.
Jan 9, 2018
8b9e807
- Added configuration file template
Jan 9, 2018
902096c
Delete boh_config.template.sh
yannarak Jan 9, 2018
5e0957e
- Add OS Environment variable configuration file
Jan 9, 2018
6eb5f1b
- Upgrade to Django 2 but need to fix the search functionalities.
Jan 10, 2018
8286530
- Fix the search functionality
Jan 10, 2018
e974cbe
- Add social-auth-app-django==2.1.0 to the requirements file
Jan 10, 2018
74ac78b
- added the default value for slack_id and email fields
Jan 10, 2018
4a2a846
- set the debug configuration to 'False' and MySQL port to 3306
Jan 10, 2018
982c6ca
- Added ALLOWED_HOSTS to the settings
Jan 10, 2018
42b8e32
- Added ALLOWED_HOSTS to the settings
Jan 11, 2018
2809bc1
- Added ALLOWED_HOSTS to the settings
Jan 11, 2018
a58bba5
- Added ALLOWED_HOSTS to the settings
Jan 11, 2018
05fd31e
- Only allowed Google Authentication with the users from mercari.com
Jan 11, 2018
ee9ce1c
- fix the bug in the search functionality
Jan 11, 2018
4415b20
- fix the bug in the search functionality
Jan 15, 2018
41fbb00
- Add the 'Potential Threats' field to the 'Application' model
Jan 15, 2018
d2f8ab1
- fix cosmetic bug when displaying potential threats.
Jan 15, 2018
0f47f32
- Add the 'Potential Threats' field to the 'Application' model
Jan 16, 2018
84ca858
- Add the field 'slack_id' to the Person Form.
Jan 16, 2018
63b9c72
- Add the 'Potential Threats' field to the 'Application' model
Jan 24, 2018
26d8d86
- Upgrade to Django 2.0.2
Feb 2, 2018
545c71a
added cwe_insert.sql
Feb 5, 2018
9416061
Merge pull request #1 from yannarak/insert-cwe-data
yannarak Feb 5, 2018
f9d4eb2
- Add 'Application Vulnerability Add' view so that the user does not …
Feb 27, 2018
7a1c180
Added Vulnerability Module and Upgraded to Django 2.0
Feb 28, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ node_modules
.temp
.sass-cache
bower_components
package-lock.json
bag-of-holding.iml

# Sample Data
project/mercari_data*.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to sample_data or something not brand-specific.


# OS Environment Variables Config file
config/boh_config.sh
config/boh_config_prod.sh

#Mac
*.DS_Store
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
* Adam Parsons <[email protected]>
* Matt Tesauro <[email protected]>
* Aaron Weaver <[email protected]>
* Yannarak Wannasai <[email protected]>
16 changes: 9 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
FROM alpine
FROM ubuntu

RUN apk --update add python3 && apk add bash
RUN apt-get update
RUN apt-get install -y python3 python3-pip sqlite3
RUN apt-get install -y libmysqlclient-dev

ENV PYTHONUNBUFFERED 1
RUN mkdir /bag-of-holding
WORKDIR /bag-of-holding
ADD . /bag-of-holding/
RUN pip3 install -r requirements.txt
RUN python3 /bag-of-holding/src/manage.py makemigrations
RUN python3 /bag-of-holding/src/manage.py migrate
RUN python3 /bag-of-holding/src/manage.py loaddata /bag-of-holding/src/sample_data.json
RUN python3 /bag-of-holding/project/manage.py makemigrations
RUN python3 /bag-of-holding/project/manage.py migrate
RUN python3 /bag-of-holding/project/manage.py loaddata /bag-of-holding/project/mercari_data.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename to sample_data or something not brand-specific.


CMD python3 /bag-of-holding/src/manage.py runserver 0.0.0.0:8000
CMD python3 /bag-of-holding/project/manage.py runserver 0.0.0.0:8000

# Instructions:
# docker run -d -p 8000:8000 --name boh-server disenchant/bag-of-holding:latest
# docker exec -it boh-server bash
# python3 /bag-of-holding/src/manage.py createsuperuser
# python3 /bag-of-holding/project/manage.py createsuperuser
2 changes: 1 addition & 1 deletion assets/scripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ $(function () {
}]
}]
],
footer: '<div class="btn-group" role="group"><a class="btn btn-default btn-xs" href="http://daringfireball.net/projects/markdown/basics" role="button" target="_blank">Markdown Help</a><a class="btn btn-default btn-xs" href="http://pythonhosted.org//Markdown/extensions/code_hilite.html#syntax" role="button" target="_blank">Code Highlighting Help</a></div>'
footer: '<div class="btn-group" role="group"><a class="btn btn-default btn-xs" href="http://daringfireball.net/projects/markdown/basics" role="button" target="_blank" rel="noopener noreferrer">Markdown Help</a><a class="btn btn-default btn-xs" href="http://pythonhosted.org//Markdown/extensions/code_hilite.html#syntax" role="button" target="_blank" rel="noopener noreferrer">Code Highlighting Help</a></div>'
});

$(".threadfix-process").click(function(event) {
Expand Down
628 changes: 628 additions & 0 deletions config/cwe_insert.sql

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions project/boh/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.contrib import admin
from django.core.urlresolvers import reverse
from django.utils.html import format_html
from django.utils.translation import ugettext_lazy as _

Expand Down Expand Up @@ -310,7 +309,7 @@ def category_display(self, obj):
category_display.short_description = _('Category')

def reference_link(self, obj):
return format_html('<a href="{}" rel="nofollow" target="_blank">{}</a>', obj.reference, obj.reference)
return format_html('<a href="{}" rel="nofollow noopener noreferrer" target="_blank">{}</a>', obj.reference, obj.reference)
reference_link.admin_order_field = 'reference'
reference_link.allow_tags = True
reference_link.short_description = _('Reference')
Expand All @@ -329,14 +328,26 @@ def category_display(self, obj):
category_display.short_description = 'Category'

def reference_link(self, obj):
return format_html('<a href="{}" rel="nofollow" target="_blank">{}</a>', obj.reference, obj.reference)
return format_html('<a href="{}" rel="nofollow noopener noreferrer" target="_blank">{}</a>', obj.reference, obj.reference)
reference_link.admin_order_field = 'reference'
reference_link.allow_tags = True
reference_link.short_description = _('Reference')

admin.site.register(models.Regulation, RegulationAdmin)


class ServiceLevelAgreementAdmin(admin.ModelAdmin):
list_display = ['name', 'description']

admin.site.register(models.ServiceLevelAgreement, ServiceLevelAgreementAdmin)

class VulnerabililtyAttachmentAdmin(admin.ModelAdmin):
list_display = ['file_name', 'description']

admin.site.register(models.VulnerabilityAttachment, VulnerabililtyAttachmentAdmin)

class VulnerabilityClassAdmin(admin.ModelAdmin):
list_display = ['cwe_id', 'name', 'url']

admin.site.register(models.VulnerabilityClass, VulnerabilityClassAdmin)

7 changes: 7 additions & 0 deletions project/boh/behaviors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.db import models
from datetime import timedelta
from django.utils import timezone


class TimeStampedModel(models.Model):
Expand All @@ -9,3 +11,8 @@ class TimeStampedModel(models.Model):

class Meta:
abstract = True

def is_new(self):
"""Returns true if the application was created in the last 7 days"""
delta = self.created_date - timezone.now()
return delta >= timedelta(days=-7)
54 changes: 43 additions & 11 deletions project/boh/filters.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,54 @@
import django_filters
from .models import Organization, Application, Vulnerability, VulnerabilityClass, Person

from django_filters import filters

from .models import Organization, Application
class ApplicationFilter(django_filters.FilterSet):
name = django_filters.CharFilter(lookup_expr='icontains')
organization = django_filters.ModelMultipleChoiceFilter(queryset=Organization.objects.all())
business_criticality = django_filters.MultipleChoiceFilter(choices=Application.BUSINESS_CRITICALITY_CHOICES)
platform = django_filters.MultipleChoiceFilter(choices=Application.PLATFORM_CHOICES)
lifecycle = django_filters.MultipleChoiceFilter(choices=Application.LIFECYCLE_CHOICES)
origin = django_filters.MultipleChoiceFilter(choices=Application.ORIGIN_CHOICES)
asvs_level = django_filters.MultipleChoiceFilter(choices=Application.ASVS_CHOICES)

def count(self):
count = 0
if self.queryset is not None:
count = len(self.queryset)
return count

class ApplicationFilter(django_filters.FilterSet):
name = filters.CharFilter(lookup_type='icontains')
organization = filters.ModelMultipleChoiceFilter(queryset=Organization.objects.all())
business_criticality = filters.MultipleChoiceFilter(choices=Application.BUSINESS_CRITICALITY_CHOICES)
platform = filters.MultipleChoiceFilter(choices=Application.PLATFORM_CHOICES)
lifecycle = filters.MultipleChoiceFilter(choices=Application.LIFECYCLE_CHOICES)
origin = filters.MultipleChoiceFilter(choices=Application.ORIGIN_CHOICES)
asvs_level = filters.MultipleChoiceFilter(choices=Application.ASVS_CHOICES)
def __getitem__(self, item):
return self.queryset[item]

class Meta:
model = Application
fields = [
'name', 'organization', 'business_criticality', 'platform', 'lifecycle', 'origin', 'external_audience',
'internet_accessible', 'technologies', 'regulations', 'service_level_agreements', 'tags', 'asvs_level'
'internet_accessible', 'technologies', 'regulations', 'service_level_agreements', 'tags', 'asvs_level', 'data_elements'
]


class VulnerabilityFilter(django_filters.FilterSet):
name = django_filters.CharFilter(lookup_expr='icontains')
affected_app = django_filters.ModelMultipleChoiceFilter(queryset=Application.objects.all())
severity = django_filters.MultipleChoiceFilter(choices=Vulnerability.SEVERITY_CHOICES)
status = django_filters.MultipleChoiceFilter(choices=Vulnerability.STATUS_CHOICES)
reporter = django_filters.ModelMultipleChoiceFilter(queryset=Person.objects.all())
detection_method = django_filters.MultipleChoiceFilter(choices=Vulnerability.DETECTION_METHOD_CHOICES)
vulnerability_classes = django_filters.ModelMultipleChoiceFilter(queryset=VulnerabilityClass.objects.all())

def count(self):
count = 0
if self.queryset is not None:
count = len(self.queryset)
return count

def __getitem__(self, item):
return self.queryset[item]

class Meta:
model = Vulnerability
fields = [
'name', 'affected_app', 'severity', 'vulnerability_classes', 'status', 'reporter', 'tags',
'detection_method'
]
73 changes: 66 additions & 7 deletions project/boh/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Meta:
class ApplicationSettingsGeneralForm(forms.ModelForm):
class Meta:
model = models.Application
fields = ['name', 'description']
fields = ['name', 'description', 'authentication','authorization']
widgets = {
'description': forms.Textarea(attrs={'rows': 8})
}
Expand All @@ -174,11 +174,34 @@ class Meta:
fields = ['organization']


class ApplicationSettingsRepositoryForm(forms.ModelForm):
class Meta:
model = models.Application
fields = ['repository']


class ApplicationSettingsThreatsForm(forms.ModelForm):
class Meta:
model = models.Application
fields = ['threats']

class ApplicationSettingsFeaturesForm(forms.ModelForm):
class Meta:
model = models.Application
fields = ['authentication', 'authorization', 'plugins']


class ApplicationSettingsDependenciesForm(forms.ModelForm):
class Meta:
model = models.Application
fields = ['dependencies']


class ApplicationSettingsMetadataForm(forms.ModelForm):
class Meta:
model = models.Application
fields = [
'platform', 'lifecycle', 'origin', 'business_criticality', 'user_records', 'revenue', 'external_audience',
'platform', 'lifecycle', 'origin', 'business_criticality', 'risk_category', 'user_records', 'revenue', 'external_audience',
'internet_accessible'
]

Expand Down Expand Up @@ -256,6 +279,13 @@ class Meta:
model = models.Application
fields = []

class ApplicationVulnerabilityAddForm(forms.ModelForm):
class Meta:
model = models.Vulnerability
fields = ['name', 'description', 'solution', 'affected_version', 'environment', 'severity',
'pre_conditions', 'reproduction_steps', 'attack_vector', 'reporter', 'deadline',
"vulnerability_classes", 'detection_method', 'tags']


# Environment

Expand Down Expand Up @@ -320,8 +350,7 @@ def clean(self):
start_date = cleaned.get('start_date')
end_date = cleaned.get('end_date')

if start_date and end_date:
if end_date < start_date:
if start_date and end_date and end_date < start_date:
self.add_error('end_date', _("End date cannot be before start date."))


Expand All @@ -342,8 +371,7 @@ def clean(self):
start_date = cleaned.get('start_date')
end_date = cleaned.get('end_date')

if start_date and end_date:
if end_date < start_date:
if start_date and end_date and end_date < start_date:
self.add_error('end_date', _("End date cannot be before start date."))


Expand Down Expand Up @@ -420,7 +448,7 @@ class Meta:
class PersonForm(forms.ModelForm):
class Meta:
model = models.Person
fields = ['first_name', 'last_name', 'email', 'phone_work', 'phone_mobile', 'job_title', 'role']
fields = ['first_name', 'last_name', 'email', 'slack_id', 'phone_work', 'phone_mobile', 'job_title', 'role']


class PersonDeleteForm(forms.ModelForm):
Expand Down Expand Up @@ -477,3 +505,34 @@ class ActivityTypeDeleteForm(forms.ModelForm):
class Meta:
model = models.ActivityType
fields = []


# Vulnerabilty
class VulnerabilityAddForm(forms.ModelForm):
class Meta:
model = models.Vulnerability
fields = ['name', 'description', 'solution', 'affected_app', 'affected_version', 'environment', 'severity',
'pre_conditions', 'reproduction_steps', 'attack_vector', 'reporter', 'deadline',
"vulnerability_classes", 'detection_method', 'tags']

class VulnerabilityEditForm(forms.ModelForm):
class Meta:
model = models.Vulnerability
fields = ['name', 'description', 'solution', 'affected_app', 'affected_version', 'environment', 'severity',
'pre_conditions', 'reproduction_steps', 'attack_vector', 'reporter', 'deadline', 'status',
"vulnerability_classes", 'detection_method', 'tags']

class VulnerabilityDeleteForm(forms.ModelForm):
class Meta:
model = models.Vulnerability
fields = []

class VulnerabilityAttachmentAddForm(forms.ModelForm):
class Meta:
model = models.VulnerabilityAttachment
fields = ['attachment', 'description']

class VulnerabilityAttachmentDeleteForm(forms.ModelForm):
class Meta:
model = models.VulnerabilityAttachment
fields = []
20 changes: 19 additions & 1 deletion project/boh/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,29 @@ def data_sensitivity_value(data_elements):

def data_classification_level(dsv):
"""Returns the data classification level of the calculated data sensitivity value."""
if dsv < 15:
if dsv < 5:
return 0
elif dsv < 15:
return 1
elif 15 <= dsv < 100:
return 2
elif 100 <= dsv < 150:
return 3
else:
return 4


def data_classification_level_display(dcl):
"""Returns the data classification level of the calculated data sensitivity value."""
if dcl == 0:
return "Public"
if dcl == 1:
return "Private"
elif dcl == 2:
return "Confidential"
elif dcl == 3:
return "Sensitive"
elif dcl == 4:
return "Highly Sensitive"
else:
return "None"
2 changes: 1 addition & 1 deletion project/boh/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def stats(self, year=None):
)

if results['average_duration']:
results['average_duration'] = datetime.timedelta(microseconds=results['average_duration'])
results['average_duration'] = datetime.timedelta(microseconds=results['average_duration'].microseconds)

return results

Expand Down
Loading