Skip to content

Commit

Permalink
Merge pull request ceph#55414 from yuvalif/wip_yuval_url_decode_sns
Browse files Browse the repository at this point in the history
rgw/rest: fix url decode of post params passed as attributes

reviewed-by: cbodley
  • Loading branch information
yuvalif authored Feb 5, 2024
2 parents a3ec5d3 + a23b424 commit 4c0fc4a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/rgw/rgw_rest_s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5117,7 +5117,8 @@ void update_attribute_map(const std::string& input, AttributeMap& map) {
auto pos = key_or_value.find("=");
if (pos != std::string::npos) {
const auto key_or_value_lhs = key_or_value.substr(0, pos);
const auto key_or_value_rhs = url_decode(key_or_value.substr(pos + 1, key_or_value.size() - 1));
constexpr bool in_query = true; // replace '+' with ' '
const auto key_or_value_rhs = url_decode(key_or_value.substr(pos + 1, key_or_value.size() - 1), in_query);
const auto map_it = map.find(idx);
if (map_it == map.end()) {
// new entry
Expand Down
16 changes: 13 additions & 3 deletions src/test/rgw/bucket_notification/test_bn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4429,8 +4429,13 @@ def test_ps_s3_topic_permissions():
# 2nd user tries to set the attribute
status = topic_conf2.set_attributes(attribute_name="persistent", attribute_val="false", topic_arn=topic_arn)
assert False, "'AccessDenied' error is expected"
except ClientError as err:
if 'Error' in err.response:
assert_equal(err.response['Error']['Code'], 'AccessDenied')
else:
assert_equal(err.response['Code'], 'AccessDenied')
except Exception as err:
print(err)
print('unexpected error type: '+type(err).__name__)

# create bucket for conn2 and try publishing notification to topic
_ = conn2.create_bucket(bucket_name)
Expand All @@ -4442,8 +4447,13 @@ def test_ps_s3_topic_permissions():
s3_notification_conf2 = PSNotificationS3(conn2, bucket_name, topic_conf_list)
_, status = s3_notification_conf2.set_config()
assert False, "'AccessDenied' error is expected"
except ClientError as error:
assert_equal(error.response['Error']['Code'], 'AccessDenied')
except ClientError as err:
if 'Error' in err.response:
assert_equal(err.response['Error']['Code'], 'AccessDenied')
else:
assert_equal(err.response['Code'], 'AccessDenied')
except Exception as err:
print('unexpected error type: '+type(err).__name__)

# Topic policy is now added by the 1st user to allow 2nd user.
topic_policy = topic_policy.replace("Deny", "Allow")
Expand Down

0 comments on commit 4c0fc4a

Please sign in to comment.