Skip to content

Commit

Permalink
ci: add semgrep rule for HTTP API decode error status code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasell committed Nov 18, 2022
1 parent b2ad141 commit 9b55ffc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .semgrep/http_endpoint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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"

0 comments on commit 9b55ffc

Please sign in to comment.