Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6dbeabd
Add bulma CSS framework
sbs2001 Jul 9, 2020
0b4e8fb
Implement Views
sbs2001 Jul 9, 2020
6df8c1f
Add view for adding references for vulnerabilities
sbs2001 Jul 13, 2020
9c71ff1
Organize templates
sbs2001 Jul 15, 2020
14d1fc7
Organise views
sbs2001 Jul 15, 2020
4e0f741
WIP
sbs2001 Jul 18, 2020
e3d421b
Update requirements
sbs2001 Jul 18, 2020
ef90285
Get selectize working instead of long dropdowns
sbs2001 Jul 20, 2020
f8e9e2d
Refactor views for new models, do some style changes
sbs2001 Jul 21, 2020
8e03a2e
Manage static assets.
sbs2001 Jul 21, 2020
776af5c
Remove unused templates
sbs2001 Jul 21, 2020
7b8835a
Format code to follow code style guidelines
sbs2001 Jul 21, 2020
38d90a0
Pass function instead function call in forms
sbs2001 Jul 21, 2020
b99675d
Don't use CDN, self host instead
sbs2001 Jul 24, 2020
fda98d2
Change title of the templates
sbs2001 Jul 31, 2020
a18d452
:hammer: Squash views for impacted and resolved into one view
sbs2001 Aug 6, 2020
0a1d007
:ok_hand: Use subtitle o hint creation of vulnerability
sbs2001 Aug 6, 2020
2a0b6d1
:bug: Fix get_success_url method of PackageUpdate view
sbs2001 Aug 6, 2020
3983119
:art: Make aesthetic changes.
sbs2001 Aug 6, 2020
38905e0
:bug: Avoid giving user the opportunity to create conflicting relations
sbs2001 Aug 6, 2020
d8afc73
:page_facing_up: Add metadata for lib_oval.py
sbs2001 Aug 11, 2020
4340264
:page_facing_up: Add license metadata for bulma
sbs2001 Aug 11, 2020
c09bbdd
:page_facing_up: Add LICENSE and ABOUT files for third parties
sbs2001 Aug 11, 2020
d6897b8
:sparkles: Add pagination to vulnerability search
sbs2001 Aug 13, 2020
2443fc1
:sparkles: Add pagination to package search
sbs2001 Aug 13, 2020
5d3ee7f
:pencil: Use normal static assests instead of minified versions
sbs2001 Aug 14, 2020
c735c35
:heavy_minus_sign: Get rid of selectize js and jquery
sbs2001 Aug 15, 2020
1caad95
:heavy_plus_sign: Update requirements.txt and make code style changes
sbs2001 Aug 26, 2020
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
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dj-database-url==0.4.2
Django==3.0.7
django-filter==2.2.0
djangorestframework==3.11.0
django-widget-tweaks==1.4.8
gunicorn==19.7.1
importlib-metadata==1.3.0
ipython==7.13.0
Expand All @@ -35,6 +36,7 @@ pygit2==1.2.0
Pygments==2.6.1
pyparsing==2.4.5
pytest==5.3.2
django-widget-tweaks==1.4.8
pytest-dependency==0.4.0
pytest-django==3.7.0
pytest-mock==1.13.0
Expand Down
56 changes: 56 additions & 0 deletions vulnerabilities/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright (c) nexB Inc. and others. All rights reserved.
# http://nexb.com and https://github.com/nexB/vulnerablecode/
# The VulnerableCode software is licensed under the Apache License version 2.0.
# Data generated with VulnerableCode require an acknowledgment.
#
# You may not use this software except in compliance with the License.
# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software distributed
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
# specific language governing permissions and limitations under the License.
#
# When you publish or redistribute any data created with VulnerableCode or any VulnerableCode
# derivative work, you must accompany this data with the following acknowledgment:
#
# Generated with VulnerableCode and provided on an "AS IS" BASIS, WITHOUT WARRANTIES
# OR CONDITIONS OF ANY KIND, either express or implied. No content created from
# VulnerableCode should be considered or used as legal advice. Consult an Attorney
# for any legal advice.
# VulnerableCode is a free software tool from nexB Inc. and others.
# Visit https://github.com/nexB/vulnerablecode/ for support and download.

