-
-
Notifications
You must be signed in to change notification settings - Fork 328
Update dep versions and make test pass #42
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ebf553c
Bump versions
singh1114 bd6477c
Update README with latest code and add postgresql as a dependency
singh1114 1de678a
Remove DJANGO_DEV env from travis CI
singh1114 46bf7e3
Add travis environment variable check in settings
singh1114 38c6b88
Fix tests
singh1114 4424ad2
Makes review changes
singh1114 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # Generated by Django 2.2 on 2019-04-06 09:50 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('vulnerabilities', '0002_package_vulnerabilities'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AlterField( | ||
| model_name='vulnerability', | ||
| name='cvss', | ||
| field=models.FloatField(help_text='CVSS Score', max_length=100, null=True), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name='vulnerability', | ||
| name='summary', | ||
| field=models.CharField(blank=True, help_text='Summary of the vulnerability', max_length=100), | ||
| ), | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,8 +29,8 @@ class Vulnerability(models.Model): | |
| A software vulnerability with minimal information. | ||
| Identifiers are stored as VulnerabilityReference. | ||
| """ | ||
| summary = models.CharField(max_length=50, help_text='Summary of the vulnerability', blank=True) | ||
| cvss = models.FloatField(max_length=50, help_text='CVSS Score', null=True) | ||
| summary = models.CharField(max_length=100, help_text='Summary of the vulnerability', blank=True) | ||
|
pombredanne marked this conversation as resolved.
|
||
| cvss = models.FloatField(max_length=100, help_text='CVSS Score', null=True) | ||
|
|
||
| def __str__(self): | ||
| return self.summary | ||
|
|
@@ -42,10 +42,14 @@ class VulnerabilityReference(models.Model): | |
| vulnerability data on such as a CVE ID and its web page | ||
| at the NVD, a bug id and similar references. | ||
| """ | ||
| vulnerability = models.ForeignKey('Vulnerability') | ||
| source = models.CharField(max_length=50, help_text='Source(s) name eg:NVD', blank=True) | ||
| reference_id = models.CharField(max_length=50, help_text='Reference ID, eg:CVE-ID', blank=True) | ||
| url = models.URLField(max_length=1024, help_text='URL of Vulnerability data', blank=True) | ||
| vulnerability = models.ForeignKey( | ||
| Vulnerability, on_delete=models.CASCADE) | ||
| source = models.CharField( | ||
| max_length=50, help_text='Source(s) name eg:NVD', blank=True) | ||
| reference_id = models.CharField( | ||
| max_length=50, help_text='Reference ID, eg:CVE-ID', blank=True) | ||
| url = models.URLField( | ||
| max_length=1024, help_text='URL of Vulnerability data', blank=True) | ||
|
|
||
| class Meta: | ||
| unique_together = ('vulnerability', 'source', 'reference_id', 'url') | ||
|
|
@@ -54,12 +58,26 @@ def __str__(self): | |
| return self.source | ||
|
|
||
|
|
||
| class Package(models.Model): | ||
| """ | ||
| A software package with minimal identifying information. | ||
| Other identifiers are stored as PackageReference. | ||
| """ | ||
| platform = models.CharField(max_length=50, help_text='Package platform eg:maven', blank=True) | ||
| name = models.CharField(max_length=50, help_text='Package name', blank=True) | ||
| version = models.CharField(max_length=50, help_text='Package version', blank=True) | ||
| vulnerabilities = models.ManyToManyField(to='Vulnerability', through='ImpactedPackage') | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
|
|
||
|
|
||
| class ImpactedPackage(models.Model): | ||
| """ | ||
| Relates a vulnerability to package(s) impacted by it. | ||
| """ | ||
| vulnerability = models.ForeignKey('Vulnerability') | ||
| package = models.ForeignKey('Package') | ||
| vulnerability = models.ForeignKey(Vulnerability, on_delete=models.CASCADE) | ||
| package = models.ForeignKey(Package, on_delete=models.CASCADE) | ||
|
|
||
| class Meta: | ||
| unique_together = ('vulnerability', 'package') | ||
|
|
@@ -70,30 +88,16 @@ class ResolvedPackage(models.Model): | |
| Relates a vulnerability to package(s) that contain | ||
| a fix or resolution of this vulnerability. | ||
| """ | ||
| vulnerability = models.ForeignKey('Vulnerability') | ||
| package = models.ForeignKey('Package') | ||
|
|
||
|
|
||
| class Package(models.Model): | ||
| """ | ||
| A software package with minimal identifying information. | ||
| Other identifiers are stored as PackageReference. | ||
| """ | ||
| platform = models.CharField(max_length=50, help_text='Package platform eg:maven', blank=True) | ||
| name = models.CharField(max_length=50, help_text='Package name', blank=True) | ||
| version = models.CharField(max_length=50, help_text='Package version', blank=True) | ||
| vulnerabilities = models.ManyToManyField(to='Vulnerability', through='ImpactedPackage') | ||
|
|
||
| def __str__(self): | ||
| return self.name | ||
| vulnerability = models.ForeignKey(Vulnerability, on_delete=models.CASCADE) | ||
| package = models.ForeignKey(Package, on_delete=models.CASCADE) | ||
|
|
||
|
|
||
| class PackageReference(models.Model): | ||
| """ | ||
| One or more identifiers and references for a software package | ||
| in a package repository, such as a Debian, Maven or NPM repository. | ||
| """ | ||
| package = models.ForeignKey('Package') | ||
| package = models.ForeignKey(Package, on_delete=models.CASCADE) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using classes as ForeignKeys rather than strings. |
||
| repository = models.CharField( | ||
| max_length=50, | ||
| help_text='Repository URL eg:http://central.maven.org', | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,7 @@ | |
| 'django.template.context_processors.debug', | ||
| 'django.template.context_processors.static', | ||
| 'django.template.context_processors.request', | ||
| 'django.contrib.messages.context_processors.messages' | ||
| ], | ||
| }, | ||
| }, | ||
|
|
@@ -86,9 +87,18 @@ | |
| DATABASES = { | ||
| 'default': { | ||
| 'ENGINE': 'django.db.backends.postgresql', | ||
| 'NAME': 'vulnerablecode', | ||
| 'USER': 'vulnerablecode', | ||
| 'PASSWORD': 'vulnerablecode', | ||
| 'HOST': 'localhost', | ||
| 'PORT': '5432', | ||
| } | ||
| } | ||
|
|
||
| if 'TRAVIS' in os.environ: | ||
| DATABASES['default']['USER'] = 'postgres' | ||
| DATABASES['default']['PASSWORD'] = '' | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Defaults for travisCI. |
||
|
|
||
| # Update database configuration with $DATABASE_URL. | ||
| import dj_database_url | ||
| db_from_env = dj_database_url.config(conn_max_age=500) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.