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:
4
db.go
4
db.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user