-
-
Notifications
You must be signed in to change notification settings - Fork 328
JSON API #8 #26
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
JSON API #8 #26
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
bfa5bc7
Add serializers based on models #8
kartiksibal 89f2bb1
Add DRF to requirements.txt
kartiksibal c75ae67
Remove un-used imports #8
kartiksibal 4d1c6c1
Merge branch 'json_api' of https://github.com/nexB/vulnerablecode int…
kartiksibal 585327a
Change data output format #8
kartiksibal 37d16b2
Change API data format to as discussed #8
kartiksibal 96d6bfd
Add test cases and change data output format #8
kartiksibal 0705c24
Updated serialization logic
kartiksibal f08d614
Add many to many field on Package #8
kartiksibal 692d72d
Remove un-used imports #8
kartiksibal fcadb17
Add test cases #8
kartiksibal d41215d
New migrations #8
kartiksibal 9015a68
Update models #8
kartiksibal bdcb807
Minor formatting changes #8
kartiksibal 42c7be2
Add test cases #8
kartiksibal d1821c4
Update unique together #8
kartiksibal 8158a84
Add missing migration file along some code cleanup #8
tdruez 0317f8a
Move tests to vulncode_app/tests #8
kartiksibal d533162
Re-order serializers according to models #8
kartiksibal 5469f99
change API url to api/ from data/ #8
kartiksibal 0bf6354
Update travis according to new dir structure
kartiksibal 9b277d6
Update tests according to changed api url #8
kartiksibal 5d5f089
Merge branch 'json_api' of https://github.com/nexB/vulnerablecode int…
kartiksibal 16ea31a
Update readme for API instructions #8
kartiksibal 86c359a
Refactor the codebase structure
tdruez b016877
Fix failing tests following codebase structure changes
tdruez 23fc544
Add back Gitter webhooks removed by mistake
tdruez a860bef
Update URL regex #8
kartiksibal c42a775
Included platform in package serializer #8
kartiksibal 2d6d5eb
Update tests according to changes #8
kartiksibal 2c5f78d
Add a `vulnerabilities` m2m field on the Package model
tdruez 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 |
|---|---|---|
| @@ -1,6 +1,10 @@ | ||
| setuptools==36.5.0 | ||
|
|
||
| beautifulsoup4==4.6.0 | ||
| lxml==3.8.0 | ||
| django==1.11.4 | ||
| lxml==4.0.0 | ||
| django==1.11.5 | ||
| djangorestframework==3.6.4 | ||
|
|
||
| # Tests | ||
| pytest==3.1.3 | ||
| pytest==3.2.2 | ||
| pycodestyle==2.3.1 |
File renamed without changes.
File renamed without changes.
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
20 changes: 20 additions & 0 deletions
20
vulnerabilities/migrations/0002_package_vulnerabilities.py
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,20 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Generated by Django 1.11.5 on 2017-09-22 19:18 | ||
| from __future__ import unicode_literals | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('vulnerabilities', '0001_initial'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='package', | ||
| name='vulnerabilities', | ||
| field=models.ManyToManyField(through='vulnerabilities.ImpactedPackage', to='vulnerabilities.Vulnerability'), | ||
| ), | ||
| ] |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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,57 @@ | ||
| # | ||
| # Copyright (c) 2017 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 code scanning tool from nexB Inc. and others. | ||
| # Visit https://github.com/nexB/vulnerablecode/ for support and download. | ||
|
|
||
| from rest_framework import serializers | ||
|
|
||
| from vulnerabilities.models import Package | ||
| from vulnerabilities.models import PackageReference | ||
| from vulnerabilities.models import Vulnerability | ||
| from vulnerabilities.models import VulnerabilityReference | ||
|
|
||
|
|
||
| class PackageReferenceSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = PackageReference | ||
| fields = ('repository', 'platform', 'name', 'version') | ||
|
|
||
|
|
||
| class VulnerabilityReferenceSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = VulnerabilityReference | ||
| fields = ('source', 'reference_id', 'url') | ||
|
|
||
|
|
||
| class VulnerabilitySerializer(serializers.ModelSerializer): | ||
| references = VulnerabilityReferenceSerializer(source='vulnerabilityreference_set', many=True) | ||
|
|
||
| class Meta: | ||
| model = Vulnerability | ||
| fields = ('summary', 'references') | ||
|
|
||
|
|
||
| class PackageSerializer(serializers.ModelSerializer): | ||
| vulnerabilities = VulnerabilitySerializer(many=True) | ||
|
|
||
| class Meta: | ||
| model = Package | ||
| fields = ('name', 'version', 'platform', 'vulnerabilities') |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on our chat, does it ever make sense to create package without name and version or both empty values?
Also what about the platform field? Same for Ubuntu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refer: #29