record the csp violators

This commit is contained in:
Ted Unangst 2023-05-27 22:47:55 -04:00
parent fd0aff3099
commit 314e0bb805
1 changed files with 12 additions and 0 deletions

12
web.go
View File

@ -2440,6 +2440,16 @@ func apihandler(w http.ResponseWriter, r *http.Request) {
}
}
func fiveoh(w http.ResponseWriter, r *http.Request) {
fd, err := os.OpenFile("violations.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
elog.Printf("error opening violations! %s", err)
return
}
defer fd.Close()
io.Copy(fd, r.Body)
}
var endoftheworld = make(chan bool)
var readyalready = make(chan bool)
var workinprogress = 0
@ -2594,6 +2604,8 @@ func serve() {
posters.HandleFunc("/server/inbox", serverinbox)
posters.HandleFunc("/inbox", serverinbox)
posters.HandleFunc("/csp-violation", fiveoh)
getters.HandleFunc("/style.css", serveviewasset)
getters.HandleFunc("/honkpage.js", serveviewasset)
getters.HandleFunc("/misc.js", serveviewasset)