-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathevent.go
32 lines (26 loc) · 839 Bytes
/
event.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package yarx
import (
"fmt"
"net/http"
)
type ScanEvent struct {
Request *http.Request
Response *RespMetrics
PocMatched string
RuleMatched string
}
func (s *ScanEvent) String() string {
return fmt.Sprintf("[%s] scanned %s", s.Request.RemoteAddr, s.PocMatched)
}
type ScanEventHandleFunc func(e *ScanEvent)
// OnRuleMatch will be called if there is a poc rule matched
// for example, if a poc has there rules, OnRuleMatch will be called there times,
// meanwhile OnPocMatch will only be called once.
func (h *RegexpHandler) OnRuleMatch(fn ScanEventHandleFunc) {
h.onRuleMatches = append(h.onRuleMatches, fn)
}
// OnPocMatch will be called only if the last rule of poc get matched
// see details at OnRuleMatch
func (h *RegexpHandler) OnPocMatch(fn ScanEventHandleFunc) {
h.onPocMatches = append(h.onPocMatches, fn)
}