-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat : Option to filter Vunerable and Non Vulnerable Packages
Signed-off-by: Rishi Garg <[email protected]>
- Loading branch information
1 parent
fabe035
commit e664411
Showing
4 changed files
with
83 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,26 @@ def test_package_view_with_valid_purl_without_version(self): | |
"pkg:nginx/[email protected]", | ||
] | ||
|
||
def test_package_search_vulnerable_only_filter(self): | ||
vulnerable_pkg = Package.objects.create(type="npm", name="vulnerable-pkg", version="1.0.0") | ||
non_vulnerable_pkg = Package.objects.create( | ||
type="npm", name="non-vulnerable-pkg", version="2.0.0" | ||
) | ||
vuln = Vulnerability.objects.create( | ||
vulnerability_id="VCID-123", summary="test vulnerability" | ||
) | ||
AffectedByPackageRelatedVulnerability.objects.create( | ||
package=vulnerable_pkg, vulnerability=vuln | ||
) | ||
self.assertTrue( | ||
AffectedByPackageRelatedVulnerability.objects.filter(package=vulnerable_pkg).exists() | ||
) | ||
self.assertFalse( | ||
AffectedByPackageRelatedVulnerability.objects.filter( | ||
package=non_vulnerable_pkg | ||
).exists() | ||
) | ||
|
||
def test_package_view_with_valid_purl_and_incomplete_version(self): | ||
qs = PackageSearch().get_queryset(query="pkg:nginx/nginx@1") | ||
pkgs = list(qs) | ||
|
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