-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 597-migrate-archlinux
Merging latest 'main' into this archlinux importer branch. Signed-off-by: John M. Horan <[email protected]>
- Loading branch information
Showing
8 changed files
with
126 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
|
@@ -18,6 +18,20 @@ | |
</div> | ||
</div> | ||
<div class="navbar-end mr-3"> | ||
<div class="navbar-item navbar-item is-cursor-help"> | ||
<div class="dropdown is-right is-hoverable "> | ||
<div class="dropdown-trigger has-text-grey-light"> | ||
API | ||
</div> | ||
<div class="dropdown-menu navbar-hover-div" role="menu"> | ||
<div class="dropdown-content"> | ||
<div class="dropdown-item about-hover-div"> | ||
If you want to try the JSON REST API for VulnerableCode.io, please send an email to <a href="mailto:[email protected]">[email protected]</a> with "VulnerableCode API Key" in the email title. API access is limited to a maximum of 1000 package-versions per request. | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="navbar-item navbar-item is-cursor-help"> | ||
<div class="dropdown is-right is-hoverable "> | ||
<div class="dropdown-trigger has-text-grey-light"> | ||
|
@@ -46,7 +60,6 @@ | |
Source code and issues at <a href="https://github.com/nexB/vulnerablecode">https://github.com/nexB/vulnerablecode</a> | ||
</li> | ||
</ul> | ||
If you want to try the JSON REST API, please send a note to <a href="mailto:[email protected]">[email protected]</a> to request an API key for testing. | ||
</div> | ||
</div> | ||
</div> | ||
|
This file contains 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 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,66 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# VulnerableCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
# See https://github.com/nexB/vulnerablecode for support or download. | ||
# See https://aboutcode.org for more information about nexB OSS projects. | ||
# | ||
|
||
from django.contrib.auth import get_user_model | ||
from django.test import TestCase | ||
from packageurl import PackageURL | ||
|
||
from vulnerabilities.models import Package | ||
from vulnerabilities.models import PackageRelatedVulnerability | ||
from vulnerabilities.models import Vulnerability | ||
|
||
User = get_user_model() | ||
|
||
|
||
class TestPackageModel(TestCase): | ||
def setUp(self): | ||
vuln1 = Vulnerability.objects.create( | ||
summary="test-vuln", | ||
) | ||
vuln2 = Vulnerability.objects.create( | ||
summary="test-vuln1", | ||
) | ||
for i in range(0, 10): | ||
query_kwargs = dict( | ||
type="generic", | ||
namespace="nginx", | ||
name="test", | ||
version=str(i), | ||
qualifiers={}, | ||
subpath="", | ||
) | ||
vuln_package = Package.objects.create(**query_kwargs) | ||
# Attaching same package to 2 vulnerabilities | ||
PackageRelatedVulnerability.objects.create( | ||
package=vuln_package, | ||
vulnerability=vuln1, | ||
fix=False, | ||
) | ||
PackageRelatedVulnerability.objects.create( | ||
package=vuln_package, | ||
vulnerability=vuln2, | ||
fix=False, | ||
) | ||
|
||
def test_get_vulnerable_packages(self): | ||
vuln_packages = Package.objects.vulnerable() | ||
assert vuln_packages.count() == 10 | ||
vuln_purls = [pkg.purl for pkg in vuln_packages.only(*PackageURL._fields)] | ||
assert vuln_purls == [ | ||
"pkg:generic/nginx/test@0", | ||
"pkg:generic/nginx/test@1", | ||
"pkg:generic/nginx/test@2", | ||
"pkg:generic/nginx/test@3", | ||
"pkg:generic/nginx/test@4", | ||
"pkg:generic/nginx/test@5", | ||
"pkg:generic/nginx/test@6", | ||
"pkg:generic/nginx/test@7", | ||
"pkg:generic/nginx/test@8", | ||
"pkg:generic/nginx/test@9", | ||
] |
This file contains 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