-
-
Notifications
You must be signed in to change notification settings - Fork 328
Add UI for VulnerableCode #230
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
Changes from all commits
6dbeabd
0b4e8fb
6df8c1f
9c71ff1
14d1fc7
4e0f741
e3d421b
ef90285
f8e9e2d
8e03a2e
776af5c
7b8835a
38d90a0
b99675d
fda98d2
a18d452
0a1d007
2a0b6d1
3983119
38905e0
d8afc73
4340264
c09bbdd
d6897b8
2443fc1
5d3ee7f
c735c35
1caad95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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")) | ||
| return pkg_types | ||
|
|
||
|
|
||
| def get_package_namespaces(): | ||
| pkg_namespaces = [ | ||
| (i.namespace, i.namespace) | ||
|
Member
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. I am puzzled by the repetition.
Collaborator
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. 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 |
||
| 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"})) | ||
| 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. |
| 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. |
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.
What is
"package type"about? I am also puzzled by the repetition (a bit of docstring would help I guess?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.
package typeis just another choice , which roughly translates into the user not caring about the pkg type of results obtainedThere 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.
I am still not clear at all why you need that?
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.
placeholder
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.
Ah, you mean a placeholder in the UI dropdown?