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: Yong Tang <yong.tang.github@outlook.com>
This commit is contained in:
Yong Tang 2022-06-26 16:06:43 -07:00 committed by GitHub
parent e0dead4aa2
commit 0218a34008
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -100,6 +100,9 @@ func newRule(args ...string) (Rule, error) {
switch arg0 {
case Continue:
mode = Continue
if len(args) < 2 {
return nil, fmt.Errorf("continue rule must begin with a rule type")
}
ruleType = strings.ToLower(args[1])
expectNumArgs = len(args) - 1
startArg = 2

View file

@ -33,6 +33,7 @@ func TestParse(t *testing.T) {
name regex foo bar
}`, true, "must begin with a name rule"},
{`rewrite stop`, true, ""},
{`rewrite continue`, true, ""},
}
for i, test := range tests {