Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ai-prompt-guard): increase the maximum length of regex expression #12731

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 to 500 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
Loading