Skip to content

Commit 1164374

Browse files
authored
fix(grpc-transcode): filter out illegal INT(string) formats (#11367)
1 parent 7f649bc commit 1164374

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

apisix-master-0.rockspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = {
4848
"lua-resty-session = 3.10",
4949
"opentracing-openresty = 0.1",
5050
"lua-resty-radixtree = 2.9.1",
51-
"lua-protobuf = 0.5.0-1",
51+
"lua-protobuf = 0.5.2-1",
5252
"lua-resty-openidc = 1.7.6-3",
5353
"luafilesystem = 1.7.0-2",
5454
"nginx-lua-prometheus-api7 = 0.20240201-1",

t/plugin/grpc-transcode3.t

+51
Original file line numberDiff line numberDiff line change
@@ -525,3 +525,54 @@ location /t {
525525
end
526526
}
527527
}
528+
529+
530+
531+
=== TEST 13: bugfix - filter out illegal INT(string) formats
532+
--- config
533+
location /t {
534+
content_by_lua_block {
535+
local pcall = pcall
536+
local require = require
537+
local protoc = require("protoc")
538+
local pb = require("pb")
539+
local pb_encode = pb.encode
540+
541+
assert(protoc:load [[
542+
syntax = "proto3";
543+
message IntStringPattern {
544+
int64 value = 1;
545+
}]])
546+
547+
local patterns
548+
do
549+
local function G(pattern)
550+
return {pattern, true}
551+
end
552+
553+
local function B(pattern)
554+
return {pattern, [[bad argument #2 to '?' (number/'#number' expected for field 'value', got string)]]}
555+
end
556+
557+
patterns = {
558+
G(1), G(2), G(-3), G("#123"), G("0xabF"), G("#-0x123abcdef"), G("-#0x123abcdef"), G("#0x123abcdef"), G("123"),
559+
B("#a"), B("+aaa"), B("#aaaa"), B("#-aa"),
560+
}
561+
end
562+
563+
for _, p in pairs(patterns) do
564+
local pattern = {
565+
value = p[1],
566+
}
567+
local status, err = pcall(pb_encode, "IntStringPattern", pattern)
568+
local res = status
569+
if not res then
570+
res = err
571+
end
572+
assert(res == p[2])
573+
end
574+
ngx.say("passed")
575+
}
576+
}
577+
--- response_body
578+
passed

0 commit comments

Comments
 (0)