Skip to content
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

Filter advisories using AND operator and not OR #1433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions dnf5/commands/advisory_shared.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,29 @@ inline std::optional<libdnf5::advisory::AdvisoryQuery> advisory_query_from_cli_i
if (!advisory_types.empty() || !advisory_severities.empty() || !advisory_names.empty() || !advisory_bzs.empty() ||
!advisory_cves.empty()) {
auto advisories = libdnf5::advisory::AdvisoryQuery(base);
advisories.clear();
// Filter by advisory name
if (!advisory_names.empty()) {
auto advisories_names = libdnf5::advisory::AdvisoryQuery(base);
advisories_names.filter_name(advisory_names);
advisories |= advisories_names;
advisories.filter_name(advisory_names);
}

// Filter by advisory type
if (!advisory_types.empty()) {
auto advisories_types = libdnf5::advisory::AdvisoryQuery(base);
advisories_types.filter_type(advisory_types);
advisories |= advisories_types;
advisories.filter_type(advisory_types);
}

// Filter by advisory severity
if (!advisory_severities.empty()) {
auto advisories_severities = libdnf5::advisory::AdvisoryQuery(base);
advisories_severities.filter_severity(advisory_severities);
advisories |= advisories_severities;
advisories.filter_severity(advisory_severities);
}

// Filter by advisory bz
if (!advisory_bzs.empty()) {
auto advisories_bzs = libdnf5::advisory::AdvisoryQuery(base);
advisories_bzs.filter_reference(advisory_bzs, {"bugzilla"});
advisories |= advisories_bzs;
advisories.filter_reference(advisory_bzs, {"bugzilla"});
}

// Filter by advisory cve
if (!advisory_cves.empty()) {
auto advisories_cves = libdnf5::advisory::AdvisoryQuery(base);
advisories_cves.filter_reference(advisory_cves, {"cve"});
advisories |= advisories_cves;
advisories.filter_reference(advisory_cves, {"cve"});
}

return advisories;
Expand Down
Loading