Commit Graph
15 Commits
Author SHA1 Message Date
Zac Bergquist 2519f40d8d Add anonymized device ID to tp.user.login event (#22994)
Updates gravitational/teleport.e#829
2023-03-14 16:06:15 +00:00
Edoardo Spadolini acdf61d931 usagereporter: Use the batched event ingest RPC (#22739)
* Sync prehog/v1alpha/teleport.proto

* Use the new SubmitEvents rpc

* Remove leftover file

* Warn against changing usageReporterMaxBatchSize
2023-03-14 08:58:03 +00:00
Vitor EnesandEdoardo Spadolini 6a1d1aedc3 Emit new AgentMetadataEvent (#22068)
* Emit new `AgentMetadataEvent`

Part of https://github.com/gravitational/cloud/issues/3550.

This commits adds a new `UpstreamInventoryAgentMetadata` that is sent
from a Teleport agent to an auth server.
Once received, it is transformed into an `AgentMetadataEvent` and sent
to PreHog.

Most `UpstreamInventoryAgentMetadata` fields are intentionally kept as
empty in this PR. Follow up PRs will be opened with the mechanisms
required to fill them (as described in #21337).

* server_id -> host_id

* compute OS and host architecture

* Compute OS version and container runtime

* Close stream if agent receives an agent metadata message

* cmd -> exec ; file -> read

* implement fetchOSVersion for linux

* Remove unused import

* Add note about `agentMetadataCh`

* Allow commands with args

* Remove parseFun abstraction

* fetch glibc version

* fetch container orchestrator

* Fix lint

* Fix TODO

* Add note about glibc version

* cmd -> command

* fetch cloud environment

* fetch install methods

* GLibCVersion -> GlibcVersion

* Use `http.NewRequestWithContext`

* Add missing comment

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* GLibCVersion -> GlibcVersion

* Fix lint

* Fix helm unit tests

* Add missing comments

* 5 second timeout on http requests

* Spawn gorountine that fetches metadata on each new stream

* Use `defaults.HTTPClient()`

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Add missing import

* Handle error

* Revert "Spawn gorountine that fetches metadata on each new stream"

This reverts commit fe4f2790be.

* Send agent metadata to auth server once per stream

* Improve note about agentMetadataDone

* Don't process command output & file content on the agent

Since agents cannot be trusted, regex validation and sanitization should
happen in PreHog anyways. So this commit removes such logic in favor of
moving it to PreHog.

* Fix lint

* Trim space

* Move handling of `AgentMetadataEvent` to `handleControlStream`

* Use cached hello message

* Move metadata files to lib/inventory/metadata

* make sending of agent metadata more self contained

* Minimize diff

* Send all system roles to PreHog

* Remove unused import

* Add parsing of command output / file content back

* Usage reporter refactor

* Usage reporter refactor

* Add missing handling of inventory agent metadata msg

* Fix ICS usage reporter

* Improve comments

* Add cached `metadata.Get*` methods

* Use systemctl status instead of is-active

* Add `Metadata` struct

* return pointer in `FetchMetadata`

* Pass context to `GetMetadata`

* metadataFetchConfig -> fetchConfig

* GetMetadata -> Get

* Add note about `Get` result

* Ensure install methods are non-nil

* Exit `metadata.Get` if context is closed

* Replace sync.Once with atomic.Bool.Swap

* Initialize channel

* Fix lint

* Fix lint

* Make `metadata.Get` return an error instead of bool

* Allow multiple true/false values for env vars

* Use `strings.Cut`

* Use /etc/os-release ID instead of NAME

* Improve `autoEmitMetadata`

* Use `gnu_get_libc_version`

* Ubuntu -> ubuntu

* Use GOARCH

* gofmt

* Move import C up

* Variables may include quotes

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Default values for ID and VERSION_ID

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Blank lines are permitted

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Anonymize host id

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-03-10 12:45:29 +00:00
Rafał Cieślak f43297f56a Connect: Remove leftovers from resource cache removal (#22772)
* Connect: Remove leftovers from resource cache removal

* GetAll* RPCs were used in the resource cache and are no longer used.
* ListApps was pretty much never actually used as we didn't ever list apps
  in Connect.
* ClusterContext.state.searchValue ceased to be used after we moved to
  fetching resources from the backend.

* Remove remaining leftovers from tshd client mock

* Remove unused imports
2023-03-10 10:05:18 +00:00
Noah StrideandEdoardo Spadolini 6eaea0300e Machine ID Agent Anonymous Analytics (#22174)
* Start fleshing out tbot anonymous analytics submission

* Support overriding telemetry endpoint

* Add debug message on success

* Refactor sendTelemetry to be compatible with unit testing

* Improve telemetry log message cppy

* Ensure exit occurs after telemetry submitted

* Improve mocking for tests

* Finish automated test

* Fix imports

* Switch to info level message when nto enabled

* Use preferred package import anme

* Use tbot specific telemetry endpoints

* Use start time instead of now in timestamp

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>

* Add missing license headers

* Add brief comment

* Correct staging domain

* Ensure anonymous telemetry sends

* Exit telemetry wait early if context is already cancelled

* Correct linter errors

* Fail faster on telemetry submission

---------

Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2023-03-06 10:24:07 +00:00
Rafał Cieślak 6578af1efd Connect: Remove resource cache (#21964)
* Connect: Remove resource cache

This commit refactors parts of the Electron app which still depend on
the resource cache, that is cluster sync and `tsh ssh` executed from the
command bar.

A number of adjustments has been made to executing `tsh ssh` from the
command bar, namely the logic of resolving the hostname has been moved
from the command launcher to useDocumentTerminal. The UI was also
adjusted to allow the user to reconnect to an SSH server if resolving
the hostname fails. This has a nice benefit of also allowing them to
retry if the PTY couldn't be created for some reason.

---

Before gravitational/webapps#1307, Connect was pulling all resources
from the cluster on app start and cluster login. Then it'd show them to
you in tables if you opened a new tab with cluster resources. There were
at least two problems with this approach:

1. It was slow for big clusters as pagination, filtering and sorting
   were all done client-side and blocked the main thread.
2. It wasn't possible to implement advanced search unless we copied the
   implementation from the backend to tshd.

gravitational/webapps#1307 made it so that instead of depending on that
resource cache to show resource tables, Connect would pull paginated
resources from the backend.

However, the resource tables were not the only part of the app depending
on that cache. Due to time constraints, we weren't able to refactor all
of them. We managed to refactor autocomplete (gravitational/webapps#1406)
and the remaining places are listed in #21800.

This PR refactors those remaining places to not use the cache by either
not depending on resource details or by making a call to the proxy
instead.

* Add missing license
2023-02-27 15:32:19 +00:00
Rafał Cieślak 0cdfa0b0ef Connect: Use SSH server UUID instead of hostname for file transfer (#21913)
* Add ResourceURI.GetServerUUID

* Use server UUID when calling TeleportClient.TransferFiles

* Mark removed FileTransferRequest fields as reserved
2023-02-17 10:24:12 +00:00
Edoardo Spadolini e3ce1f83c4 Emit usage events for port, kube.request, sftp (#21740)
* Update prehog/teleport.proto

* Add port as a tp.session.start with kind ssh_port

* Emit tp.kube.request events

* update prehog teleport.proto

* Emit tp.sftp usage event
2023-02-15 09:51:43 +00:00
Michelle Bergquist 8dfa07559b capture custom role creation in prehog (#21123)
* add e2e role creation events

* add role name

* reset proto

* cleartext default role names

* constant
2023-02-09 19:23:29 +00:00
Rafał Cieślak 9fa007ca5f Remove code related to restarting lib/teleterm gateways (#21457)
The Electron app no longer asks tshd to restart gateways. This was changed
in gravitational/webapps#1383.

This PR merely removes the tshd implementation of that RPC.
2023-02-09 08:21:12 +00:00
Grzegorz ZdunekandRafał Cieślak 7ed92c1c18 Connect: return logged in user in ListRootClusters (#20809)
* Add integration/teleterm_test with tests for get* and list* clusters

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>

* Move `testAddingRootCluster to integration/teleterm_test

* Add `ClusterWithDetails` type instead of enriching existing `Cluster` with optional properties

* Remove unnecessary condition

* Add license

* Bunch of renames

* Do more in mustLogin

* Remove watcher

---------

Co-authored-by: Rafał Cieślak <rafal.cieslak@goteleport.com>
2023-02-08 16:45:53 +00:00
Lisa Kim c7a11477ee [Web:Discover] Report events (#20581)
* Define event types

* Define event names for each flow

* Report events upon start, exiting, and next steps

* Update json property name change

* Emit user skipped event

* Emit error events

* Handle unloading event for 'completed' step

* Move updating event state into hook

* Finish emitting events for desktop

* Address CR: rename DiscoverDesktop to DiscoverResources

* Various changes:

- address CR: remove use of ref
- diagnostic traces can also be a success, only emit event on failed traces
- add mysql to discover events
- consistent naming on exit prompt

* Update and add new event names

* Update tests

* Emit events for unimplemented flows (apps and other dbs)

* Redo emitting events for test connection

Send event for EACH test connection failure or success.
If a user does not do any testing, send a skipped event.
2023-02-03 19:30:56 +00:00
Rafał Cieślak 3ac5a0aedb Refactor prehog & teleterm protos to match project conventions (#20810)
* Adjust go_package of lib/prehog Go protobufs

This makes them follow the pattern set out by api/proto and proto.

* Adjust go_package of lib/teleterm Go protobufs

* Use single buf.gen.yaml to generate JS protos

This also entailed changing the location of lib/teleterm protos and changing
the value of their package specifier to match the conventions in other parts
of the codebase. This is a breaking change but that is fine for Connect
as the protos are used locally only and each build ships with matching
protobufs.

* Make web/packages/teleterm use protobufs from gen-proto-js

We used to copy protobufs over to web/packages/teleterm/src/services/tshd
since webapps used to be in a separate repo.

This is no longer the case, so we can just make teleterm use protobufs
from gen-proto-js.

* Move prehog & teleterm protos into proto/teleport/lib

* Generate JS protos to gen/proto/js

* Move lib/teleterm Go protobufs to gen/proto/go

* Move lib/prehog Go protobufs to gen/proto/go

* Rename lib/teleterm proto package

* Re-enable linter rules for teleterm & prehog

* Update prehogv1 path in usagereporter_test.go

* Use except instead of ignore_only to allow Google API-style responses

* Add UNARY_RPC to api/proto & proto

* Ignore gen/ when running addlicense

* buf-js.gen.yaml: Remove comment about lack of go_package for JS

* Move prehog protos to proto/prehog/v1alpha

* Adjust prehog's go_package to match proto package
2023-02-03 14:47:06 +00:00
Alan Parra fbc135e672 Add comment and import cycle proto linters (#16082)
Require top-level proto types to have comments and introduce import cycle linter.
2022-09-02 13:31:45 +00:00
Alan Parra f447b99c63 Use Buf to build/lint/format lib/ protos (#15870)
Similarly to #15856, moves lib/ protos (except for Connect) under the proto/ tree.

The intended layout is a mirror of api:

```
teleport-root
  proto/         <- root for protos and proto imports
    teleport/
      lib/...
  gen/proto/go/  <- ideal root for generated protos
```

#15187

* Move lib/ protos under the proto/ tree
* Reformat protos
* Update generated protos
2022-08-29 17:44:18 +00:00