securityevent is the one vocabulary of security events in webtyp. A layer that sees something suspicious (a refused sign-in, a denied permission, a request too large, a script the browser blocked) reports an Event through a Reporter; the composition root listens once with Listen and decides what to do with it (write a line, count, block, alert).
| File | Holds |
|---|---|
securityevent.go |
Topic, Event, Reason, Reporter, New, Report, Listen |
kind.go |
Kind, its constants, Name (OWASP Logging Vocabulary) and Level |
errors.go |
the errors, compared with == |
tests/ |
the contract through the real in-process broker (events/inprocess) |
- At startup the composition root creates the reporter over its broker:
securityevent.New(broker); a nil broker fails there. - It listens once:
securityevent.Listen(broker, handle). - A layer reports:
reporter.Report(securityevent.Event{Kind: securityevent.LoginFailed, IP: ip, Mode: mode});ReportstampsAtand publishes onTopic. handlereceives the event and writes, counts or alerts.
- An event never carries a secret: no password, token, session id or typed input.
Reasonis a constant of the reporter. - Names follow the OWASP Logging Vocabulary; kinds it lacks use its prefixes (
authn_,authz_,excess_,malicious_,sys_). Kindnumbers never change; new kinds are appended.- Zero values refuse: a zero
Reporter, a zeroKind, a nil broker or handler each return an error.