bzp2010 commented on a change in pull request #5518:
URL: https://github.com/apache/apisix/pull/5518#discussion_r754043953



##########
File path: apisix/plugins/openwhisk.lua
##########
@@ -0,0 +1,124 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements.  See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License.  You may obtain a copy of the License at
+--
+--     http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+
+local core              = require("apisix.core")
+local http              = require("resty.http")
+local ngx_encode_base64 = ngx.encode_base64
+local tostring          = tostring
+
+local schema = {
+    type = "object",
+    properties = {
+        api_host = {type = "string"},
+        ssl_verify = {
+            type = "boolean",
+            default = true,
+        },
+        service_token = {type = "string"},
+        namespace = {type = "string"},
+        action = {type = "string"},
+        result = {
+            type = "boolean",
+            default = true,
+        },
+        timeout = {
+            type = "integer",
+            minimum = 1000,
+            maximum = 60000,
+            default = 3000,
+            description = "timeout in milliseconds",
+        },
+        keepalive = {type = "boolean", default = true},
+        keepalive_timeout = {type = "integer", minimum = 1000, default = 
60000},
+        keepalive_pool = {type = "integer", minimum = 1, default = 5}
+    },
+    required = {"api_host", "service_token", "namespace", "action"}
+}
+
+
+local _M = {
+    version = 0.1,
+    priority = -1901,
+    name = "openwhisk",
+    schema = schema,
+}
+
+
+function _M.check_schema(conf)
+    local ok, err = core.schema.check(schema, conf)
+    if not ok then
+        return false, err
+    end
+
+    return true
+end
+
+
+function _M.access(conf, ctx)
+    if core.request.get_method() ~= "GET" then
+        local content_type = core.request.header(ctx, "Content-Type")
+        if not core.string.has_prefix(content_type, "application/json") then
+            core.log.error("only support json request body")
+            return 415
+        end

Review comment:
       Here it is actually a requirement of OpenWhisk and does not pose a 
security problem.
   When there is an incorrect request body, OpenWhisk will return the following.
   
   ```json
   {
       "code": "M97oTvPn4Lb4TqBREemUYa5PNBImoc6F",
       "error": "The request content was malformed:\nUnexpected character 'a' 
at input index 0 (line 1, position 1), expected JSON Value:\naaa\n^\n"
   }
   ```
   
   Can we remove this check in order to use OpenWhisk's input validation 
directly?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to