Skip to content

Commit

Permalink
fix misspelling
Browse files Browse the repository at this point in the history
  • Loading branch information
sheyanjie-taos committed Dec 15, 2023
1 parent 28c2f6d commit e33ee93
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions api/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var auditLogger = log.GetLogger("audit")

const MAX_DETAIL_LEN = 50000

const MAX_SQL_LEN = 1000 * 1000
var MAX_SQL_LEN = 1000 * 1000

type Audit struct {
username string
Expand Down Expand Up @@ -188,19 +188,19 @@ func handleBatchRecord(auditArray []AuditInfo, conn *db.Connector) error {
for _, audit := range auditArray {

details := handleDetails(audit.Details)
varluesStr := fmt.Sprintf(
valuesStr := fmt.Sprintf(
"(%s, '%s', '%s', '%s', '%s', '%s', '%s') ",
audit.Timestamp, audit.User, audit.Operation, audit.Db, audit.Resource, audit.ClientAdd, details)

if (builder.Len() + len(varluesStr)) > MAX_SQL_LEN {
if (builder.Len() + len(valuesStr)) > MAX_SQL_LEN {
sql := builder.String()
if _, err := conn.Exec(context.Background(), sql); err != nil {
return err
}
builder.Reset()
builder.WriteString(head)
}
builder.WriteString(varluesStr)
builder.WriteString(valuesStr)
}

if builder.Len() > len(head) {
Expand Down
1 change: 1 addition & 0 deletions api/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func TestAudit(t *testing.T) {
})
}

MAX_SQL_LEN = 300
// test audit batch
input := `{"records":[{"timestamp":"1702548856940013848","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45166","db":"test","resource":"","details":"d630302"},{"timestamp":"1702548856939746458","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45230","db":"test","resource":"","details":"d130277"},{"timestamp":"1702548856939586665","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:50288","db":"test","resource":"","details":"d5268"},{"timestamp":"1702548856939528940","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:50222","db":"test","resource":"","details":"d255282"},{"timestamp":"1702548856939336371","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45126","db":"test","resource":"","details":"d755297"},{"timestamp":"1702548856939075131","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45122","db":"test","resource":"","details":"d380325"},{"timestamp":"1702548856938640661","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45152","db":"test","resource":"","details":"d255281"},{"timestamp":"1702548856938505795","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45122","db":"test","resource":"","details":"d130276"},{"timestamp":"1702548856938363319","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45178","db":"test","resource":"","details":"d755296"},{"timestamp":"1702548856938201478","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:45166","db":"test","resource":"","details":"d380324"},{"timestamp":"1702548856937740618","cluster_id":"8468922059162439502","user":"root","operation":"createTable","client_add":"173.50.0.7:50288","db":"test","resource":"","details":"d5266"}]}`

Expand Down

0 comments on commit e33ee93

Please sign in to comment.