Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Commit

Permalink
Indicate whether session.network events were allowed or blocked (#800)
Browse files Browse the repository at this point in the history
* Indicate whether session.network events were allowed or blocked

Fixes TEL-Q421-2
Fixes gravitational/teleport.e#331
  • Loading branch information
zmb3 authored May 2, 2022
1 parent 7bb9cf5 commit 0651e48
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3271,7 +3271,7 @@ exports[`list of all events 1`] = `
<td
style="word-break: break-word;"
>
Program [bash] opened a connection [10.217.136.161 &lt;-&gt; 190.58.129.4:3000] within a session [44c6cea8-362f-11ea-83aa-125400432324]
[DENY] Program [bash] was prevented from opening a connection [10.217.136.161 &lt;-&gt; 190.58.129.4:3000] within a session [44c6cea8-362f-11ea-83aa-125400432324]
</td>
<td
style="min-width: 120px;"
Expand Down Expand Up @@ -4310,7 +4310,7 @@ exports[`loaded audit log screen 1`] = `
<td
style="word-break: break-word;"
>
Program [bash] opened a connection [10.217.136.161 &lt;-&gt; 190.58.129.4:3000] within a session [44c6cea8-362f-11ea-83aa-125400432324]
[ALLOW] Program [bash] successfully opened a connection [10.217.136.161 &lt;-&gt; 190.58.129.4:3000] within a session [44c6cea8-362f-11ea-83aa-125400432324]
</td>
<td
style="min-width: 120px;"
Expand Down
2 changes: 2 additions & 0 deletions packages/teleport/src/Audit/fixtures/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const events = [
dst_port: '3000',
version: 4,
time: '2019-04-22T19:39:26.676Z',
action: 1,
},
{
code: 'T4001I',
Expand Down Expand Up @@ -1135,6 +1136,7 @@ export const eventsSample = [
dst_port: '3000',
version: 4,
time: '2019-04-22T19:39:26.676Z',
action: 0,
},
{
code: 'T4001I',
Expand Down
32 changes: 22 additions & 10 deletions packages/teleport/src/services/audit/makeEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ export const formatters: Formatters = {
[eventCodes.SESSION_NETWORK]: {
type: 'session.network',
desc: 'Session Network Connection',
format: ({ sid, program, src_addr, dst_addr, dst_port }) =>
`Program [${program}] opened a connection [${src_addr} <-> ${dst_addr}:${dst_port}] within a session [${sid}]`,
format: ({ action, sid, program, src_addr, dst_addr, dst_port }) => {
const a = action === 1 ? '[DENY]' : '[ALLOW]';
const desc =
action === 1 ? 'was prevented from opening' : 'successfully opened';
return `${a} Program [${program}] ${desc} a connection [${src_addr} <-> ${dst_addr}:${dst_port}] within a session [${sid}]`;
},
},
[eventCodes.SESSION_PROCESS_EXIT]: {
type: 'session.process_exit',
Expand Down Expand Up @@ -445,7 +449,14 @@ export const formatters: Formatters = {
[eventCodes.MYSQL_STATEMENT_SEND_LONG_DATA]: {
type: 'db.session.mysql.statements.send_long_data',
desc: 'MySQL Statement Send Long Data',
format: ({ user, db_service, db_name, statement_id, parameter_id, data_size }) =>
format: ({
user,
db_service,
db_name,
statement_id,
parameter_id,
data_size,
}) =>
`User [${user}] has sent ${data_size} bytes of data to parameter [${parameter_id}] of statement [${statement_id}] in database [${db_name}] on [${db_service}]`,
},
[eventCodes.MYSQL_STATEMENT_CLOSE]: {
Expand Down Expand Up @@ -631,20 +642,21 @@ export const formatters: Formatters = {
format: ({ server_addr }) => `Session connected to [${server_addr}]`,
},
[eventCodes.CERTIFICATE_CREATED]: {
type: "cert.create",
desc: "Certificate Issued",
type: 'cert.create',
desc: 'Certificate Issued',
format: ({ cert_type, identity: { user } }) => {
if (cert_type === 'user') {
return `User certificate issued for [${user}]`
return `User certificate issued for [${user}]`;
}
return `Certificate of type [${cert_type}] issued for [${user}]`
}
return `Certificate of type [${cert_type}] issued for [${user}]`;
},
},
[eventCodes.UNKNOWN]: {
type: 'unknown',
desc: 'Unknown Event',
format: ({ unknown_type, unknown_code }) => `Unknown '${unknown_type}' event (${unknown_code})`,
}
format: ({ unknown_type, unknown_code }) =>
`Unknown '${unknown_type}' event (${unknown_code})`,
},
};

const unknownFormatter = {
Expand Down
1 change: 1 addition & 0 deletions packages/teleport/src/services/audit/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ type RawEventCommand<T extends EventCode> = RawEvent<
type RawEventNetwork<T extends EventCode> = RawEvent<
T,
{
action: number;
login: string;
namespace: string;
pid: number;
Expand Down

0 comments on commit 0651e48

Please sign in to comment.