-
Notifications
You must be signed in to change notification settings - Fork 2.1k
support session metadata generation for encrypted sessions #60838
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
56e1fbf
support session metadata generation for encrypted sessions
tigrato ec3706f
add unit tests for session completer
tigrato ba6cfb3
add unit tests for audit log session completer
tigrato e6987c9
move file decrypter to file
tigrato 8b65de2
handle code review comments
tigrato e7b0824
add todo list
tigrato 4f889cd
remove duplicate code
tigrato 7d85e74
fix typo
tigrato dc59b3f
rename
tigrato c6c03e6
Merge branch 'master' into tigrato/supportsummariesmetadataencrypted
tigrato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Teleport | ||
| // Copyright (C) 2025 Gravitational, Inc. | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU Affero General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU Affero General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU Affero General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| package recordingencryption | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "context" | ||
| "io" | ||
|
|
||
| "github.com/gravitational/trace" | ||
| ) | ||
|
|
||
| // ageEncryptionPrefix is the prefix used to identify age-encrypted data. | ||
| // age always uses "age-encryption.org/v1" as the prefix for its encrypted files. | ||
| const ageEncryptionPrefix = "age-encryption.org" | ||
|
|
||
| var ageEncryptionPrefixBytes = []byte(ageEncryptionPrefix) | ||
|
|
||
| // Decrypter wraps an io.Reader with decryption if the data is age-encrypted. | ||
| type Decrypter interface { | ||
| WithDecryption(ctx context.Context, reader io.Reader) (io.Reader, error) | ||
| } | ||
|
|
||
| // DecryptBufferIfEncrypted checks whether the provided buffer contains | ||
| // age-encrypted data and decrypts it if necessary. | ||
| // | ||
| // The function looks for the standard age encryption header prefix to determine | ||
| // whether the data is encrypted. If the buffer is not age-encrypted, it returns | ||
| // the original data unchanged. | ||
| // | ||
| // If the buffer is encrypted, a Decrypter must be provided. The function uses | ||
| // the Decrypter to read and decrypt the buffer, returning the plaintext bytes. | ||
| // If no Decrypter is configured when encrypted data is detected, an error is | ||
| // returned. | ||
| func DecryptBufferIfEncrypted(ctx context.Context, buf []byte, decrypter Decrypter) ([]byte, error) { | ||
| if !bytes.HasPrefix(buf, ageEncryptionPrefixBytes) { | ||
| return buf, nil | ||
| } | ||
|
|
||
| if decrypter == nil { | ||
| return nil, trace.BadParameter("recording metadata decrypter is not configured") | ||
| } | ||
|
|
||
| decryptedReader, err := decrypter.WithDecryption(ctx, bytes.NewReader(buf)) | ||
| if err != nil { | ||
| return nil, trace.Wrap(err, "decrypting recording metadata") | ||
| } | ||
|
|
||
| decryptedBuf := bytes.NewBuffer(make([]byte, 0, len(buf))) | ||
| _, err = io.Copy(decryptedBuf, decryptedReader) | ||
| if err != nil { | ||
| return nil, trace.Wrap(err, "reading decrypted recording metadata") | ||
| } | ||
|
|
||
| return decryptedBuf.Bytes(), nil | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.