refactor: replace PostgreSQL placeholders with generic SQL syntax and add audit logging for duplicate entries

- Replace $%d placeholders with ? in logsHandler for database abstraction
- Remove unused argIndex variable in auth.go
- Log duplicate permanent whitelist insertions to audit_log in db.go
This commit is contained in:
db123-test
2026-05-04 15:17:12 +03:30
parent 3fb4c6af95
commit 5a811241e1
2 changed files with 6 additions and 5 deletions

4
db.go
View File

@@ -60,6 +60,10 @@ func AddPermanentEntry(db *sql.DB, entry, apiClientIP string) (bool, error) {
_, err := db.Exec(`INSERT INTO perm_whitelist(entry) VALUES(?)`, entry)
if err != nil {
if isUniqueConstraintError(err) {
_, err = db.Exec(`INSERT INTO audit_log(action, cidr, api_client_ip) VALUES('add_perm_duplicate', ?, ?)`, entry, apiClientIP)
if err != nil {
return false, err
}
return false, nil
}
return false, err