Commit 0218a340 authored by Yong Tang's avatar Yong Tang Committed by GitHub

Fix out-of-index issue in rewrite plugin (#5462)

This PR fixes another out-of-index issue in rewrite to avoid
security vuln.
Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>
parent e0dead4a
...@@ -100,6 +100,9 @@ func newRule(args ...string) (Rule, error) { ...@@ -100,6 +100,9 @@ func newRule(args ...string) (Rule, error) {
switch arg0 { switch arg0 {
case Continue: case Continue:
mode = Continue mode = Continue
if len(args) < 2 {
return nil, fmt.Errorf("continue rule must begin with a rule type")
}
ruleType = strings.ToLower(args[1]) ruleType = strings.ToLower(args[1])
expectNumArgs = len(args) - 1 expectNumArgs = len(args) - 1
startArg = 2 startArg = 2
......
...@@ -33,6 +33,7 @@ func TestParse(t *testing.T) { ...@@ -33,6 +33,7 @@ func TestParse(t *testing.T) {
name regex foo bar name regex foo bar
}`, true, "must begin with a name rule"}, }`, true, "must begin with a name rule"},
{`rewrite stop`, true, ""}, {`rewrite stop`, true, ""},
{`rewrite continue`, true, ""},
} }
for i, test := range tests { for i, test := range tests {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment