mirror of
https://github.com/Ed1s0nZ/PrivHunterAI.git
synced 2026-10-27 19:10:55 +00:00
26 lines
630 B
Go
26 lines
630 B
Go
package store
|
|
|
|
import (
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestAuditFilter(t *testing.T) {
|
|
s, e := Open(filepath.Join(t.TempDir(), "audit.db"))
|
|
if e != nil {
|
|
t.Fatal(e)
|
|
}
|
|
defer s.Close()
|
|
s.Log("alice", "review", "42")
|
|
s.Log("bob", "login", "session")
|
|
s.Log("alice", "login", "session")
|
|
rows, total, e := s.Audit(AuditFilter{Search: "alice", Action: "review"})
|
|
if e != nil || total != 1 || len(rows) != 1 || rows[0].Target != "42" {
|
|
t.Fatal("audit filter incorrect", e)
|
|
}
|
|
rows, total, e = s.Audit(AuditFilter{Search: "' OR 1=1 --"})
|
|
if e != nil || total != 0 || len(rows) != 0 {
|
|
t.Fatal("search injection")
|
|
}
|
|
}
|