Skip to content

Commit

Permalink
rm/Do not apply system role access modifications (#515)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-khimov authored Sep 7, 2023
2 parents 8945368 + 365da35 commit 4377f59
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eacl/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ func matchFilters(hdrSrc TypedHeaderSource, filters []Filter) int {
// suitable target OR suitable public key.
func targetMatches(unit *ValidationUnit, record *Record) bool {
for _, target := range record.Targets() {
if target.Role() == RoleSystem {
// system role access modifications have been deprecated
continue
}

// check public key match
if pubs := target.BinaryKeys(); len(pubs) != 0 {
for _, key := range pubs {
Expand Down
33 changes: 33 additions & 0 deletions eacl/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import (
"github.com/stretchr/testify/require"
)

func checkIgnoredAction(t *testing.T, expected Action, v *Validator, vu *ValidationUnit) {
action, ok := v.CalculateAction(vu)
require.False(t, ok)
require.Equal(t, expected, action)
}

func checkAction(t *testing.T, expected Action, v *Validator, vu *ValidationUnit) {
action, ok := v.CalculateAction(vu)
require.True(t, ok)
Expand Down Expand Up @@ -191,6 +197,33 @@ func TestTargetMatches(t *testing.T) {
require.False(t, targetMatches(u, r))
}

func TestSystemRoleModificationIgnored(t *testing.T) {
tgt := *NewTarget()
tgt.SetRole(RoleSystem)

operations := []Operation{
OperationPut,
OperationGet,
OperationDelete,
OperationHead,
OperationRange,
OperationRangeHash,
}

tb := NewTable()
for _, operation := range operations {
tb.AddRecord(newRecord(ActionDeny, operation, tgt))
}

v := NewValidator()
vu := newValidationUnit(RoleSystem, nil, tb)

for _, operation := range operations {
vu.op = operation
checkIgnoredAction(t, ActionAllow, v, vu)
}
}

func makeKeys(t *testing.T, n int) [][]byte {
pubs := make([][]byte, n)
for i := range pubs {
Expand Down

0 comments on commit 4377f59

Please sign in to comment.