Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add session recording access usage event #47310

Merged
merged 2 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/usagereporter/teleport/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ func ConvertAuditEvent(event apievents.AuditEvent) Anonymizable {
}
case *apievents.CrownJewelCreate:
return &AccessGraphCrownJewelCreateEvent{}
case *apievents.SessionRecordingAccess:
return &SessionRecordingAccessEvent{
SessionType: e.SessionType,
UserName: e.User,
Format: e.Format,
}
}

return nil
Expand Down
26 changes: 26 additions & 0 deletions lib/usagereporter/teleport/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/gravitational/teleport"
"github.com/gravitational/teleport/api/types"
apievents "github.com/gravitational/teleport/api/types/events"
prehogv1a "github.com/gravitational/teleport/gen/proto/go/prehog/v1alpha"
"github.com/gravitational/teleport/lib/utils"
Expand Down Expand Up @@ -212,6 +214,30 @@ func TestConvertAuditEvent(t *testing.T) {
},
},
},
{
desc: "SessionRecordingAccess",
event: &apievents.SessionRecordingAccess{
UserMetadata: apievents.UserMetadata{
User: "some-user",
},
SessionType: string(types.SSHSessionKind),
Format: teleport.PTY,
},
expected: &SessionRecordingAccessEvent{
SessionType: string(types.SSHSessionKind),
UserName: "some-user",
Format: teleport.PTY,
},
expectedAnonymized: &prehogv1a.SubmitEventRequest{
Event: &prehogv1a.SubmitEventRequest_SessionRecordingAccess{
SessionRecordingAccess: &prehogv1a.SessionRecordingAccessEvent{
SessionType: string(types.SSHSessionKind),
UserName: anonymizer.AnonymizeString("some-user"),
Format: teleport.PTY,
},
},
},
},
}

for _, tt := range cases {
Expand Down
16 changes: 16 additions & 0 deletions lib/usagereporter/teleport/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,22 @@ func (u *UserTaskStateEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEvent
}
}

// SessionRecordingAccessEvent is an event that is emitted after an user access
// a session recording.
type SessionRecordingAccessEvent prehogv1a.SessionRecordingAccessEvent

func (s *SessionRecordingAccessEvent) Anonymize(a utils.Anonymizer) prehogv1a.SubmitEventRequest {
return prehogv1a.SubmitEventRequest{
Event: &prehogv1a.SubmitEventRequest_SessionRecordingAccess{
SessionRecordingAccess: &prehogv1a.SessionRecordingAccessEvent{
SessionType: s.SessionType,
UserName: a.AnonymizeString(s.UserName),
Format: s.Format,
},
},
}
}

// ConvertUsageEvent converts a usage event from an API object into an
// anonymizable event. All events that can be submitted externally via the Auth
// API need to be defined here.
Expand Down
Loading