From d18fe6d671de238aee6b4de8c5fe5cad86a2d525 Mon Sep 17 00:00:00 2001 From: Robin Xiang Date: Thu, 14 Mar 2024 14:07:49 +0800 Subject: [PATCH] feat(ai-prompt-guard): increase the maximum length of regex expression to 500 for both allow and deny parameter FTI-5767 --- .../feat-increase-ai-anthropic-regex-expression-length.yml | 4 ++++ kong/plugins/ai-prompt-guard/schema.lua | 4 ++-- spec/03-plugins/42-ai-prompt-guard/00_config_spec.lua | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 changelog/unreleased/kong/feat-increase-ai-anthropic-regex-expression-length.yml diff --git a/changelog/unreleased/kong/feat-increase-ai-anthropic-regex-expression-length.yml b/changelog/unreleased/kong/feat-increase-ai-anthropic-regex-expression-length.yml new file mode 100644 index 000000000000..f91f446618ba --- /dev/null +++ b/changelog/unreleased/kong/feat-increase-ai-anthropic-regex-expression-length.yml @@ -0,0 +1,4 @@ +message: | + **AI-Prompt-Guard**: increase the maximum length of regex expression for both allow and deny parameter +scope: Plugin +type: feature diff --git a/kong/plugins/ai-prompt-guard/schema.lua b/kong/plugins/ai-prompt-guard/schema.lua index da4dd49eebcb..d5a8e8aa1bd9 100644 --- a/kong/plugins/ai-prompt-guard/schema.lua +++ b/kong/plugins/ai-prompt-guard/schema.lua @@ -15,7 +15,7 @@ return { elements = { type = "string", len_min = 1, - len_max = 50, + len_max = 500, }}}, { deny_patterns = { description = "Array of invalid patterns, or invalid questions from the 'user' role in chat.", @@ -25,7 +25,7 @@ return { elements = { type = "string", len_min = 1, - len_max = 50, + len_max = 500, }}}, { allow_all_conversation_history = { description = "If true, will ignore all previous chat prompts from the conversation history.", diff --git a/spec/03-plugins/42-ai-prompt-guard/00_config_spec.lua b/spec/03-plugins/42-ai-prompt-guard/00_config_spec.lua index ff8cc21669f5..69dd6c82c52d 100644 --- a/spec/03-plugins/42-ai-prompt-guard/00_config_spec.lua +++ b/spec/03-plugins/42-ai-prompt-guard/00_config_spec.lua @@ -42,7 +42,7 @@ describe(PLUGIN_NAME .. ": (schema)", function() local config = { allow_all_conversation_history = true, allow_patterns = { - [1] = "123456789012345678901234567890123456789012345678901" -- 51 + [1] = string.rep('x', 501) }, } @@ -50,7 +50,7 @@ describe(PLUGIN_NAME .. ": (schema)", function() assert.is_falsy(ok) assert.not_nil(err) - assert.same({ config = {allow_patterns = { [1] = "length must be at most 50" }}}, err) + assert.same({ config = {allow_patterns = { [1] = "length must be at most 500" }}}, err) end) it("won't allow too many array items", function()