From 5d52f056eb4263d5a55aa6f46dd574f180f2064b Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Thu, 7 Jul 2022 01:28:16 +0400 Subject: [PATCH] [#583] Fix error when policy file cannot be read Signed-off-by: Angira Kekteeva --- cmd/s3-authmate/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/s3-authmate/main.go b/cmd/s3-authmate/main.go index 70f59ba5c..fdb5ef5c1 100644 --- a/cmd/s3-authmate/main.go +++ b/cmd/s3-authmate/main.go @@ -440,9 +440,16 @@ func parsePolicies(val string) (authmate.ContainerPolicies, error) { if val == "" { return nil, nil } - data, err := os.ReadFile(val) - if err != nil { + + var ( data = []byte(val) + err error + ) + + if !json.Valid(data) { + if data, err = os.ReadFile(val); err != nil { + return nil, fmt.Errorf("coudln't read json file or its content is invalid") + } } var policies authmate.ContainerPolicies