Commit Graph
34 Commits
Author SHA1 Message Date
Tobiasz Heller 770e74a31a refactor: audit interface (#22070)
* refactor: shrinker interface for external audit loggers

* move StreamSessionEvents from ExternalAuditLogger

* fix comment of getLocalLog

* Rename IauditLog into AuditLoggerSessionStreamer
2023-03-06 10:44:16 +00:00
Edward Dowling e1856cd8cb Add incomplete session upload metric to the teleport namespace (#20351)
Also change name to match prometheus naming practices
2023-01-18 19:43:40 +00:00
Edward Dowling a4f972bbc4 Add metric for incomplete file uploads (#19724) 2023-01-16 16:58:54 +00:00
Zac Bergquist 166dc5a1be Clean up defaults (#18860)
- Make vars const where possible
- Move constants that are only used by the audit log into lib/events
- Remove unused vars
2022-11-30 15:50:29 +00:00
Jakub Nyckowski 0ee91f6c37 Enable GCI linter (#17894) 2022-10-28 20:20:28 +00:00
Zac Bergquist 7f1f8ec098 Remove upload completer grace period (#16809)
The 24-hour grace period was kept in Teleport 10 for backwards
compatibility, but is no longer necessary for Teleport 11 due
to the session tracker system.

As a result, it takes about an hour to complete an abandoned upload
instead of 24 hours.
2022-09-29 13:18:52 +00:00
Zac Bergquist aa136e7e8a Run a single uploader service per process (#14521)
Prior to this change, each individual service (proxy, app, SSH, db, etc)
would spin up its own uploader service. If you are running multiple
Teleport services in the same process, this means you get multiple
uploaders all looking at the same directory, which can result in
duplicate upload events in the audit log.

Additionally, desktop access has (mistakenly) failed to set up this
service, so desktop sessions would only be uploaded if you happened
to also run some other service in the same process that does spin up
the uploader.

Solve these issues by centralizing the uploader service so that it
runs once per process, and each Teleport service doesn't need to think
about whether or not the service should run.
2022-09-25 22:33:46 +00:00
Brian Joerger 4c0a6ff5b1 tsh PIV login integration (#15335)
* Add Yubikey PrivateKey implementation for use by Teleport clients.

  - Add yubikey login logic, reusing previously stored private keys.

  - Fix identity file decoding with PIV keys, which sign ecdsa certificates.

  - Add libpcsclite-dev pre-req for building on linux.

  - Remove unnecessary keys.Signer interface and move its functionality to keys.PrivateKey.

  - Move retry and jitter utils to new api/utils/retryutils package.
2022-09-23 19:44:10 +00:00
Zac Bergquist 903a816a65 Correctly set the end time when completing an upload (#16566)
The upload completer would set the session end time based on the last
known event in the session, but it left the timestamp in the event's
metadata blank, which caused it to default to the time the upload was
completed.

Fixes #16555
2022-09-23 13:33:40 +00:00
29e46a2a6a buddy: Fix incorrect use of loop variables (#16306)
* Fix incorrect use of loop variables

This commit fixes a few occurrences of loop variables being
incorrectly used in the context of Go-routines or (most frequently)
parallel tests. To fix the issues, we create a local copy of the range
variables before the parallel tests (or Go-routine), as suggested in
the documentation of the `testing` package:

https://pkg.go.dev/testing#hdr-Subtests_and_Sub_benchmarks

Issues were found using the `loopvarcapture` linter.

Signed-off-by: Roman Tkachenko <roman@goteleport.com>

* fix TestTraceProvider/spans_exported_with_gRPC+TLS

* run TestSSH serially

* operator: Conserve 'created_by' data in user spec

Signed-off-by: Roman Tkachenko <roman@goteleport.com>
Co-authored-by: Renato Costa <renato@cockroachlabs.com>
Co-authored-by: Tim Ross <tim.ross@goteleport.com>
Co-authored-by: Hugo Hervieux <hugo.hervieux@goteleport.com>
2022-09-14 14:31:56 +00:00
Zac Bergquist b1d4d608b2 auditlog: fix panic during concurrent streams of the same session (#15361)
The code attempts to wait on an existing download if one is already
in progress rather than starting a concurrent download of the same
session. If this code path runs, we incorrectly defer a call to a
nil function, triggering a panic.

This bug was introduced in #7360.
2022-08-12 14:47:54 +00:00
Tobiasz Heller 57d572dcc5 Fix missing cluster name on session.upload via Upload Completer (#15120) 2022-08-05 13:56:38 +02:00
Zac Bergquist ad512e449f Ensure the upload completer sets the time on session.upload events (#14535)
Fixes #11364
2022-07-17 15:06:27 +00:00
Noah Stride 02b4f8575f Configure linter to catch British 🇬🇧 spellings 🇺🇸 🦅 📖 (#14363)
* configure golangci-lint misspell to check for anglicized spellings

* Americanize spellings

* fix aws constant value with british spelling 🇬🇧

* update api types with americanized spellings

* use american spellings .cloudbuild/scripts
2022-07-14 10:51:23 +00:00
Brian Joerger 5ac508a16d Fix session tracker backwards compatibility. (#12795) 2022-05-25 22:48:36 +00:00
Brian Joerger b4eec0d3c5 Add Session tracker to DB, App, and Windows Desktop Sessions (#12304) 2022-05-12 17:03:32 +00:00
Brian Joerger dde7bb73b9 Re-add grace period to Upload completer for backwards compatibility. (#12471) 2022-05-09 22:24:01 +00:00
Brian Joerger 93f6f61386 Fix flaky test - TestAuditOn (#12101) 2022-04-21 01:20:26 +00:00
Brian Joerger 0d702e68aa Fix flaky test - TestChaosUpload (#12043) 2022-04-19 00:40:53 +00:00
Brian Joerger aba0b0cd93 Replace session upload grace period with session tracker (#11551)
* Replace Upload completer grace period logic with session tracker checking to accurately determine whether an upload has been abandoned

* Update session tracker expiration to be 1 hour, and dynamically extend it while the session is active.
2022-04-08 23:40:47 +00:00
rosstimothy d3de6c489d Spread out UploadCompleter load (#11590)
* Spread out UploadCompleter load

Replaces the use of a `Ticker` with an `Interval` to reduce the
chance of auth servers `UploadCompleter` from synchronizing `run`
loops. Without this auth servers are essentially racing against
each other to upload any unfinished uploads. This was causing
an increase in network utilization every 10 mins.

This also prevents any missing parts of an upload from prematurely
ending the unfinished upload process. Doing so only causes a back
log of uploads that will never be completed during any of the
subsequent calls to `CheckUploads` in the future.
2022-04-01 18:21:53 +00:00
Zac Bergquist 8ef9455fc7 Fix Windows session uploads
Ensure that the logic which checks for (and emits) a session.end
event also applies for windows.desktop.session.end events.

For this to work, we use the StreamSessionEvents API instead of
GetEvents. This is because the streaming API works for any stream
of audit events, and GetSessionEvents is specific to SSH and the
chunks index format used by SSH sessions.

Lastly, ensure that desktop related events are also captured in the
session recording stream (but omitted when streaming the events to
the browser during session playback). This allows us to use the
start event in order to reconstruct a missing end event.
2022-03-03 08:26:44 -07:00
Zac Bergquist 33622b1eb7 Complete empty uploads
The upload completer scans for uploads that need to be completed,
likely due to an error or process restart. Prior to this change,
it only completed uploads that had 1 or more parts. Since completing
an upload is what cleans up the directory on disk (or in the case of
cloud storage, finishes the multipart upload), it was possible
for us to leave behind empty directories (or multipart uploads)
for uploads with no parts.

This change makes it valid to complete uploads with no parts, which
ensures that these directories get cleaned up.

Also fix an issue with the GCS uploader, which failed to properly calculate
the upload ID from the path. This is because strings.Split(s, "/") returns an empty
string as the last element when s ends with a /.

Updates #9646
2022-03-03 08:26:44 -07:00
JoelandZac Bergquist 62173e096b use google/uuid instead of pborman/uuid (#9793)
* replace imports

* use google/uuid

* fix test

* reverse changelog changes

* update gomod

* zac steps

* tidy

Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
2022-01-19 23:44:48 +00:00
Joel 86c67d1b76 add IDs to upload events (#8453) 2021-10-07 12:45:31 +02:00
Brian Joerger 9b8b9d6d0c rollback - Upgrade api version. (#7751) 2021-07-30 15:34:19 -07:00
Brian Joerger c040aca4c1 Upgrade api version. (#7609) 2021-07-28 13:51:21 -07:00
Brian Joerger 4d36870ff0 Remove remaining API aliases (#7137) 2021-06-08 12:08:55 -07:00
Brian Joerger 7bff7c41bd Remove API aliases (#6983) 2021-06-04 13:29:31 -07:00
jane quin 6c67067c6e Emit session end event when completer finishes upload (#6756) 2021-05-11 12:58:12 -07:00
Jane Quintero 1ca978bc43 make only protostreamer implement getuploadmetadata 2021-02-19 17:29:11 -08:00
Jane Quintero 9b26bfe821 emit session upload event 2021-02-19 17:29:11 -08:00
Sasha Klizhentas c1b1c6a154 Improves logging and error handling in filesessions.
Adds chaos tests for async file upload.

Fixes playback for legacy sessions stored unpacked on disk
2020-10-06 13:41:17 -07:00
Sasha Klizhentas d160507430 Session streaming
This commit introduces GRPC API for streaming sessions.

It adds structured events and sync streaming
that avoids storing events on disk.

You can find design in rfd/0002-streaming.md RFD.
2020-09-28 23:08:56 -07:00