From 1929b634a1f746d6ae774a8e6102949474822f01 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Fri, 9 Sep 2022 14:34:49 +0300 Subject: [PATCH] [#332] netmap/parser: Disallow trailing garbage Signed-off-by: Evgenii Stratonikov --- netmap/parser/Query.g4 | 2 +- netmap/parser/Query.interp | Bin 4346 -> 4300 bytes netmap/parser/QueryLexer.interp | Bin 7060 -> 6957 bytes netmap/parser/query_base_listener.go | 2 +- netmap/parser/query_base_visitor.go | 2 +- netmap/parser/query_lexer.go | 303 +++++++------ netmap/parser/query_listener.go | 2 +- netmap/parser/query_parser.go | 643 +++++++++++++++++++-------- netmap/parser/query_visitor.go | 2 +- netmap/policy_test.go | 1 + 10 files changed, 617 insertions(+), 340 deletions(-) diff --git a/netmap/parser/Query.g4 b/netmap/parser/Query.g4 index fc74c6fc..52fcb4fa 100644 --- a/netmap/parser/Query.g4 +++ b/netmap/parser/Query.g4 @@ -4,7 +4,7 @@ options { tokenVocab = QueryLexer; } -policy: repStmt+ cbfStmt? selectStmt* filterStmt*; +policy: repStmt+ cbfStmt? selectStmt* filterStmt* EOF; repStmt: REP Count = NUMBER1 // number of object replicas diff --git a/netmap/parser/Query.interp b/netmap/parser/Query.interp index 9512ecb628462c54d2fb7c893a4d88015cbb1ffc..298ddaebe73fcd27e8b70021fc7ba1a1add1ab2d 100644 GIT binary patch literal 4300 zcmaKvTTdfL5QX3SSMWv>5y|bl_bFbOjjR|O+1?-}iV(1~5?XVSF-rLN`<<$p@pQ96 z8oIkqpQ<`lGoESokKf9NqwU?k++A;v9)5Y0wI9{%fD|=O3V9yo| z(>25C$4`vwVqTnXSbSP7&o#~Fn*yKXU$i+rFPP3|>&8?mKR~U(zu?TU(5@wkQQc(FkJ^k1(y^gD7c((Ih&uIPFH8)bUyvO zF0Lf3Uf1fv{OV%5Di&c?&C^YoofV5sSbRSJSgd0Bt5_|=db64>eh-)H5Oy!yvX=KG zt*>EMKCSon`*3^n)#m4NTi)&++Frjrm*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lxi9kR2Di94{ESL}3@>!38{*^{4F!4yB~Ff_LEl?Bs21rSb!#!8 z{0Om6m8cs8)t?np4bVqL7FB8NgHtuD9^Z}XtKrH@7)(RhjxVIye}wYLLn}4zIjA=1 zlvTdYJ+-xPOE?2ATS-%I^T3I=x^2^ OT6<>vLz@hU`1dDLSRRG| diff --git a/netmap/parser/QueryLexer.interp b/netmap/parser/QueryLexer.interp index d453ff6e05930c0ed8b54aaca3ea4cceb2712edd..80a47ce78550f67276c2402cfc6719ca56b462ca 100644 GIT binary patch literal 6957 zcmc(jTW=dT5QX3OSLn@c;R2#{&r=m^-3XN>Lz0oAMPay!(HeDZAaNf0?{mHxa(Bs1 zgA{!zpylOoICEymC1>^g^w-_v;NkxH?)~k<;PLj|-G>*|SVcHom3~g{YmWa z>nruwTNTTLiu0EjDi8IhK0m5)vEN-%tvAP7b56cvaCup)TCESq_12`mQTJOtKSZr= zYS`^n&&KJ)-|v2Zdbod+krJny-Bq>QQy$irSDTuas8#E2wLDZJRXL>!LY330UavQ+ z^W}b3oo|-chx!I$sh!wWo13fUzTQ^*STB#&dR1?a)%N=GWxWs8FZF&`9gh3;_Q&e= zp{m}0e7H;W{vT$m`#9mNB(es=ctbO0|RNXn=}dH0`#75XMw7=H{vBIRPqqPJxP^lc1vK z9H{6y5h{94g-X3M=R!r#xlqy5g9e)VITtE=&V`DebD^T=T&UZhozIp6i=U^NQ@<}& z9!WM9QvbU0fUy&q?qN!mhlriXn1`oRfdh_w8LSO`FnCap1>kp_?4e};qS3>ZDi06) z7sd3(5#dew->PzLpt$KxZD>Z@-TwGoUjPSaN-z9AXZCvUqjXKx#_fclZKjhRc? z9xb5$M7Cu&UTU+$x{xMuWOX4;n)%z^IHXCOC0!}SYR=Z{kYFw5rAZl>7gKo^**@7^ znOGF@w_|z8UhWvN6)9KU)}&l_Ta|b(G@jUzU`1CahRfx#wJ8_KP7W(N(>X>$xgs1Y zfg_|#-d2+Hqzl^2Nf8g5IV(YC&WeC=Duh`PI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