from django import forms

from vulnerabilities.models import Package, PackageRelatedVulnerability, Vulnerability


def get_package_types():
pkg_types = [(i.type, i.type) for i in Package.objects.distinct("type").all()]
pkg_types.append((None, "package type"))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is "package type" about? I am also puzzled by the repetition (a bit of docstring would help I guess?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

package type is just another choice , which roughly translates into the user not caring about the pkg type of results obtained

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am still not clear at all why you need that?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

placeholder

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, you mean a placeholder in the UI dropdown?

return pkg_types


def get_package_namespaces():
pkg_namespaces = [
(i.namespace, i.namespace)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am puzzled by the repetition.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

https://docs.djangoproject.com/en/3.1/ref/forms/fields/#django.forms.ChoiceField.choices

Example: For the tuple ("x","1") the user will be able to select "1" in the frontend which will be interpreted as "x" in the backend.

In this case I want the user to select namespace for what it is in the frontend as well as backend. This whole thing is done because I want to use ChoiceField instead of CharField which is provided by the ModelForm.

for i in Package.objects.distinct("namespace").all()
if i.namespace
]
pkg_namespaces.append((None, "package namespace"))
return pkg_namespaces


class PackageForm(forms.Form):

type = forms.ChoiceField(choices=get_package_types)
namespace = forms.ChoiceField(choices=get_package_namespaces, required=False)
name = forms.CharField(widget=forms.TextInput(attrs={"placeholder": "package name"}))
version = forms.CharField(
widget=forms.TextInput(attrs={"placeholder": "package version"}), required=False
)


class CVEForm(forms.Form):

cve_id = forms.CharField(widget=forms.TextInput(attrs={"placeholder": "vulnerability id"}))
14 changes: 14 additions & 0 deletions vulnerabilities/lib_oval.py.ABOUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
about_resource: lib_oval.py
version: 6aaae0
download_url: https://raw.githubusercontent.com/CISecurity/OVALRepo/6aaae00876ec716927e0ae5b9ccfa12f310427a0/scripts/lib_oval.py

name: OVALRepo - lib_oval
homepage_url: https://github.com/CISecurity/OVALRepo
owner: Center for Internet Security
author: Gunnar Engelbach <Gunnar.Engelbach@ThreatGuard.com>
notes: This a single file extracted from OVALRepo that parses OVAL files.

license: bsd-new
license_file: lib_oval.py.LICENSE

copyright: Copyright (c) 2010 United States Government. All Rights Reserved.
9 changes: 9 additions & 0 deletions vulnerabilities/lib_oval.py.LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Copyright© 2010 United States Government. All Rights Reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
Neither the name of the Center for Internet Security, Inc. (CIS) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER, CIS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER, CIS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 changes: 16 additions & 0 deletions vulnerabilities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class Vulnerability(models.Model):
help_text='Summary of the vulnerability', blank=True)
cvss = models.FloatField(max_length=100, help_text='CVSS Score', null=True)

@property
def vulnerable_to(self):
return self.packagerelatedvulnerability_set.filter(is_vulnerable=True)

@property
def resolved_to(self):
return self.packagerelatedvulnerability_set.filter(is_vulnerable=False)

def __str__(self):
return self.cve_id or self.summary

Expand Down Expand Up @@ -80,6 +88,14 @@ class Package(PackageURLMixin):
vulnerabilities = models.ManyToManyField(
to='Vulnerability', through='PackageRelatedVulnerability')

@property
def vulnerable_to(self):
return self.packagerelatedvulnerability_set.filter(is_vulnerable=True)

@property
def resolved_to(self):
return self.packagerelatedvulnerability_set.filter(is_vulnerable=False)

class Meta:
unique_together = ('name', 'namespace', 'type',
'version', 'qualifiers', 'subpath')
Expand Down
Loading