-
Notifications
You must be signed in to change notification settings - Fork 24
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
✨ tailscale provider #5214
✨ tailscale provider #5214
Conversation
This comment has been minimized.
This comment has been minimized.
461a0ab
to
891b7b2
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Use the tailscale provider to query devices, DNS namespaces, and more information about a Tailscale network known as `tailnet`. To authenticate using an API access token: ``` cnquery shell tailscale --token <access-token> ``` To authenticate using an OAuth client: ``` cnquery shell tailscale --client-id <id> --client-secret <secret> ``` You can also use the default environment variables `TAILSCALE_OAUTH_CLIENT_ID`, `TAILSCALE_OAUTH_CLIENT_SECRET`, and `TAILSCALE_TAILNET` to provide your credentials. If you are using an API access token instead of an OAuth client, use the `TAILSCALE_API_KEY` variable instead. Examples **List all devices in a tailnet** ```shell cnquery> tailscale.devices() ``` **Show a single device information** ```shell cnquery> tailscale.device(id: "55161288425123456") {*} tailscale.device: { id: "55161288425123456" isExternal: false os: "linux" created: 2021-06-25 12:34:34 -0700 PDT updateAvailable: true nodeKey: "nodekey:abc123" lastSeen: 2024-03-25 08:01:04 -0700 PDT user: "afiune@mondoo.com" hostname: "raspberrypi" clientVersion: "1.10.0-t766ae6c10-g3e6822772" authorized: true blocksIncomingConnections: false addresses: [ 0: "100.71.181.41" 1: "abc1:abc1:a1e0:ab12:abc1:cd96:abc1:bf33" ] keyExpiryDisabled: true expires: 2022-08-02 18:55:39 -0700 PDT name: "raspberrypi.tail1a4a6.ts.net" machineKey: "mkey:abc123" tailnetLockKey: "" tailnetLockError: "" } ``` Advanced Usage Discover all devices (any computer or mobile device) that joins the tailnet `example.com`. ```shell cnquery shell tailscale example.com --discover devices ``` Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
891b7b2
to
412dbb1
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@afiune Great first version for the tailscale provider! I added a few comments that we should address before we can merge it. Its close!
option provider = "go.mondoo.com/cnquery/v11/providers/tailscale" | ||
option go_package = "go.mondoo.com/cnquery/v11/providers/tailscale/resources" | ||
|
||
// The Tailscale provider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this represents the tailscale organization
conf := conn.Asset().Connections[0] | ||
assetList := []*inventory.Asset{} | ||
|
||
cf, err := getMqlTailscale(runtime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want also discover the root asset (org/tailnet).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can fetch this information.
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
1893fc9
to
6ee3021
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really good docs in this PR, as always, superstar! I made some suggestions. On some of them you'll find question marks where I wasn't 100% confident. 😁
// The time the user joined their tailnet | ||
createdAt time | ||
// This time can be either: | ||
// a) The last time any of the user's nodes were connected to the network |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// a) The last time any of the user's nodes were connected to the network | |
// a) The last time any of the user's nodes were connected to the network | |
// or |
} | ||
} | ||
|
||
func (s *Service) ParseCLI(req *plugin.ParseCLIReq) (*plugin.ParseCLIRes, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an empty token does not throw an error in the initial phase:
echo $TAILSCALE_API_KEY
cnquery shell tailscale --token $TAILSCALE_API_KEY --discover devices
→ tailscale> authentication configured method=token
→ connected to Tailscale
___ _ __ __ _ _ _ ___ _ __ _ _
/ __| '_ \ / _` | | | |/ _ \ '__| | | |
| (__| | | | (_| | |_| | __/ | | |_| |
\___|_| |_|\__, |\__,_|\___|_| \__, |
mondoo™ |_| |___/ interactive shell
cnquery> tailscale
tailscale: tailscale id = devices
cnquery> tailscale.devices
API token invalid (401)
tailscale.devices: no data available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will add a verify step to fail fast, just like we do with the GitHub provider, good call! 💯
Co-authored-by: Letha <letha@mondoo.com>
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Salim Afiune Maya <afiune@mondoo.com>
✨ Tailscale Provider
Use the tailscale provider to query devices, users, DNS namespaces, and more information about a Tailscale network,
known as a
tailnet
.To authenticate using an API access token:
To authenticate using an OAuth client:
You can also use the default environment variables
TAILSCALE_OAUTH_CLIENT_ID
,TAILSCALE_OAUTH_CLIENT_SECRET
,and
TAILSCALE_TAILNET
to provide your credentials.If you are using an API access token instead of an OAuth client, use the
TAILSCALE_API_KEY
variable instead.Examples
List all devices in a tailnet
Get information on a single device
List all users in a tailnet
Get information on a single user
Advanced usage
Discover all devices (any computer or mobile device) that join the tailnet
example.com