Skip to content

Commit

Permalink
fixed bug and implied tests (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiriMoran authored Jan 1, 2025
1 parent 5566003 commit 15b954c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/symbolicexpr/atomic.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewAtomicTerm(label vmProperty, toVal string, neg bool) *atomicTerm {
return &atomicTerm{property: label, toVal: toVal, neg: neg}
}

// negate an atomicTerm expression; return pointer to corresponding expression from Atomics, if not there yet then add it
// negate an atomicTerm expression
func (term atomicTerm) negate() atomic {
return atomicTerm{property: term.property, toVal: term.toVal, neg: !term.neg}
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/synthesis/allowOnlyConversion.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package synthesis

import (
"slices"
"strings"

"github.com/np-guard/vmware-analyzer/pkg/model/dfw"
Expand Down Expand Up @@ -67,8 +68,7 @@ func computeAllowOnlyForCategory(inboundOrOutbound *[]*symbolicRule,
globalDenies *symbolicexpr.SymbolicPaths) (allowRule []*symbolicRule, denyPaths *symbolicexpr.SymbolicPaths) {
allowOnlyRules := []*symbolicRule{}
categoryPasses := symbolicexpr.SymbolicPaths{}
newGlobalDenies := symbolicexpr.SymbolicPaths{}
copy(newGlobalDenies, *globalDenies)
newGlobalDenies := slices.Clone(*globalDenies)
for _, rule := range *inboundOrOutbound {
switch rule.origRule.Action {
case dfw.ActionJumpToApp:
Expand All @@ -77,8 +77,7 @@ func computeAllowOnlyForCategory(inboundOrOutbound *[]*symbolicRule,
newSymbolicPaths := symbolicexpr.ComputeAllowGivenDenies(rule.origSymbolicPaths, &categoryPasses)
newGlobalDenies = append(newGlobalDenies, *newSymbolicPaths...)
case dfw.ActionAllow:
symbolicDeniesAndPasses := symbolicexpr.SymbolicPaths{}
symbolicDeniesAndPasses = append(symbolicDeniesAndPasses, newGlobalDenies...)
symbolicDeniesAndPasses := slices.Clone(newGlobalDenies)
symbolicDeniesAndPasses = append(symbolicDeniesAndPasses, categoryPasses...)
newSymbolicPaths := symbolicexpr.ComputeAllowGivenDenies(rule.origSymbolicPaths, &symbolicDeniesAndPasses)
newRule := &symbolicRule{origRule: rule.origRule, origRuleCategory: rule.origRuleCategory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Allow Only Rules
~~~~~~~~~~~~~~~~~
inbound rules
All Connections from (*) to (*)
All Connections from (*) to (group != Hufflepuff and group != Slytherin)
All Connections from (*) to (group != Hufflepuff and group = Dumbledore)
All Connections from (*) to (group = Dumbledore and group != Slytherin)
All Connections from (*) to (group = Dumbledore)
outbound rules
All Connections from (*) to (*)
All Connections from (*) to (group != Hufflepuff and group != Slytherin)
All Connections from (*) to (group != Hufflepuff and group = Dumbledore)
All Connections from (*) to (group = Dumbledore and group != Slytherin)
All Connections from (*) to (group = Dumbledore)

0 comments on commit 15b954c

Please sign in to comment.