Skip to content

Commit

Permalink
cli: fix overriding of the Timestamp container attribute
Browse files Browse the repository at this point in the history
Add a check for the `Timestamp` container attribute, so there will be an error
when you create a container with the `Timestamp` attribute without
the `--disable-timestamp` flag.
Also add a check for empty attribute key and value to prevent panic.

Closes #1339.

Signed-off-by: Andrey Butusov <andrey@nspcc.io>
  • Loading branch information
End-rey committed Oct 28, 2024
1 parent 1b2a229 commit a4f192d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ attribute, which is used for container domain name in NNS contracts (#2954)
- Do not search for tombstones when handling their expiration, use local indexes instead (#2929)
- Unathorized container ops accepted by the IR (#2947)
- Structure table in the SN-configuration document (#2974)
- Overriding the `Timestamp` container attribute only with `--disable-timestamp` (#2985)

### Changed
- `ObjectService`'s `Put` RPC handler caches up to 10K lists of per-object sorted container nodes (#2901)
Expand Down
10 changes: 10 additions & 0 deletions cmd/neofs-cli/modules/container/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,16 @@ func parseAttributes(dst *container.Container, attributes []string) error {
return errors.New("invalid container attribute")
}

if kvPair[0] == "" {
return errors.New("empty attribute key")
} else if kvPair[1] == "" {
return errors.New("empty attribute value")
}

if kvPair[0] == "Timestamp" && !containerNoTimestamp {
return errors.New("can't override default timestamp attribute, use '--disable-timestamp' flag")
}

dst.SetAttribute(kvPair[0], kvPair[1])
}

Expand Down

0 comments on commit a4f192d

Please sign in to comment.