Skip to content

Commit

Permalink
Correct handleAllDbs audit fields
Browse files Browse the repository at this point in the history
  • Loading branch information
bbrks committed Jul 22, 2024
1 parent a2175b9 commit 3f77a28
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 3 additions & 1 deletion base/audit_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,10 @@ var AuditEvents = events{
AuditIDDatabaseAllRead: {
Name: "Read all databases",
Description: "All databases were viewed",
MandatoryFields: AuditFields{
AuditFieldDBNames: []string{"list", "of", "db", "names"},
},
mandatoryFieldGroups: []fieldGroup{
fieldGroupDatabase,
fieldGroupRequest,
// fieldGroupAuthenticated, // FIXME: CBG-3973,
},
Expand Down
1 change: 1 addition & 0 deletions base/audit_events_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
AuditEffectiveUserID = "effective_userid"
AuditFieldAuditScope = "audit_scope"
AuditFieldFileName = "filename"
AuditFieldDBNames = "db_names"

// AuditIDSyncGatewayStartup AuditID = 53260
AuditFieldSGVersion = "sg_version"
Expand Down
17 changes: 12 additions & 5 deletions rest/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,19 @@ func (h *handler) handlePing() error {
}

func (h *handler) handleAllDbs() error {
base.Audit(h.ctx(), base.AuditIDDatabaseAllRead, nil)
if h.getBoolQuery("verbose") {
h.writeJSON(h.server.allDatabaseSummaries())
return nil
verbose := h.getBoolQuery("verbose")
var dbNames []string
if verbose {
summaries := h.server.allDatabaseSummaries()
for _, summary := range summaries {
dbNames = append(dbNames, summary.DBName)
}
h.writeJSON(summaries)
} else {
dbNames = h.server.AllDatabaseNames()
h.writeJSON(dbNames)
}
h.writeJSON(h.server.AllDatabaseNames())
base.Audit(h.ctx(), base.AuditIDDatabaseAllRead, base.AuditFields{base.AuditFieldDBNames: dbNames, "verbose": verbose})
return nil
}

Expand Down

0 comments on commit 3f77a28

Please sign in to comment.