2023-04-10 15:36:59 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-11-18 16:47:43 +00:00
|
|
|
rules:
|
|
|
|
- id: "http-endpoint-request-decode-error-code"
|
|
|
|
patterns:
|
|
|
|
- pattern: |
|
|
|
|
if err := decodeBody(...); err != nil {
|
|
|
|
return nil, CodedError(...)
|
|
|
|
}
|
|
|
|
- pattern-not-inside: |
|
|
|
|
if err := decodeBody(...); err != nil {
|
|
|
|
return nil, CodedError(400, ...)
|
|
|
|
}
|
|
|
|
- pattern-not-inside: |
|
|
|
|
if err := decodeBody(...); err != nil {
|
|
|
|
return nil, CodedError(http.StatusBadRequest, ...)
|
|
|
|
}
|
|
|
|
message: "HTTP endpoint request decode should return http.StatusBadRequest"
|
|
|
|
languages:
|
|
|
|
- "go"
|
|
|
|
severity: "ERROR"
|
|
|
|
paths:
|
|
|
|
include:
|
|
|
|
- "command/agent/*_endpoint.go"
|