mirror of
https://github.com/dstotijn/hetty
synced 2024-11-10 06:04:19 +00:00
Add HTTP header support to string literal matching
This commit is contained in:
parent
aa9822854d
commit
f7def87d0f
3 changed files with 66 additions and 0 deletions
|
@ -198,6 +198,17 @@ func getMappedStringLiteralFromReq(req *http.Request, s string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchReqStringLiteral(req *http.Request, strLiteral filter.StringLiteral) (bool, error) {
|
func matchReqStringLiteral(req *http.Request, strLiteral filter.StringLiteral) (bool, error) {
|
||||||
|
for key, values := range req.Header {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.Contains(
|
||||||
|
strings.ToLower(fmt.Sprintf("%v: %v", key, value)),
|
||||||
|
strings.ToLower(strLiteral.Value),
|
||||||
|
) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range reqFilterKeyFns {
|
for _, fn := range reqFilterKeyFns {
|
||||||
value, err := fn(req)
|
value, err := fn(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -398,6 +409,17 @@ func getMappedStringLiteralFromRes(res *http.Response, s string) (string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchResStringLiteral(res *http.Response, strLiteral filter.StringLiteral) (bool, error) {
|
func matchResStringLiteral(res *http.Response, strLiteral filter.StringLiteral) (bool, error) {
|
||||||
|
for key, values := range res.Header {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.Contains(
|
||||||
|
strings.ToLower(fmt.Sprintf("%v: %v", key, value)),
|
||||||
|
strings.ToLower(strLiteral.Value),
|
||||||
|
) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range resFilterKeyFns {
|
for _, fn := range resFilterKeyFns {
|
||||||
value, err := fn(res)
|
value, err := fn(res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -181,6 +181,17 @@ func (reqLog RequestLog) getMappedStringLiteral(s string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (reqLog RequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) {
|
func (reqLog RequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) {
|
||||||
|
for key, values := range reqLog.Header {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.Contains(
|
||||||
|
strings.ToLower(fmt.Sprintf("%v: %v", key, value)),
|
||||||
|
strings.ToLower(strLiteral.Value),
|
||||||
|
) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range reqLogSearchKeyFns {
|
for _, fn := range reqLogSearchKeyFns {
|
||||||
if strings.Contains(
|
if strings.Contains(
|
||||||
strings.ToLower(fn(reqLog)),
|
strings.ToLower(fn(reqLog)),
|
||||||
|
@ -191,6 +202,17 @@ func (reqLog RequestLog) matchStringLiteral(strLiteral filter.StringLiteral) (bo
|
||||||
}
|
}
|
||||||
|
|
||||||
if reqLog.Response != nil {
|
if reqLog.Response != nil {
|
||||||
|
for key, values := range reqLog.Response.Header {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.Contains(
|
||||||
|
strings.ToLower(fmt.Sprintf("%v: %v", key, value)),
|
||||||
|
strings.ToLower(strLiteral.Value),
|
||||||
|
) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range ResLogSearchKeyFns {
|
for _, fn := range ResLogSearchKeyFns {
|
||||||
if strings.Contains(
|
if strings.Contains(
|
||||||
strings.ToLower(fn(*reqLog.Response)),
|
strings.ToLower(fn(*reqLog.Response)),
|
||||||
|
|
|
@ -174,6 +174,17 @@ func (req Request) getMappedStringLiteral(s string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (req Request) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) {
|
func (req Request) matchStringLiteral(strLiteral filter.StringLiteral) (bool, error) {
|
||||||
|
for key, values := range req.Header {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.Contains(
|
||||||
|
strings.ToLower(fmt.Sprintf("%v: %v", key, value)),
|
||||||
|
strings.ToLower(strLiteral.Value),
|
||||||
|
) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range senderReqSearchKeyFns {
|
for _, fn := range senderReqSearchKeyFns {
|
||||||
if strings.Contains(
|
if strings.Contains(
|
||||||
strings.ToLower(fn(req)),
|
strings.ToLower(fn(req)),
|
||||||
|
@ -184,6 +195,17 @@ func (req Request) matchStringLiteral(strLiteral filter.StringLiteral) (bool, er
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.Response != nil {
|
if req.Response != nil {
|
||||||
|
for key, values := range req.Response.Header {
|
||||||
|
for _, value := range values {
|
||||||
|
if strings.Contains(
|
||||||
|
strings.ToLower(fmt.Sprintf("%v: %v", key, value)),
|
||||||
|
strings.ToLower(strLiteral.Value),
|
||||||
|
) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, fn := range reqlog.ResLogSearchKeyFns {
|
for _, fn := range reqlog.ResLogSearchKeyFns {
|
||||||
if strings.Contains(
|
if strings.Contains(
|
||||||
strings.ToLower(fn(*req.Response)),
|
strings.ToLower(fn(*req.Response)),
|
||||||
|
|
Loading…
Reference in a new issue