-
Notifications
You must be signed in to change notification settings - Fork 40
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
Warn if lib32- variant is missing when adding a group #129
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
from tracker.model import CVEGroup | ||
from tracker.model import CVEGroupEntry | ||
from tracker.model import CVEGroupPackage | ||
from tracker.model import Package | ||
from tracker.model.enum import Affected | ||
from tracker.model.enum import Remote | ||
from tracker.model.enum import Severity | ||
|
@@ -199,4 +200,26 @@ def add_group(): | |
|
||
db.session.commit() | ||
flash('Added {}'.format(group.name)) | ||
|
||
missing_variants(pkgnames, group) | ||
|
||
return redirect('/{}'.format(group.name)) | ||
|
||
|
||
def missing_variants(pkgnames, group, variants=['lib32']): | ||
testpkgs = [] | ||
for pkgname in pkgnames: | ||
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 tested this locally and the behavior is correct. I wanted to make sure that we don't add a "there's a lib32 package added but this still flashes the warning" behavior. Could we add a test for it? 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. Good idea! I think test_add_group_missing_lib32_invaid handles this case, since the lib32-foo pakage is not created. |
||
for variant in variants: | ||
if variant in pkgname: | ||
pkg = pkgname.replace(f'{variant}-', '') | ||
if pkg not in pkgnames: | ||
testpkgs.append(pkg) | ||
else: | ||
pkg = f'{variant}-{pkgname}' | ||
if pkg not in pkgnames: | ||
testpkgs.append(pkg) | ||
|
||
package_data = Package.query.filter(Package.name.in_(testpkgs)).all() | ||
for pkg in package_data: | ||
if pkg not in group.packages: | ||
flash('Missing AVG for {}'.format(pkg.name)) |
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.
i would love to see a test as well that already has the lib32 variant and adds the non-lib32 one later. maybe that case should be detected and flashed as well 😺
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.
Fixed, but the code is rather deeply nested, maybe some lambda/filter/map logic can be used to make it nicer.