feat: add SQL/SQLite, AppSec, Capstone incident-tracker, Gitea Actions CI and spaced repetition
Test and Lint / quality (push) Successful in 2m13s
Test and Lint / quality (push) Successful in 2m13s
This commit is contained in:
1 parent
011f23e637
commit
33082598fc
19 files changed
+496
-6
No files matched your search
@@ -0,0 +1,40 @@
|
||||
package sqlsqlite
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSQLiteCRUDAndSQLiResistance(t *testing.T) {
|
||||
reg, err := OpenRegistry(filepath.Join(t.TempDir(), "registry.db"))
|
||||
if err != nil {
|
||||
t.Fatalf("open failed: %v", err)
|
||||
}
|
||||
defer reg.Close()
|
||||
|
||||
if err := reg.InitSchema(); err != nil {
|
||||
t.Fatalf("init schema failed: %v", err)
|
||||
}
|
||||
id1, err := reg.Register("billing-api", "team-core")
|
||||
if err != nil || id1 <= 0 {
|
||||
t.Fatalf("register failed: id=%d err=%v", id1, err)
|
||||
}
|
||||
_, _ = reg.Register("auth-api", "team-core")
|
||||
_, _ = reg.Register("metrics-proxy", "team-sre")
|
||||
|
||||
got, err := reg.FindByOwner("team-core")
|
||||
if err != nil {
|
||||
t.Fatalf("find failed: %v", err)
|
||||
}
|
||||
want := []string{"auth-api", "billing-api"}
|
||||
if !reflect.DeepEqual(got, want) {
|
||||
t.Fatalf("got %v, want %v", got, want)
|
||||
}
|
||||
|
||||
// Negative security assertion: SQL Injection payload must NOT return all rows
|
||||
sqli, err := reg.FindByOwner("' OR '1'='1")
|
||||
if err != nil || len(sqli) != 0 {
|
||||
t.Fatalf("SQLi resistance failed: got=%v err=%v", sqli, err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user