From a4f192d23c1b7085665df05027cac04be0e05ba9 Mon Sep 17 00:00:00 2001 From: Andrey Butusov Date: Mon, 28 Oct 2024 20:40:39 +0300 Subject: [PATCH] cli: fix overriding of the `Timestamp` container attribute 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 --- CHANGELOG.md | 1 + cmd/neofs-cli/modules/container/create.go | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14b57676d9..39ca002405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/cmd/neofs-cli/modules/container/create.go b/cmd/neofs-cli/modules/container/create.go index 6828d54127..de8ee54858 100644 --- a/cmd/neofs-cli/modules/container/create.go +++ b/cmd/neofs-cli/modules/container/create.go @@ -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]) }