Skip to content

Commit

Permalink
Handles connect and disconnect audits for database servers where data…
Browse files Browse the repository at this point in the history
…base name is not given. (#1226)
  • Loading branch information
stevenGravy authored Oct 2, 2022
1 parent 1e4bf2c commit 9251273
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2563,7 +2563,7 @@ exports[`list of all events 1`] = `
<td
style="word-break: break-word;"
>
User [[email protected]] has disconnected from database [] on [mongo-primary]
User [[email protected]] has disconnected on [mongo-primary]
</td>
<td
style="min-width: 120px;"
Expand Down Expand Up @@ -2674,7 +2674,7 @@ exports[`list of all events 1`] = `
<td
style="word-break: break-word;"
>
User [[email protected]] has connected to database [] as [alice] on [mongo-primary]
User [[email protected]] has connected as [alice] on [mongo-primary]
</td>
<td
style="min-width: 120px;"
Expand Down
8 changes: 6 additions & 2 deletions web/packages/teleport/src/services/audit/makeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,9 @@ export const formatters: Formatters = {
type: 'db.session.start',
desc: 'Database Session Started',
format: ({ user, db_service, db_name, db_user }) =>
`User [${user}] has connected to database [${db_name}] as [${db_user}] on [${db_service}]`,
`User [${user}] has connected ${
db_name ? `to database [${db_name}] ` : ''
}as [${db_user}] on [${db_service}]`,
},
[eventCodes.DATABASE_SESSION_STARTED_FAILURE]: {
type: 'db.session.start',
Expand All @@ -711,7 +713,9 @@ export const formatters: Formatters = {
type: 'db.session.end',
desc: 'Database Session Ended',
format: ({ user, db_service, db_name }) =>
`User [${user}] has disconnected from database [${db_name}] on [${db_service}]`,
`User [${user}] has disconnected ${
db_name ? `from database [${db_name}] ` : ''
}on [${db_service}]`,
},
[eventCodes.DATABASE_SESSION_QUERY]: {
type: 'db.session.query',
Expand Down

0 comments on commit 9251273

Please sign in to comment.