Skip to content

Commit

Permalink
Adding name to the so definition for audit events (#178350)
Browse files Browse the repository at this point in the history
## Summary

Closes #175626

This PR adds a `name` field to the Audit Logging definition of a saved
object. It will be available for consumers to populate

## Related PR

Integrations elastic/integrations#9318
  • Loading branch information
kc13greiner committed Mar 19, 2024
1 parent 4677718 commit 9425de1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface AuditKibana {
saved_object?: {
type: string;
id: string;
name?: string;
};
/**
* Name of authentication provider associated with a login event.
Expand Down
17 changes: 10 additions & 7 deletions x-pack/plugins/security/server/audit/audit_events.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('#savedObjectEvent', () => {
savedObjectEvent({
action: AuditAction.CREATE,
outcome: 'unknown',
savedObject: { type: 'dashboard', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'dashboard', id: 'SAVED_OBJECT_ID', name: 'test_dashboard' },
})
).toMatchInlineSnapshot(`
Object {
Expand All @@ -50,6 +50,7 @@ describe('#savedObjectEvent', () => {
"delete_from_spaces": undefined,
"saved_object": Object {
"id": "SAVED_OBJECT_ID",
"name": "test_dashboard",
"type": "dashboard",
},
"unauthorized_spaces": undefined,
Expand All @@ -64,7 +65,7 @@ describe('#savedObjectEvent', () => {
expect(
savedObjectEvent({
action: AuditAction.CREATE,
savedObject: { type: 'dashboard', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'dashboard', id: 'SAVED_OBJECT_ID', name: 'test_dashboard' },
})
).toMatchInlineSnapshot(`
Object {
Expand All @@ -84,6 +85,7 @@ describe('#savedObjectEvent', () => {
"delete_from_spaces": undefined,
"saved_object": Object {
"id": "SAVED_OBJECT_ID",
"name": "test_dashboard",
"type": "dashboard",
},
"unauthorized_spaces": undefined,
Expand All @@ -98,7 +100,7 @@ describe('#savedObjectEvent', () => {
expect(
savedObjectEvent({
action: AuditAction.CREATE,
savedObject: { type: 'dashboard', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'dashboard', id: 'SAVED_OBJECT_ID', name: 'test_dashboard' },
error: new Error('ERROR_MESSAGE'),
})
).toMatchInlineSnapshot(`
Expand All @@ -122,6 +124,7 @@ describe('#savedObjectEvent', () => {
"delete_from_spaces": undefined,
"saved_object": Object {
"id": "SAVED_OBJECT_ID",
"name": "test_dashboard",
"type": "dashboard",
},
"unauthorized_spaces": undefined,
Expand Down Expand Up @@ -163,13 +166,13 @@ describe('#savedObjectEvent', () => {
expect(
savedObjectEvent({
action: AuditAction.GET,
savedObject: { type: 'telemetry', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'telemetry', id: 'SAVED_OBJECT_ID', name: 'telemetry_name' },
})
).toBeUndefined();
expect(
savedObjectEvent({
action: AuditAction.RESOLVE,
savedObject: { type: 'config', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'config', id: 'SAVED_OBJECT_ID', name: 'config_name' },
})
).toBeUndefined();
expect(
Expand All @@ -196,13 +199,13 @@ describe('#savedObjectEvent', () => {
expect(
savedObjectEvent({
action: AuditAction.UPDATE,
savedObject: { type: 'config', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'config', id: 'SAVED_OBJECT_ID', name: 'config_name' },
})
).not.toBeUndefined();
expect(
savedObjectEvent({
action: AuditAction.UPDATE,
savedObject: { type: 'telemetry', id: 'SAVED_OBJECT_ID' },
savedObject: { type: 'telemetry', id: 'SAVED_OBJECT_ID', name: 'telemetry_name' },
})
).not.toBeUndefined();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export interface AddAuditEventParams {
* Relevant saved object information
* object containing type & id strings
*/
savedObject?: { type: string; id: string };
savedObject?: { type: string; id: string; name?: string };
/**
* Array of spaces being added. For
* UPDATE_OBJECTS_SPACES action only
Expand Down

0 comments on commit 9425de1

Please sign in to comment.