diff --git a/internal/bsr/ssh/types.go b/internal/bsr/ssh/types.go new file mode 100644 index 000000000..c01f17410 --- /dev/null +++ b/internal/bsr/ssh/types.go @@ -0,0 +1,70 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package ssh + +import ( + "github.com/hashicorp/boundary/internal/bsr" +) + +// SessionProgram identifies the program running on this channel +// as outlined in https://www.rfc-editor.org/rfc/rfc4254.html#section-6.5 : +// +// Once the session has been set up, a program is started at the remote +// end. The program can be a shell, an application program, or a +// subsystem with a host-independent name. Only one of these requests +// can succeed per channel. +// +// SessionProgram is only valid when the channel type is 'session' +type SessionProgram string + +// SessionPrograms +const ( + NotApplicable SessionProgram = "not applicable" + Exec SessionProgram = "exec" + Shell SessionProgram = "shell" + Subsystem SessionProgram = "subsystem" +) + +// ValidChannelProgram checks if a given SessionProgram is valid. +func ValidChannelProgram(d SessionProgram) bool { + switch d { + case Exec, Shell, Subsystem, NotApplicable: + return true + } + return false +} + +// ExecApplicationProgram identifies what program was run with exec +// Currently, only Scp and Rsync are recognized to identify file transfers +type ExecApplicationProgram string + +// ExecApplicationPrograms +const ( + ExecApplicationProgramNotApplicable ExecApplicationProgram = "not applicable" + Unknown ExecApplicationProgram = "unknown" + Scp ExecApplicationProgram = "scp" + Rsync ExecApplicationProgram = "rsync" +) + +// ValidExecApplicationProgram checks if a given ExecApplicationProgram is valid. +func ValidExecApplicationProgram(d ExecApplicationProgram) bool { + switch d { + case Scp, Rsync, Unknown: + return true + } + return false +} + +// ChannelSummary encapsulates data for a channel +// SessionProgram can only be one of the following: exec, shell, or subsystem +// SubsystemName is only populated if SessionProgram is subsystem +// ExecApplicationProgram is only populated if Channel Program is subsystem, and can be one of the following: +// +// scp, rsync, or unknown +type ChannelSummary struct { + ChannelSummary *bsr.ChannelSummary + SessionProgram SessionProgram + SubsystemName string + ExecProgram ExecApplicationProgram +} diff --git a/internal/bsr/types.go b/internal/bsr/types.go new file mode 100644 index 000000000..d5c493fde --- /dev/null +++ b/internal/bsr/types.go @@ -0,0 +1,40 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package bsr + +import "time" + +type ( + // SessionSummary encapsulates data for a session, including its session id, connection count, + // and start/end time using a monotonic clock + SessionSummary struct { + Id string + ConnectionCount uint64 + StartTime time.Time + EndTime time.Time + } + + // ConnectionSummary encapsulates data for a connection, including its connection id, channel count, + // start/end time using a monotonic clock, and the aggregate bytes up/ down of its channels + ConnectionSummary struct { + Id string + ChannelCount uint64 + StartTime time.Time + EndTime time.Time + BytesUp uint64 + BytesDown uint64 + } + + // ChannelSummary encapsulates data for a channel, including its id, channel type, + // start/end time using a monotonic clock, and the bytes up/ down seen on this channel + ChannelSummary struct { + Id string + ConnectionRecordingId string + StartTime time.Time + EndTime time.Time + BytesUp uint64 + BytesDown uint64 + ChannelType string + } +)