Remove redundant length check:

The range body will not execute if the len
of r.Parameter.SignaturePayloadHeaders is 0.

Signed-off-by: Jacob Weinstock <jakobweinstock@gmail.com>
This commit is contained in:
Jacob Weinstock 2023-06-09 13:57:09 -06:00
parent bd28fd0957
commit 753d12e479

View file

@ -951,13 +951,11 @@ func (r MatchRule) Evaluate(req *Request) (bool, error) {
// signaturePayload will concatenate the request body with header values from headers specified in r.Parameter.SignaturePayloadHeaders. // signaturePayload will concatenate the request body with header values from headers specified in r.Parameter.SignaturePayloadHeaders.
func (r MatchRule) signaturePayload(body []byte, headers map[string]interface{}) []byte { func (r MatchRule) signaturePayload(body []byte, headers map[string]interface{}) []byte {
if len(r.Parameter.SignaturePayloadHeaders) > 0 { for _, elem := range r.Parameter.SignaturePayloadHeaders {
for _, elem := range r.Parameter.SignaturePayloadHeaders { h, found := headers[elem]
h, found := headers[elem] header := fmt.Sprintf("%s", h)
header := fmt.Sprintf("%s", h) if found && header != "" {
if found && header != "" { body = append(body, []byte(header)...)
body = append(body, []byte(header)...)
}
} }
} }