Skip to content

Commit

Permalink
add discovery config events to the web UI (#44354)
Browse files Browse the repository at this point in the history
  • Loading branch information
capnspacehook authored Jul 18, 2024
1 parent ddefda9 commit 37016a7
Show file tree
Hide file tree
Showing 5 changed files with 297 additions and 2 deletions.
4 changes: 4 additions & 0 deletions web/packages/teleport/src/Audit/EventList/EventTypeCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ const EventIconMap: Record<EventCode, any> = {
[eventCodes.SECURITY_REPORT_RUN]: Icons.Info,
[eventCodes.EXTERNAL_AUDIT_STORAGE_ENABLE]: Icons.Database,
[eventCodes.EXTERNAL_AUDIT_STORAGE_DISABLE]: Icons.Database,
[eventCodes.DISCOVERY_CONFIG_CREATE]: Icons.Info,
[eventCodes.DISCOVERY_CONFIG_UPDATE]: Icons.Info,
[eventCodes.DISCOVERY_CONFIG_DELETE]: Icons.Info,
[eventCodes.DISCOVERY_CONFIG_DELETE_ALL]: Icons.Info,
[eventCodes.UNKNOWN]: Icons.Question,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,12 @@ exports[`list of all events 1`] = `
</strong>
-
<strong>
215
219
</strong>
of

<strong>
215
219
</strong>
</div>
<button
Expand Down Expand Up @@ -723,6 +723,222 @@ exports[`list of all events 1`] = `
</button>
</td>
</tr>
<tr>
<td
style="vertical-align: inherit;"
>
<div
class="c17"
>
<span
class="c18 icon icon-info"
>
<svg
fill="currentColor"
height="20"
viewBox="0 0 24 24"
width="20"
>
<path
d="M11.625 8.8125C12.1428 8.8125 12.5625 8.39277 12.5625 7.875C12.5625 7.35723 12.1428 6.9375 11.625 6.9375C11.1072 6.9375 10.6875 7.35723 10.6875 7.875C10.6875 8.39277 11.1072 8.8125 11.625 8.8125Z"
/>
<path
d="M10.5 11.25C10.5 10.8358 10.8358 10.5 11.25 10.5C11.6478 10.5 12.0294 10.658 12.3107 10.9393C12.592 11.2206 12.75 11.6022 12.75 12V15.75C13.1642 15.75 13.5 16.0858 13.5 16.5C13.5 16.9142 13.1642 17.25 12.75 17.25C12.3522 17.25 11.9706 17.092 11.6893 16.8107C11.408 16.5294 11.25 16.1478 11.25 15.75V12C10.8358 12 10.5 11.6642 10.5 11.25Z"
/>
<path
clip-rule="evenodd"
d="M12 2.25C6.61522 2.25 2.25 6.61522 2.25 12C2.25 17.3848 6.61522 21.75 12 21.75C17.3848 21.75 21.75 17.3848 21.75 12C21.75 6.61522 17.3848 2.25 12 2.25ZM3.75 12C3.75 7.44365 7.44365 3.75 12 3.75C16.5563 3.75 20.25 7.44365 20.25 12C20.25 16.5563 16.5563 20.25 12 20.25C7.44365 20.25 3.75 16.5563 3.75 12Z"
fill-rule="evenodd"
/>
</svg>
</span>
All Discovery Configs Deleted
</div>
</td>
<td
style="word-break: break-word;"
>
User [undefined] deleted all discovery configs
</td>
<td
style="min-width: 120px;"
>
2023-05-08T19:21:39.144Z
</td>
<td
align="right"
>
<button
class="c19"
kind="border"
width="87px"
>
Details
</button>
</td>
</tr>
<tr>
<td
style="vertical-align: inherit;"
>
<div
class="c17"
>
<span
class="c18 icon icon-info"
>
<svg
fill="currentColor"
height="20"
viewBox="0 0 24 24"
width="20"
>
<path
d="M11.625 8.8125C12.1428 8.8125 12.5625 8.39277 12.5625 7.875C12.5625 7.35723 12.1428 6.9375 11.625 6.9375C11.1072 6.9375 10.6875 7.35723 10.6875 7.875C10.6875 8.39277 11.1072 8.8125 11.625 8.8125Z"
/>
<path
d="M10.5 11.25C10.5 10.8358 10.8358 10.5 11.25 10.5C11.6478 10.5 12.0294 10.658 12.3107 10.9393C12.592 11.2206 12.75 11.6022 12.75 12V15.75C13.1642 15.75 13.5 16.0858 13.5 16.5C13.5 16.9142 13.1642 17.25 12.75 17.25C12.3522 17.25 11.9706 17.092 11.6893 16.8107C11.408 16.5294 11.25 16.1478 11.25 15.75V12C10.8358 12 10.5 11.6642 10.5 11.25Z"
/>
<path
clip-rule="evenodd"
d="M12 2.25C6.61522 2.25 2.25 6.61522 2.25 12C2.25 17.3848 6.61522 21.75 12 21.75C17.3848 21.75 21.75 17.3848 21.75 12C21.75 6.61522 17.3848 2.25 12 2.25ZM3.75 12C3.75 7.44365 7.44365 3.75 12 3.75C16.5563 3.75 20.25 7.44365 20.25 12C20.25 16.5563 16.5563 20.25 12 20.25C7.44365 20.25 3.75 16.5563 3.75 12Z"
fill-rule="evenodd"
/>
</svg>
</span>
Discovery Config Deleted
</div>
</td>
<td
style="word-break: break-word;"
>
User [undefined] deleted a discovery config [discovery-config]
</td>
<td
style="min-width: 120px;"
>
2023-05-08T19:21:38.144Z
</td>
<td
align="right"
>
<button
class="c19"
kind="border"
width="87px"
>
Details
</button>
</td>
</tr>
<tr>
<td
style="vertical-align: inherit;"
>
<div
class="c17"
>
<span
class="c18 icon icon-info"
>
<svg
fill="currentColor"
height="20"
viewBox="0 0 24 24"
width="20"
>
<path
d="M11.625 8.8125C12.1428 8.8125 12.5625 8.39277 12.5625 7.875C12.5625 7.35723 12.1428 6.9375 11.625 6.9375C11.1072 6.9375 10.6875 7.35723 10.6875 7.875C10.6875 8.39277 11.1072 8.8125 11.625 8.8125Z"
/>
<path
d="M10.5 11.25C10.5 10.8358 10.8358 10.5 11.25 10.5C11.6478 10.5 12.0294 10.658 12.3107 10.9393C12.592 11.2206 12.75 11.6022 12.75 12V15.75C13.1642 15.75 13.5 16.0858 13.5 16.5C13.5 16.9142 13.1642 17.25 12.75 17.25C12.3522 17.25 11.9706 17.092 11.6893 16.8107C11.408 16.5294 11.25 16.1478 11.25 15.75V12C10.8358 12 10.5 11.6642 10.5 11.25Z"
/>
<path
clip-rule="evenodd"
d="M12 2.25C6.61522 2.25 2.25 6.61522 2.25 12C2.25 17.3848 6.61522 21.75 12 21.75C17.3848 21.75 21.75 17.3848 21.75 12C21.75 6.61522 17.3848 2.25 12 2.25ZM3.75 12C3.75 7.44365 7.44365 3.75 12 3.75C16.5563 3.75 20.25 7.44365 20.25 12C20.25 16.5563 16.5563 20.25 12 20.25C7.44365 20.25 3.75 16.5563 3.75 12Z"
fill-rule="evenodd"
/>
</svg>
</span>
Discovery Config Updated
</div>
</td>
<td
style="word-break: break-word;"
>
User [undefined] updated a discovery config [discovery-config]
</td>
<td
style="min-width: 120px;"
>
2023-05-08T19:21:37.144Z
</td>
<td
align="right"
>
<button
class="c19"
kind="border"
width="87px"
>
Details
</button>
</td>
</tr>
<tr>
<td
style="vertical-align: inherit;"
>
<div
class="c17"
>
<span
class="c18 icon icon-info"
>
<svg
fill="currentColor"
height="20"
viewBox="0 0 24 24"
width="20"
>
<path
d="M11.625 8.8125C12.1428 8.8125 12.5625 8.39277 12.5625 7.875C12.5625 7.35723 12.1428 6.9375 11.625 6.9375C11.1072 6.9375 10.6875 7.35723 10.6875 7.875C10.6875 8.39277 11.1072 8.8125 11.625 8.8125Z"
/>
<path
d="M10.5 11.25C10.5 10.8358 10.8358 10.5 11.25 10.5C11.6478 10.5 12.0294 10.658 12.3107 10.9393C12.592 11.2206 12.75 11.6022 12.75 12V15.75C13.1642 15.75 13.5 16.0858 13.5 16.5C13.5 16.9142 13.1642 17.25 12.75 17.25C12.3522 17.25 11.9706 17.092 11.6893 16.8107C11.408 16.5294 11.25 16.1478 11.25 15.75V12C10.8358 12 10.5 11.6642 10.5 11.25Z"
/>
<path
clip-rule="evenodd"
d="M12 2.25C6.61522 2.25 2.25 6.61522 2.25 12C2.25 17.3848 6.61522 21.75 12 21.75C17.3848 21.75 21.75 17.3848 21.75 12C21.75 6.61522 17.3848 2.25 12 2.25ZM3.75 12C3.75 7.44365 7.44365 3.75 12 3.75C16.5563 3.75 20.25 7.44365 20.25 12C20.25 16.5563 16.5563 20.25 12 20.25C7.44365 20.25 3.75 16.5563 3.75 12Z"
fill-rule="evenodd"
/>
</svg>
</span>
Discovery Config Created
</div>
</td>
<td
style="word-break: break-word;"
>
User [undefined] created a discovery config [discovery-config]
</td>
<td
style="min-width: 120px;"
>
2023-05-08T19:21:36.144Z
</td>
<td
align="right"
>
<button
class="c19"
kind="border"
width="87px"
>
Details
</button>
</td>
</tr>
<tr>
<td
style="vertical-align: inherit;"
Expand Down
28 changes: 28 additions & 0 deletions web/packages/teleport/src/Audit/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3206,6 +3206,34 @@ export const events = [
time: '2024-04-08T17:33:48.877Z',
uid: '2bc5e2cb-5ba1-47d7-a7ae-381cf323ae7f',
},
{
code: 'DC001I',
event: 'discovery_config.create',
time: '2023-05-08T19:21:36.144Z',
name: 'discovery-config',
updated_by: 'joe',
},
{
code: 'DC002I',
event: 'discovery_config.update',
time: '2023-05-08T19:21:37.144Z',
name: 'discovery-config',
updated_by: 'joe',
},
{
code: 'DC003I',
event: 'discovery_config.delete',
time: '2023-05-08T19:21:38.144Z',
name: 'discovery-config',
updated_by: 'joe',
},
{
code: 'DC004I',
event: 'discovery_config.delete_all',
time: '2023-05-08T19:21:39.144Z',
name: 'discovery-config',
updated_by: 'joe',
},
].map(makeEvent);

// Do not add new events to this array, add it to `events` list.
Expand Down
28 changes: 28 additions & 0 deletions web/packages/teleport/src/services/audit/makeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1616,6 +1616,34 @@ export const formatters: Formatters = {
format: ({ updated_by }) =>
`User [${updated_by}] disabled External Audit Storage`,
},
[eventCodes.DISCOVERY_CONFIG_CREATE]: {
type: 'discovery_config.create',
desc: 'Discovery Config Created',
format: ({ user, name }) => {
return `User [${user}] created a discovery config [${name}]`;
},
},
[eventCodes.DISCOVERY_CONFIG_UPDATE]: {
type: 'discovery_config.update',
desc: 'Discovery Config Updated',
format: ({ user, name }) => {
return `User [${user}] updated a discovery config [${name}]`;
},
},
[eventCodes.DISCOVERY_CONFIG_DELETE]: {
type: 'discovery_config.delete',
desc: 'Discovery Config Deleted',
format: ({ user, name }) => {
return `User [${user}] deleted a discovery config [${name}]`;
},
},
[eventCodes.DISCOVERY_CONFIG_DELETE_ALL]: {
type: 'discovery_config.delete_all',
desc: 'All Discovery Configs Deleted',
format: ({ user }) => {
return `User [${user}] deleted all discovery configs`;
},
},
[eventCodes.UNKNOWN]: {
type: 'unknown',
desc: 'Unknown Event',
Expand Down
19 changes: 19 additions & 0 deletions web/packages/teleport/src/services/audit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ export const eventCodes = {
SECURITY_REPORT_RUN: 'SRE002I',
EXTERNAL_AUDIT_STORAGE_ENABLE: 'TEA001I',
EXTERNAL_AUDIT_STORAGE_DISABLE: 'TEA002I',
DISCOVERY_CONFIG_CREATE: 'DC001I',
DISCOVERY_CONFIG_UPDATE: 'DC002I',
DISCOVERY_CONFIG_DELETE: 'DC003I',
DISCOVERY_CONFIG_DELETE_ALL: 'DC004I',
} as const;

/**
Expand Down Expand Up @@ -1476,6 +1480,21 @@ export type RawEvents = {
updated_by: string;
}
>;
[eventCodes.DISCOVERY_CONFIG_CREATE]: RawEvent<
typeof eventCodes.DISCOVERY_CONFIG_CREATE,
HasName
>;
[eventCodes.DISCOVERY_CONFIG_UPDATE]: RawEvent<
typeof eventCodes.DISCOVERY_CONFIG_UPDATE,
HasName
>;
[eventCodes.DISCOVERY_CONFIG_DELETE]: RawEvent<
typeof eventCodes.DISCOVERY_CONFIG_DELETE,
HasName
>;
[eventCodes.DISCOVERY_CONFIG_DELETE_ALL]: RawEvent<
typeof eventCodes.DISCOVERY_CONFIG_DELETE_ALL
>;
};

/**
Expand Down

0 comments on commit 37016a7

Please sign in to comment.