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

Fix requiredCategory issue #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions include/spiffing/categorydata.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace Spiffing {
void compile(Spif const &);
bool matches(Label const &) const;
void fixup(Label &) const;
std::set<CategoryRef> const & cats() const {
return m_cats;
}
private:
std::set<CategoryRef> m_cats;
std::string m_tagSetRef;
Expand Down
26 changes: 14 additions & 12 deletions src/categorygroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SOFTWARE.
#include <spiffing/categorygroup.h>
#include <spiffing/markings.h>
#include <spiffing/categorydata.h>
#include <spiffing/label.h>

using namespace Spiffing;

Expand All @@ -34,19 +35,20 @@ CategoryGroup::CategoryGroup(OperationType opType) : m_opType(opType) {}
bool CategoryGroup::matches(Label const & l) const {
bool found{false};
for (auto const & cd : m_categoryData) {
if (cd->matches(l)) {
switch (m_opType) {
case OperationType::onlyOne:
if (found) return false;
break;
case OperationType::oneOrMore:
return true;
case OperationType::all:
;
for (auto const & cat : cd->cats()) {
if (l.hasCategory(cat)) {
switch (m_opType) {
case OperationType::onlyOne:
if (found) return false;
break;
case OperationType::oneOrMore:
return true;
case OperationType::all:;
}
found = true;
} else if (m_opType == OperationType::all) {
return false;
}
found = true;
} else if (m_opType == OperationType::all) {
return false;
}
}
return found;
Expand Down
8 changes: 7 additions & 1 deletion test-data/food-policy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@
<securityCategoryTag name="Packaging Materials" tagType="tagType7" tag7Encoding="securityAttributes">
<tagCategory name="Plastic" lacv='0'/>
</securityCategoryTag>
</securityCategiryTagSet>
</securityCategoryTagSet>
<securityCategoryTagSet name="Something" id="1.2.826.0.1.6726289.0.0.5">
<securityCategoryTag name="Things" tagType="enumerated" enumType="permissive">
<tagCategory name="Thing One" lacv='23'/>
<tagCategory name="Thing Two" lacv='42'/>
</securityCategoryTag>
</securityCategoryTagSet>
</securityCategoryTagSets>
<markingQualifier code='pageBottom'>
<qualifier markingQualifier="[ " qualifierCode="prefix"/>
Expand Down