Skip to content

Commit

Permalink
cli/eacl: deprecate using public key targets in eACL tables
Browse files Browse the repository at this point in the history
Refs #2922.

Signed-off-by: Pavel Karpy <[email protected]>
  • Loading branch information
carpawell committed Oct 10, 2024
1 parent 113da9a commit c49bf14
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ Increase default timeout for dialing connections in node: `morph.dial_timeout`,
`morph.dial_timout`, `morph.consensus.p2p.dial_timout`, `mainnet.dial_timout`
to 1 minute. Can be adjusted for fast networks.

Using public keys as a rule target in eACL tables was deprecated and will not
be supported in the next releases, use addresses instead. For more information
call `neofs-cli acl extended create -h`.

## [0.43.0] - 2024-08-20 - Jukdo

### Added
Expand Down
25 changes: 24 additions & 1 deletion cmd/neofs-cli/modules/acl/extended/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"strings"

"github.com/flynn-archive/go-shlex"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/modules/util"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
Expand Down Expand Up @@ -42,7 +43,7 @@ Target is
'user' for container owner,
'system' for Storage nodes in container and Inner Ring nodes,
'others' for all other request senders,
'pubkey:<key1>,<key2>,...' for exact request sender, where <key> is a hex-encoded 33-byte public key,
'pubkey:<key1>,<key2>,...' for exact request sender, where <key> is a hex-encoded 33-byte public key, DEPRECATED,
'address:<adr1>,<adr2>,...' for exact request sender, where <adr> is a base58 25-byte address. Example: NSiVJYZej4XsxG5CUpdwn7VRQk8iiiDMPM.
When both '--rule' and '--file' arguments are used, '--rule' records will be placed higher in resulting extended ACL table.
Expand Down Expand Up @@ -86,6 +87,8 @@ func createEACL(cmd *cobra.Command, _ []string) error {
return errors.New("no extended ACL rules has been provided")
}

warnIfPubKeyTargetFound(cmd, rules)

Check warning on line 90 in cmd/neofs-cli/modules/acl/extended/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/acl/extended/create.go#L90

Added line #L90 was not covered by tests

var tb eacl.Table
if err := util.ParseEACLRules(&tb, rules); err != nil {
return fmt.Errorf("unable to parse provided rules: %w", err)
Expand Down Expand Up @@ -134,3 +137,23 @@ func getRulesFromFile(filename string) ([]string, error) {

return strings.Split(strings.TrimSpace(string(data)), "\n"), nil
}

func warnIfPubKeyTargetFound(cmd *cobra.Command, rules []string) {
for _, rule := range rules {
record, err := shlex.Split(rule)
if err != nil {
return

Check warning on line 145 in cmd/neofs-cli/modules/acl/extended/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/acl/extended/create.go#L141-L145

Added lines #L141 - L145 were not covered by tests
}

if len(record) < 2 {
return

Check warning on line 149 in cmd/neofs-cli/modules/acl/extended/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/acl/extended/create.go#L148-L149

Added lines #L148 - L149 were not covered by tests
}

for _, target := range record[2:] {
targetTokens := strings.SplitN(target, ":", 2)
if strings.ToLower(targetTokens[0]) == "pubkey" {
cmd.Println("WARN: using public keys as eACL table targets was deprecated and will be dropped in the next releases")

Check warning on line 155 in cmd/neofs-cli/modules/acl/extended/create.go

View check run for this annotation

Codecov / codecov/patch

cmd/neofs-cli/modules/acl/extended/create.go#L152-L155

Added lines #L152 - L155 were not covered by tests
}
}
}
}

0 comments on commit c49bf14

Please sign in to comment.