Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add original http request to hooks #2740

Merged
merged 3 commits into from Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/appsec/request.go
Expand Up @@ -43,6 +43,7 @@
IsOutBand bool `json:"-"`
AppsecEngine string `json:"appsec_engine,omitempty"`
RemoteAddrNormalized string `json:"normalized_remote_addr,omitempty"`
OriginalHTTPRequest *http.Request `json:"-"`
}

type ReqDumpFilter struct {
Expand Down Expand Up @@ -343,5 +344,6 @@
TransferEncoding: r.TransferEncoding,
ResponseChannel: make(chan AppsecTempResponse),
RemoteAddrNormalized: remoteAddrNormalized,
OriginalHTTPRequest: r,

Check warning on line 347 in pkg/appsec/request.go

View check run for this annotation

Codecov / codecov/patch

pkg/appsec/request.go#L347

Added line #L347 was not covered by tests
}, nil
}
4 changes: 3 additions & 1 deletion pkg/appsec/waf_helpers.go
Expand Up @@ -22,6 +22,7 @@
return map[string]interface{}{
"IsInBand": request.IsInBand,
"IsOutBand": request.IsOutBand,
"req": request.OriginalHTTPRequest,

Check warning on line 25 in pkg/appsec/waf_helpers.go

View check run for this annotation

Codecov / codecov/patch

pkg/appsec/waf_helpers.go#L25

Added line #L25 was not covered by tests
"RemoveInBandRuleByID": w.RemoveInbandRuleByID,
"RemoveInBandRuleByName": w.RemoveInbandRuleByName,
"RemoveInBandRuleByTag": w.RemoveInbandRuleByTag,
Expand All @@ -39,13 +40,14 @@
"IsInBand": request.IsInBand,
"IsOutBand": request.IsOutBand,
"DumpRequest": request.DumpRequest,
"req": request.OriginalHTTPRequest,

Check warning on line 43 in pkg/appsec/waf_helpers.go

View check run for this annotation

Codecov / codecov/patch

pkg/appsec/waf_helpers.go#L43

Added line #L43 was not covered by tests
}
}

func GetOnMatchEnv(w *AppsecRuntimeConfig, request *ParsedRequest, evt types.Event) map[string]interface{} {
return map[string]interface{}{
"evt": evt,
"req": request,
"req": request.OriginalHTTPRequest,

Check warning on line 50 in pkg/appsec/waf_helpers.go

View check run for this annotation

Codecov / codecov/patch

pkg/appsec/waf_helpers.go#L50

Added line #L50 was not covered by tests
"IsInBand": request.IsInBand,
"IsOutBand": request.IsOutBand,
"SetRemediation": w.SetAction,
Expand Down