Skip to content

Commit

Permalink
feat(ai-prompt-guard): increase the maximum length of regex expression
Browse files Browse the repository at this point in the history
to 500 for both allow and deny parameter

FTI-5767
  • Loading branch information
liverpool8056 committed Mar 14, 2024
1 parent c72f980 commit d18fe6d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions kong/plugins/ai-prompt-guard/schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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.",
Expand Down
4 changes: 2 additions & 2 deletions spec/03-plugins/42-ai-prompt-guard/00_config_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ describe(PLUGIN_NAME .. ": (schema)", function()
local config = {
allow_all_conversation_history = true,
allow_patterns = {
[1] = "123456789012345678901234567890123456789012345678901" -- 51
[1] = string.rep('x', 501)
},
}

local ok, err = validate(config)

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()
Expand Down

0 comments on commit d18fe6d

Please sign in to comment.