]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Remove assertions in IAM Policy 18225/head
authorAdam C. Emerson <aemerson@redhat.com>
Tue, 10 Oct 2017 20:21:48 +0000 (16:21 -0400)
committerAdam C. Emerson <aemerson@redhat.com>
Tue, 10 Oct 2017 20:21:48 +0000 (16:21 -0400)
A couple of them could be triggered by user input.

Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/rgw/rgw_basic_types.h
src/rgw/rgw_iam_policy.cc
src/rgw/rgw_iam_policy.h

index 31e9d3a32acb4d4aac93aac5cadd993f44468e70..b4707b1a7088770b95b695a15ae5ac54f82eb360 100644 (file)
@@ -160,12 +160,10 @@ public:
   }
 
   const std::string& get_tenant() const {
-    ceph_assert(t != Wildcard);
     return u.tenant;
   }
 
   const std::string& get_id() const {
-    ceph_assert(t != Wildcard && t != Tenant);
     return u.id;
   }
 
index 2f6d8be81c2de3d6c5bd3554b541e61035b63351..97d9c13b4841f35d97c8dca8f9e7f02e6e1711a2 100644 (file)
@@ -221,7 +221,9 @@ optional<ARN> ARN::parse(const string& s, bool wildcards) {
   if ((s == "*") && wildcards) {
     return ARN(Partition::wildcard, Service::wildcard, "*", "*", "*");
   } else if (regex_match(s, match, wildcards ? rx_wild : rx_no_wild)) {
-    ceph_assert(match.size() == 6);
+    if (match.size() != 6) {
+      return boost::none;
+    }
 
     ARN a;
     {
@@ -771,7 +773,9 @@ static optional<Principal> parse_principal(CephContext* cct, TokenID t,
                          ECMAScript | optimize);
     smatch match;
     if (regex_match(a->resource, match, rx)) {
-      ceph_assert(match.size() == 3);
+      if (match.size() != 3) {
+       return boost::none;
+      }
 
       if (match[1] == "user") {
        return Principal::user(std::move(a->account),
@@ -843,7 +847,9 @@ bool ParseState::do_string(CephContext* cct, const char* s, size_t l) {
     // Principals
 
   } else if (w->kind == TokenKind::princ_type) {
-    ceph_assert(pp->s.size() > 1);
+    if (pp->s.size() <= 1) {
+      return false;
+    }
     auto& pri = pp->s[pp->s.size() - 2].w->id == TokenID::Principal ?
       t->princ : t->noprinc;
 
index 5236e6b02192179af17101d59518cffa19e5bbf1..59117456e0cc4a11c59213e29f7f37fe8fc9146d 100644 (file)
@@ -29,8 +29,6 @@
 #include "rgw_iam_policy_keywords.h"
 #include "rgw_string.h"
 
-#include "include/assert.h" // razzin' frazzin' ...grrr.
-
 class RGWRados;
 namespace rgw {
 namespace auth {
@@ -254,7 +252,6 @@ string to_string(const MaskedIP& m);
 inline bool operator ==(const MaskedIP& l, const MaskedIP& r) {
   auto shift = std::max((l.v6 ? 128 : 32) - l.prefix,
                        (r.v6 ? 128 : 32) - r.prefix);
-  ceph_assert(shift > 0);
   return (l.addr >> shift) == (r.addr >> shift);
 }