Copilot commented on code in PR #13570:
URL: https://github.com/apache/apisix/pull/13570#discussion_r3449376398


##########
apisix/plugins/ai-lakera-guard/schema.lua:
##########
@@ -0,0 +1,105 @@
+--
+-- 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 binding = require("apisix.plugins.ai-protocols.binding")
+
+
+local schema = {
+    type = "object",
+    properties = {
+        api_key = {
+            type = "string",
+            description = "Lakera Guard API key, sent as 'Authorization: 
Bearer'.",
+        },
+        lakera_endpoint = {
+            type = "string",
+            pattern = [[^https?://]],
+            default = "https://api.lakera.ai/v2/guard";,
+            description = "Lakera Guard v2 endpoint.",
+        },
+        project_id = {
+            type = "string",
+            description = "Lakera project whose policy (detectors + 
thresholds) to apply.",
+        },
+        direction = {
+            type = "string",
+            -- input only in this phase; output/both are added in later phases.
+            enum = { "input" },
+            default = "input",
+            description = "Which traffic to scan.",
+        },
+        action = {
+            type = "string",
+            enum = { "block", "alert" },
+            default = "block",
+            description = "block = enforce; alert = log-only shadow mode (pass 
traffic).",
+        },
+        fail_open = {
+            type = "boolean",
+            default = false,
+            description = "On Lakera error/timeout: false = fail-closed 
(deny), true = allow.",
+        },
+        fail_mode = binding.schema_property("skip"),

Review Comment:
   PR description says the plugin "requires" ai-proxy/ai-proxy-multi and 
returns 500 otherwise, but the implementation defaults `fail_mode` to `skip`, 
which passes non-ai-proxy requests through unchecked (as also described in the 
new docs/tests). Please align the PR description with the actual default 
behavior (or change the default intentionally).



##########
apisix/plugins/ai-lakera-guard/schema.lua:
##########
@@ -0,0 +1,105 @@
+--
+-- 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 binding = require("apisix.plugins.ai-protocols.binding")
+
+
+local schema = {
+    type = "object",
+    properties = {
+        api_key = {
+            type = "string",
+            description = "Lakera Guard API key, sent as 'Authorization: 
Bearer'.",
+        },

Review Comment:
   `api_key` is marked as required but the schema allows an empty string, which 
would result in sending no `Authorization` header (and likely blocking requests 
unexpectedly). Consider enforcing a non-empty value at schema validation time 
with `minLength = 1`.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to