fix: allow configuring excess versions alerting (#19028)

Bonus: enable audit alerts for object versions
beyond the configured value, default is '100'
versions per object beyond which scanner will
alert for each such objects.
This commit is contained in:
Harshavardhana
2024-02-11 23:41:53 -08:00
committed by GitHub
parent e3fbac9e24
commit afd19de5a9
7 changed files with 114 additions and 20 deletions

View File

@@ -19,6 +19,7 @@ package cmd
import (
"bufio"
"context"
"io"
"net/http"
"net/url"
@@ -1035,9 +1036,18 @@ func (api objectAPIHandlers) CompleteMultipartUploadHandler(w http.ResponseWrite
Metadata: cleanReservedKeys(objInfo.UserDefined),
})
if objInfo.NumVersions > dataScannerExcessiveVersionsThreshold {
if objInfo.NumVersions > int(scannerExcessObjectVersions.Load()) {
evt.EventName = event.ObjectManyVersions
sendEvent(evt)
auditLogInternal(context.Background(), AuditLogOptions{
Event: "scanner:manyversions",
APIName: "CompleteMultipartUpload",
Bucket: objInfo.Bucket,
Object: objInfo.Name,
VersionID: objInfo.VersionID,
Status: http.StatusText(http.StatusOK),
})
}
// Remove the transitioned object whose object version is being overwritten.