Adding name to the so definition for audit events (#178350)

## Summary

Closes https://github.com/elastic/kibana/issues/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 https://github.com/elastic/integrations/pull/9318
This commit is contained in:
Kurt 2024-03-19 08:01:29 -04:00 committed by GitHub
parent 4677718754
commit 9425de1db2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 12 additions and 8 deletions

View file

@ -26,6 +26,7 @@ export interface AuditKibana {
saved_object?: {
type: string;
id: string;
name?: string;
};
/**
* Name of authentication provider associated with a login event.

View file

@ -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 {
@ -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,
@ -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 {
@ -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,
@ -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(`
@ -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,
@ -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(
@ -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();
});

View file

@ -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