teleport/Makefile

1163 lines
37 KiB
Makefile
Raw Normal View History

# Make targets:
#
# all : builds all binaries in development mode, without web assets (default)
# full : builds all binaries for PRODUCTION use
# release: prepares a release tarball
# clean : removes all build artifacts
# test : runs tests
# To update the Teleport version, update VERSION variable:
# Naming convention:
# Stable releases: "1.0.0"
# Pre-releases: "1.0.0-alpha.1", "1.0.0-beta.2", "1.0.0-rc.3"
# Master/dev branch: "1.0.0-dev"
VERSION=12.0.0-dev
2016-06-14 23:52:32 +00:00
DOCKER_IMAGE ?= teleport
GOPATH ?= $(shell go env GOPATH)
# These are standard autotools variables, don't change them please
ifneq ("$(wildcard /bin/bash)","")
2021-08-23 17:53:51 +00:00
SHELL := /bin/bash -o pipefail
endif
2016-03-23 01:22:48 +00:00
BUILDDIR ?= build
2016-03-24 19:32:59 +00:00
BINDIR ?= /usr/local/bin
DATADIR ?= /usr/local/share/teleport
2016-03-22 19:15:17 +00:00
ADDFLAGS ?=
PWD ?= `pwd`
TELEPORT_DEBUG ?= false
GITTAG=v$(VERSION)
CGOFLAG ?= CGO_ENABLED=1
# When TELEPORT_DEBUG is true, set flags to produce
# debugger-friendly builds.
ifeq ("$(TELEPORT_DEBUG)","true")
BUILDFLAGS ?= $(ADDFLAGS) -gcflags=all="-N -l"
else
BUILDFLAGS ?= $(ADDFLAGS) -ldflags '-w -s' -trimpath
endif
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
FIPS ?=
RELEASE = teleport-$(GITTAG)-$(OS)-$(ARCH)-bin
# FIPS support must be requested at build time.
FIPS_MESSAGE := without-FIPS-support
ifneq ("$(FIPS)","")
FIPS_TAG := fips
FIPS_MESSAGE := "with-FIPS-support"
RELEASE = teleport-$(GITTAG)-$(OS)-$(ARCH)-fips-bin
endif
2018-09-27 01:21:45 +00:00
# PAM support will only be built into Teleport if headers exist at build time.
PAM_MESSAGE := without-PAM-support
2018-09-27 01:21:45 +00:00
ifneq ("$(wildcard /usr/include/security/pam_appl.h)","")
PAM_TAG := pam
PAM_MESSAGE := "with-PAM-support"
else
# PAM headers for Darwin live under /usr/local/include/security instead, as SIP
# prevents us from modifying/creating /usr/include/security on newer versions of MacOS
ifneq ("$(wildcard /usr/local/include/security/pam_appl.h)","")
PAM_TAG := pam
PAM_MESSAGE := "with-PAM-support"
endif
2018-09-27 01:21:45 +00:00
endif
# BPF support will only be built into Teleport if headers exist at build time.
BPF_MESSAGE := without-BPF-support
# We don't compile BPF for anything except regular non-FIPS linux/amd64 for now, as other builds
# have compilation issues that require fixing.
2021-04-09 23:20:56 +00:00
with_bpf := no
ifeq ("$(OS)","linux")
ifeq ("$(ARCH)","amd64")
2021-04-09 23:20:56 +00:00
ifneq ("$(wildcard /usr/include/bpf/libbpf.h)","")
with_bpf := yes
BPF_TAG := bpf
BPF_MESSAGE := "with-BPF-support"
2021-04-09 23:20:56 +00:00
CLANG ?= $(shell which clang || which clang-10)
CLANG_FORMAT ?= $(shell which clang-format || which clang-format-10)
LLVM_STRIP ?= $(shell which llvm-strip || which llvm-strip-10)
KERNEL_ARCH := $(shell uname -m | sed 's/x86_64/x86/')
INCLUDES :=
ER_BPF_BUILDDIR := lib/bpf/bytecode
RS_BPF_BUILDDIR := lib/restrictedsession/bytecode
2021-04-09 23:20:56 +00:00
# Get Clang's default includes on this system. We'll explicitly add these dirs
# to the includes list when compiling with `-target bpf` because otherwise some
# architecture-specific dirs will be "missing" on some architectures/distros -
# headers such as asm/types.h, asm/byteorder.h, asm/socket.h, asm/sockios.h,
# sys/cdefs.h etc. might be missing.
#
# Use '-idirafter': Don't interfere with include mechanics except where the
# build would have failed anyways.
CLANG_BPF_SYS_INCLUDES = $(shell $(CLANG) -v -E - </dev/null 2>&1 \
| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }')
STATIC_LIBS += -lbpf -lelf -lz
endif
endif
endif
# Check if rust and cargo are installed before compiling
CHECK_CARGO := $(shell cargo --version 2>/dev/null)
CHECK_RUST := $(shell rustc --version 2>/dev/null)
2022-10-06 08:36:23 +00:00
with_rdpclient := no
RDPCLIENT_MESSAGE := without-Windows-RDP-client
CARGO_TARGET_darwin_amd64 := x86_64-apple-darwin
CARGO_TARGET_darwin_arm64 := aarch64-apple-darwin
CARGO_TARGET_linux_arm64 := aarch64-unknown-linux-gnu
CARGO_TARGET_linux_amd64 := x86_64-unknown-linux-gnu
CARGO_TARGET := --target=${CARGO_TARGET_${OS}_${ARCH}}
ifneq ($(CHECK_RUST),)
ifneq ($(CHECK_CARGO),)
# Do not build RDP client on ARM or 386.
ifneq ("$(ARCH)","arm")
ifneq ("$(ARCH)","386")
with_rdpclient := yes
RDPCLIENT_MESSAGE := "with-Windows-RDP-client"
RDPCLIENT_TAG := desktop_access_rdp
endif
endif
endif
endif
2021-08-23 19:50:14 +00:00
# Enable libfido2 for testing?
# Eagerly enable if we detect the package, we want to test as much as possible.
ifeq ("$(shell pkg-config libfido2 2>/dev/null; echo $$?)", "0")
LIBFIDO2_TEST_TAG := libfido2
Run tests and lint libfido2 code on buildbox (#11547) - Lint libfido2 (and other) Go build tags - `make test-go` exercises the libfido2 build tag, as long as `libfido2` is present in the system - Install `libfido2` (and dependencies) in the teleport-buildbox image Libraries are installed from source, instead of apt or ppas, so we can guarantee deterministic (and current!) versions. (Binary releases are not available.) At the present moment, `librdp_client` and `libfido2` can't be used together. This is because `librdp_client` embeds openssl/`libcrypto`, which is also a dependency for `libfido2`, causing duplicate symbol errors. In practice both libraries never coexist in the same binary, so it's easy to sidestep the issue (`librdp_client` links to `teleport`, while FIDO2 code is only used by `tsh`). I may be able to make them coexist, but not without changes to how go-libfido2 builds. This change is only for linting/testing libfido2 code, I'll address `tsh` releases in a future PR. #9160 * Install libfido2 in buildbox libfido2 and libcbor are installed from source to make sure we get deterministic versions (apt is outdated and ppas are likely to move forward with time). * Run libfido2 tests on test-go * Lint libfido2 Go build tag * Lint other Go build tags * Comment build tags that break the linter * Tidy modules * Re-enable roletester linter * Pass tags conditionally to golangci-lint * Clarify and improve libfido2 wildcard * Drop `:$LD_LIBRARY_PATH` from variable * Replace LD_LIBRARY_PATH with `ldconfig` * Test for ARM homebrew location too
2022-03-30 17:52:29 +00:00
endif
# Build tsh against libfido2?
# FIDO2=yes and FIDO2=static enable static libfido2 builds.
# FIDO2=dynamic enables dynamic libfido2 builds.
LIBFIDO2_MESSAGE := without-libfido2
ifneq (, $(filter $(FIDO2), yes static))
LIBFIDO2_MESSAGE := with-libfido2
LIBFIDO2_BUILD_TAG := libfido2 libfido2static
else ifeq ("$(FIDO2)", "dynamic")
LIBFIDO2_MESSAGE := with-libfido2
LIBFIDO2_BUILD_TAG := libfido2
endif
Run tests and lint libfido2 code on buildbox (#11547) - Lint libfido2 (and other) Go build tags - `make test-go` exercises the libfido2 build tag, as long as `libfido2` is present in the system - Install `libfido2` (and dependencies) in the teleport-buildbox image Libraries are installed from source, instead of apt or ppas, so we can guarantee deterministic (and current!) versions. (Binary releases are not available.) At the present moment, `librdp_client` and `libfido2` can't be used together. This is because `librdp_client` embeds openssl/`libcrypto`, which is also a dependency for `libfido2`, causing duplicate symbol errors. In practice both libraries never coexist in the same binary, so it's easy to sidestep the issue (`librdp_client` links to `teleport`, while FIDO2 code is only used by `tsh`). I may be able to make them coexist, but not without changes to how go-libfido2 builds. This change is only for linting/testing libfido2 code, I'll address `tsh` releases in a future PR. #9160 * Install libfido2 in buildbox libfido2 and libcbor are installed from source to make sure we get deterministic versions (apt is outdated and ppas are likely to move forward with time). * Run libfido2 tests on test-go * Lint libfido2 Go build tag * Lint other Go build tags * Comment build tags that break the linter * Tidy modules * Re-enable roletester linter * Pass tags conditionally to golangci-lint * Clarify and improve libfido2 wildcard * Drop `:$LD_LIBRARY_PATH` from variable * Replace LD_LIBRARY_PATH with `ldconfig` * Test for ARM homebrew location too
2022-03-30 17:52:29 +00:00
# Enable Touch ID builds?
# Only build if TOUCHID=yes to avoid issues when cross-compiling to 'darwin'
# from other systems.
TOUCHID_MESSAGE := without-Touch-ID
ifeq ("$(TOUCHID)", "yes")
TOUCHID_MESSAGE := with-Touch-ID
TOUCHID_TAG := touchid
endif
# Enable PIV for testing?
# Eagerly enable if we detect the dynamic libpcsclite library, we want to test as much as possible.
ifeq ("$(shell pkg-config libpcsclite 2>/dev/null; echo $$?)", "0")
# This test tag should not be used for builds/releases, only tests.
PIV_TEST_TAG := piv
endif
# Build teleport/api with PIV? This requires the libpcsclite library for linux.
#
# PIV=yes and PIV=static enable static piv builds. This is used by the build
# process to link a static library of libpcsclite for piv-go to connect to.
#
# PIV=dynamic enables dynamic piv builds. This can be used for local
# builds and runs utilizing a dynamic libpcsclite library - `apt get install libpcsclite-dev`
PIV_MESSAGE := without-PIV-support
ifneq (, $(filter $(PIV), yes static dynamic))
PIV_MESSAGE := with-PIV-support
PIV_BUILD_TAG := piv
ifneq ("$(PIV)", "dynamic")
# Link static pcsc libary. By default, piv-go will look for the dynamic library.
# https://github.com/go-piv/piv-go/blob/master/piv/pcsc_unix.go#L23
STATIC_LIBS += -lpcsclite
STATIC_LIBS_TSH += -lpcsclite
endif
endif
# Reproducible builds are only available on select targets, and only when OS=linux.
2021-08-23 19:50:14 +00:00
REPRODUCIBLE ?=
ifneq ("$(OS)","linux")
REPRODUCIBLE = no
endif
# On Windows only build tsh. On all other platforms build teleport, tctl,
# and tsh.
Certificate renewal bot (#10099) * Add certificate renewal bot This adds a new `tbot` tool to continuously renew a set of certificates after registering with a Teleport cluster using a similar process to standard node joining. This makes some modifications to user certificate generation to allow for certificates that can be renewed beyond their original TTL, and exposes new gRPC endpoints: * `CreateBotJoinToken` creates a join token for a bot user * `GenerateInitialRenewableUserCerts` exchanges a token for a set of certificates with a new `renewable` flag set A new `tctl` command, `tctl bots add`, creates a bot user and calls `CreateBotJoinToken` to issue a token. A bot instance can then be started using a provided command. * Cert bot refactoring pass * Use role requests to split renewable certs from end-user certs * Add bot configuration file * Use `teleport.dev/bot` label * Remove `impersonator` flag on initial bot certs * Remove unnecessary `renew` package * Misc other cleanup * Do not pass through `renewable` flag when role requests are set This adds additional restrictions on when a certificate's `renewable` flag is carried over to a new certificate. In particular, it now also denies the flag when either role requests are present, or the `disallowReissue` flag has been previously set. In practice `disallow-reissue` would have prevented any undesired behavior but this improves consistency and resolves a TODO. * Various tbot UX improvements; render SSH config * Fully flesh out config template rendering * Fix rendering for SSH configuration templates * Added `String()` impls for destination types * Improve certificate renewal logging; show more detail * Properly fall back to default (all) roles * Add mode hints for files * Add/update copyright headers * Add stubs for tbot init and watch commands * Add gRPC endpoints for managing bots * Add `CreateBot`, `DeleteBot`, and `GetBotUsers` gRPC endpoints * Replace `tctl bot (add|rm|ls)` implementations with gRPC calls * Define a few new constants, `DefaultBotJoinTTL`, `BotLabel`, `BotGenerationLabel` * Fix outdated destination flag in example tbot command * Bugfix pass for demo * Fixed a few nil pointer derefs when using config from CLI args * Properly create destination if `--destination-dir` flag is used * Remove improper default on CLI flag * `DestinationConfig` is now a list of pointers * Address first wave of review feedback Fixes the majority of smaller issues caught by reviewers, thanks all! * Add doc comments for bot.go functions * Return the token TTL from CreateBot * Split initial user cert issuance from `generateUserCerts()` Issuing initial renewable certificate ended up requiring a lot of hacks to skip checks that prevented anonymous bots from getting certs even though we'd verified their identity elsewhere (via token). This reverts all those hacks and splits initial bot cert logic into a dedicated `generateInitialRenewableUserCerts()` function which should make the whole process much easier to follow. * Set bot traits to silence log messages * tbot log message consistency pass * Resolve lints * Add config tests * Remove CreateBotJoinToken endpoint Users should instead use the CreateBot/DeleteBot endpoints. * Create a fresh private key for every impersonated identity renewal * Hide `config` subcommand * Rename bot label prefix to `teleport.internal/` * Use types.NewRole() to create bot roles * Clean up error handling in custom YAML unmarshallers Also, add notes about the supported YAML shapes. * Fetch proxy host via gRPC Ping() instead of GetProxies() * Update lib/auth/bot.go Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * Fix some review comments * Add renewable certificate generation checks (#10098) * Add renewable certificate generation checks This adds a new validation check for renewable certificates that maintains a renewal counter as both a certificate extension and a user label. This counter is used to ensure only a single certificate lineage can exist: for example, if a renewable certificate is stolen, only one copy of the certificate can be renewed as the generation counter will not match When renewing a certificate, first the generation counter presented by the user (via their TLS identity) is compared to a value stored with the associated user (in a new `teleport.dev/bot-generation` label field). If they aren't equal, the renewal attempt fails. Otherwise, the generation counter is incremented by 1, stored to the database using a `CompareAndSwap()` to ensure atomicity, and set on the generated certificate for use in future renewals. * Add unit tests for the generation counter This adds new unit tests to exercise the generation counter checks. Additionally, it fixes two other renewable cert tests that were failing. * Remove certRequestGeneration() function * Emit audit event when cert generations don't match * Fully implement `tctl bots lock` * Show bot name in `tctl bots ls` * Lock bots when a cert generation mismatch is found * Make CompareFailed respones from validateGenerationLabel() more actionable * Update lib/services/local/users.go Co-authored-by: Nic Klaassen <nic@goteleport.com> * Backend changes for tbot IoT and AWS joining (#10360) * backend changes * add token permission check * pass ctx from caller Co-authored-by: Roman Tkachenko <roman@goteleport.com> * fix comment typo Co-authored-by: Roman Tkachenko <roman@goteleport.com> * use UserMetadata instead of Identity in RenewableCertificateGenerationMismatch event * Client changes for tbot IoT joining (#10397) * client changes * delete replaced APIs * delete unused tbot/auth.go * add license header * don't unecessarily fetch host CA * log fixes * s/tunnelling/tunneling/ Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * auth server addresses may be proxies Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * comment typo fix Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * move *Server methods out of auth_with_roles.go (#10416) Co-authored-by: Tim Buckley <tim@goteleport.com> Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> Co-authored-by: Tim Buckley <tim@goteleport.com> Co-authored-by: Roman Tkachenko <roman@goteleport.com> Co-authored-by: Tim Buckley <tim@goteleport.com> Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> Co-authored-by: Nic Klaassen <nic@goteleport.com> Co-authored-by: Roman Tkachenko <roman@goteleport.com> Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * Address another batch of review feedback * Addres another batch of review feedback Add `Role.SetMetadata()`, simplify more `trace.WrapWithMessage()` calls, clear some TODOs and lints, and address other misc feedback items. * Fix lint * Add missing doc comments to SaveIdentity / LoadIdentity * Remove pam tag from tbot build * Update note about bot lock deletion * Another pass of review feedback Ensure all requestable roles exist when creating a bot, adjust the default renewable cert TTL down to 1 hour, and check types during `CompareAndSwapUser()` Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> Co-authored-by: Nic Klaassen <nic@goteleport.com> Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-02-19 02:41:45 +00:00
BINARIES=$(BUILDDIR)/teleport $(BUILDDIR)/tctl $(BUILDDIR)/tsh $(BUILDDIR)/tbot
ifeq ("$(OS)","windows")
BINARIES=$(BUILDDIR)/tsh
endif
# Joins elements of the list in arg 2 with the given separator.
# 1. Element separator.
# 2. The list.
EMPTY :=
SPACE := $(EMPTY) $(EMPTY)
join-with = $(subst $(SPACE),$1,$(strip $2))
# Separate TAG messages into comma-separated WITH and WITHOUT lists for readability.
COMMA := ,
MESSAGES := $(PAM_MESSAGE) $(FIPS_MESSAGE) $(BPF_MESSAGE) $(RDPCLIENT_MESSAGE) $(LIBFIDO2_MESSAGE) $(TOUCHID_MESSAGE) $(PIV_MESSAGE)
WITH := $(subst -," ",$(call join-with,$(COMMA) ,$(subst with-,,$(filter with-%,$(MESSAGES)))))
WITHOUT := $(subst -," ",$(call join-with,$(COMMA) ,$(subst without-,,$(filter without-%,$(MESSAGES)))))
RELEASE_MESSAGE := "Building with GOOS=$(OS) GOARCH=$(ARCH) REPRODUCIBLE=$(REPRODUCIBLE) and with $(WITH) and without $(WITHOUT)."
2021-08-23 19:50:14 +00:00
# On platforms that support reproducible builds, ensure the archive is created in a reproducible manner.
TAR_FLAGS ?=
2021-08-23 19:50:14 +00:00
ifeq ("$(REPRODUCIBLE)","yes")
TAR_FLAGS = --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2015-03-02' --format=gnu
endif
2021-06-18 18:52:55 +00:00
VERSRC = version.go gitref.go api/version.go
2018-06-15 22:05:15 +00:00
KUBECONFIG ?=
TEST_KUBE ?=
export
TEST_LOG_DIR = ${abspath ./test-logs}
CLANG_FORMAT_STYLE = '{ColumnLimit: 100, IndentWidth: 4, Language: Proto}'
# Set CGOFLAG and BUILDFLAGS as needed for the OS/ARCH.
ifeq ("$(OS)","linux")
ifeq ("$(ARCH)","amd64")
# Link static version of libraries required by Teleport (bpf, pcsc) to reduce system dependencies. Avoid dependencies on dynamic libraries if we already link the static version using --as-needed.
CGOFLAG = CGO_ENABLED=1 CGO_LDFLAGS="-Wl,-Bstatic $(STATIC_LIBS) -Wl,-Bdynamic -Wl,--as-needed"
CGOFLAG_TSH = CGO_ENABLED=1 CGO_LDFLAGS="-Wl,-Bstatic $(STATIC_LIBS_TSH) -Wl,-Bdynamic -Wl,--as-needed"
else ifeq ("$(ARCH)","arm")
# ARM builds need to specify the correct C compiler
CGOFLAG = CGO_ENABLED=1 CC=arm-linux-gnueabihf-gcc
# Add -debugtramp=2 to work around 24 bit CALL/JMP instruction offset.
BUILDFLAGS = $(ADDFLAGS) -ldflags '-w -s -debugtramp=2' -trimpath
else ifeq ("$(ARCH)","arm64")
# ARM64 builds need to specify the correct C compiler
CGOFLAG = CGO_ENABLED=1 CC=aarch64-linux-gnu-gcc
endif
endif
# Windows requires extra parameters to cross-compile with CGO.
ifeq ("$(OS)","windows")
ARCH ?= amd64
ifneq ("$(ARCH)","amd64")
$(error "Building for windows requires ARCH=amd64")
endif
CGOFLAG = CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++
BUILDFLAGS = $(ADDFLAGS) -ldflags '-w -s' -trimpath -buildmode=exe
endif
CGOFLAG_TSH ?= $(CGOFLAG)
2016-01-17 18:28:34 +00:00
#
# 'make all' builds all 3 executables and places them in the current directory.
2018-02-24 01:23:09 +00:00
#
# IMPORTANT: the binaries will not contain the web UI assets and `teleport`
# won't start without setting the environment variable DEBUG=1
# This is the default build target for convenience of working on
# a web UI.
.PHONY: all
2021-06-18 18:52:55 +00:00
all: version
2018-09-27 01:21:45 +00:00
@echo "---> Building OSS binaries."
2018-03-27 17:43:27 +00:00
$(MAKE) $(BINARIES)
# By making these 3 targets below (tsh, tctl and teleport) PHONY we are solving
# several problems:
# * Build will rely on go build internal caching https://golang.org/doc/go1.10 at all times
# * Manual change detection was broken on a large dependency tree
# If you are considering changing this behavior, please consult with dev team first
.PHONY: $(BUILDDIR)/tctl
$(BUILDDIR)/tctl:
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(PAM_TAG) $(FIPS_TAG) $(PIV_BUILD_TAG)" -o $(BUILDDIR)/tctl $(BUILDFLAGS) ./tool/tctl
2018-03-27 17:43:27 +00:00
.PHONY: $(BUILDDIR)/teleport
$(BUILDDIR)/teleport: ensure-webassets bpf-bytecode rdpclient
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(WEBASSETS_TAG) $(RDPCLIENT_TAG) $(PIV_BUILD_TAG)" -o $(BUILDDIR)/teleport $(BUILDFLAGS) ./tool/teleport
2018-03-27 17:43:27 +00:00
# NOTE: Any changes to the `tsh` build here must be copied to `windows.go` in Dronegen until
# we can use this Makefile for native Windows builds.
.PHONY: $(BUILDDIR)/tsh
$(BUILDDIR)/tsh:
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG_TSH) go build -tags "$(FIPS_TAG) $(LIBFIDO2_BUILD_TAG) $(TOUCHID_TAG) $(PIV_BUILD_TAG)" -o $(BUILDDIR)/tsh $(BUILDFLAGS) ./tool/tsh
2016-03-22 19:15:17 +00:00
Certificate renewal bot (#10099) * Add certificate renewal bot This adds a new `tbot` tool to continuously renew a set of certificates after registering with a Teleport cluster using a similar process to standard node joining. This makes some modifications to user certificate generation to allow for certificates that can be renewed beyond their original TTL, and exposes new gRPC endpoints: * `CreateBotJoinToken` creates a join token for a bot user * `GenerateInitialRenewableUserCerts` exchanges a token for a set of certificates with a new `renewable` flag set A new `tctl` command, `tctl bots add`, creates a bot user and calls `CreateBotJoinToken` to issue a token. A bot instance can then be started using a provided command. * Cert bot refactoring pass * Use role requests to split renewable certs from end-user certs * Add bot configuration file * Use `teleport.dev/bot` label * Remove `impersonator` flag on initial bot certs * Remove unnecessary `renew` package * Misc other cleanup * Do not pass through `renewable` flag when role requests are set This adds additional restrictions on when a certificate's `renewable` flag is carried over to a new certificate. In particular, it now also denies the flag when either role requests are present, or the `disallowReissue` flag has been previously set. In practice `disallow-reissue` would have prevented any undesired behavior but this improves consistency and resolves a TODO. * Various tbot UX improvements; render SSH config * Fully flesh out config template rendering * Fix rendering for SSH configuration templates * Added `String()` impls for destination types * Improve certificate renewal logging; show more detail * Properly fall back to default (all) roles * Add mode hints for files * Add/update copyright headers * Add stubs for tbot init and watch commands * Add gRPC endpoints for managing bots * Add `CreateBot`, `DeleteBot`, and `GetBotUsers` gRPC endpoints * Replace `tctl bot (add|rm|ls)` implementations with gRPC calls * Define a few new constants, `DefaultBotJoinTTL`, `BotLabel`, `BotGenerationLabel` * Fix outdated destination flag in example tbot command * Bugfix pass for demo * Fixed a few nil pointer derefs when using config from CLI args * Properly create destination if `--destination-dir` flag is used * Remove improper default on CLI flag * `DestinationConfig` is now a list of pointers * Address first wave of review feedback Fixes the majority of smaller issues caught by reviewers, thanks all! * Add doc comments for bot.go functions * Return the token TTL from CreateBot * Split initial user cert issuance from `generateUserCerts()` Issuing initial renewable certificate ended up requiring a lot of hacks to skip checks that prevented anonymous bots from getting certs even though we'd verified their identity elsewhere (via token). This reverts all those hacks and splits initial bot cert logic into a dedicated `generateInitialRenewableUserCerts()` function which should make the whole process much easier to follow. * Set bot traits to silence log messages * tbot log message consistency pass * Resolve lints * Add config tests * Remove CreateBotJoinToken endpoint Users should instead use the CreateBot/DeleteBot endpoints. * Create a fresh private key for every impersonated identity renewal * Hide `config` subcommand * Rename bot label prefix to `teleport.internal/` * Use types.NewRole() to create bot roles * Clean up error handling in custom YAML unmarshallers Also, add notes about the supported YAML shapes. * Fetch proxy host via gRPC Ping() instead of GetProxies() * Update lib/auth/bot.go Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * Fix some review comments * Add renewable certificate generation checks (#10098) * Add renewable certificate generation checks This adds a new validation check for renewable certificates that maintains a renewal counter as both a certificate extension and a user label. This counter is used to ensure only a single certificate lineage can exist: for example, if a renewable certificate is stolen, only one copy of the certificate can be renewed as the generation counter will not match When renewing a certificate, first the generation counter presented by the user (via their TLS identity) is compared to a value stored with the associated user (in a new `teleport.dev/bot-generation` label field). If they aren't equal, the renewal attempt fails. Otherwise, the generation counter is incremented by 1, stored to the database using a `CompareAndSwap()` to ensure atomicity, and set on the generated certificate for use in future renewals. * Add unit tests for the generation counter This adds new unit tests to exercise the generation counter checks. Additionally, it fixes two other renewable cert tests that were failing. * Remove certRequestGeneration() function * Emit audit event when cert generations don't match * Fully implement `tctl bots lock` * Show bot name in `tctl bots ls` * Lock bots when a cert generation mismatch is found * Make CompareFailed respones from validateGenerationLabel() more actionable * Update lib/services/local/users.go Co-authored-by: Nic Klaassen <nic@goteleport.com> * Backend changes for tbot IoT and AWS joining (#10360) * backend changes * add token permission check * pass ctx from caller Co-authored-by: Roman Tkachenko <roman@goteleport.com> * fix comment typo Co-authored-by: Roman Tkachenko <roman@goteleport.com> * use UserMetadata instead of Identity in RenewableCertificateGenerationMismatch event * Client changes for tbot IoT joining (#10397) * client changes * delete replaced APIs * delete unused tbot/auth.go * add license header * don't unecessarily fetch host CA * log fixes * s/tunnelling/tunneling/ Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * auth server addresses may be proxies Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * comment typo fix Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * move *Server methods out of auth_with_roles.go (#10416) Co-authored-by: Tim Buckley <tim@goteleport.com> Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> Co-authored-by: Tim Buckley <tim@goteleport.com> Co-authored-by: Roman Tkachenko <roman@goteleport.com> Co-authored-by: Tim Buckley <tim@goteleport.com> Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> Co-authored-by: Nic Klaassen <nic@goteleport.com> Co-authored-by: Roman Tkachenko <roman@goteleport.com> Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> * Address another batch of review feedback * Addres another batch of review feedback Add `Role.SetMetadata()`, simplify more `trace.WrapWithMessage()` calls, clear some TODOs and lints, and address other misc feedback items. * Fix lint * Add missing doc comments to SaveIdentity / LoadIdentity * Remove pam tag from tbot build * Update note about bot lock deletion * Another pass of review feedback Ensure all requestable roles exist when creating a bot, adjust the default renewable cert TTL down to 1 hour, and check types during `CompareAndSwapUser()` Co-authored-by: Zac Bergquist <zmb3@users.noreply.github.com> Co-authored-by: Nic Klaassen <nic@goteleport.com> Co-authored-by: Roman Tkachenko <roman@goteleport.com>
2022-02-19 02:41:45 +00:00
.PHONY: $(BUILDDIR)/tbot
$(BUILDDIR)/tbot:
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -tags "$(FIPS_TAG)" -o $(BUILDDIR)/tbot $(BUILDFLAGS) ./tool/tbot
2021-04-09 23:20:56 +00:00
#
# BPF support (IF ENABLED)
# Requires a recent version of clang and libbpf installed.
#
ifeq ("$(with_bpf)","yes")
$(ER_BPF_BUILDDIR):
mkdir -p $(ER_BPF_BUILDDIR)
$(RS_BPF_BUILDDIR):
mkdir -p $(RS_BPF_BUILDDIR)
2021-04-09 23:20:56 +00:00
# Build BPF code
$(ER_BPF_BUILDDIR)/%.bpf.o: bpf/enhancedrecording/%.bpf.c $(wildcard bpf/*.h) | $(ER_BPF_BUILDDIR)
2021-04-09 23:20:56 +00:00
$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(KERNEL_ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
$(LLVM_STRIP) -g $@ # strip useless DWARF info
# Build BPF code
$(RS_BPF_BUILDDIR)/%.bpf.o: bpf/restrictedsession/%.bpf.c $(wildcard bpf/*.h) | $(RS_BPF_BUILDDIR)
$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(KERNEL_ARCH) $(INCLUDES) $(CLANG_BPF_SYS_INCLUDES) -c $(filter %.c,$^) -o $@
$(LLVM_STRIP) -g $@ # strip useless DWARF info
.PHONY: bpf-rs-bytecode
bpf-rs-bytecode: $(RS_BPF_BUILDDIR)/restricted.bpf.o
.PHONY: bpf-er-bytecode
bpf-er-bytecode: $(ER_BPF_BUILDDIR)/command.bpf.o $(ER_BPF_BUILDDIR)/disk.bpf.o $(ER_BPF_BUILDDIR)/network.bpf.o $(ER_BPF_BUILDDIR)/counter_test.bpf.o
2021-04-09 23:20:56 +00:00
.PHONY: bpf-bytecode
bpf-bytecode: bpf-er-bytecode bpf-rs-bytecode
2021-04-09 23:20:56 +00:00
# Generate vmlinux.h based on the installed kernel
.PHONY: update-vmlinux-h
update-vmlinux-h:
bpftool btf dump file /sys/kernel/btf/vmlinux format c >bpf/vmlinux.h
else
.PHONY: bpf-bytecode
bpf-bytecode:
endif
ifeq ("$(with_rdpclient)", "yes")
.PHONY: rdpclient
rdpclient:
ifneq ("$(FIPS)","")
cargo build -p rdp-client --features=fips --release $(CARGO_TARGET)
else
cargo build -p rdp-client --release $(CARGO_TARGET)
endif
else
.PHONY: rdpclient
rdpclient:
endif
2016-06-14 23:52:32 +00:00
#
# make full - Builds Teleport binaries with the built-in web assets and
# places them into $(BUILDDIR). On Windows, this target is skipped because
# only tsh is built.
#
.PHONY:full
2022-10-06 08:36:23 +00:00
full: ensure-webassets
ifneq ("$(OS)", "windows")
$(MAKE) all WEBASSETS_TAG="webassets_embed"
endif
2016-03-18 21:54:20 +00:00
#
# make full-ent - Builds Teleport enterprise binaries
#
.PHONY:full-ent
full-ent:
ifneq ("$(OS)", "windows")
2022-10-06 08:36:23 +00:00
@if [ -f e/Makefile ]; then $(MAKE) -C e full; fi
endif
#
# make clean - Removes all build artifacts.
#
2016-03-19 20:43:23 +00:00
.PHONY: clean
2016-01-17 22:50:00 +00:00
clean:
2018-09-27 01:21:45 +00:00
@echo "---> Cleaning up OSS build artifacts."
2016-03-19 20:43:23 +00:00
rm -rf $(BUILDDIR)
2022-07-18 17:06:58 +00:00
# Check if the variable is set to prevent calling remove on the root directory.
ifneq ($(ER_BPF_BUILDDIR),)
rm -f $(ER_BPF_BUILDDIR)/*.o
endif
ifneq ($(RS_BPF_BUILDDIR),)
rm -f $(RS_BPF_BUILDDIR)/*.o
endif
-cargo clean
-go clean -cache
2022-07-18 17:06:58 +00:00
rm -f *.gz
rm -f *.zip
2017-09-19 19:17:23 +00:00
rm -f gitref.go
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
rm -rf build.assets/tooling/bin
2016-01-17 22:50:00 +00:00
#
# make release - Produces a binary release tarball.
2018-02-24 01:23:09 +00:00
#
.PHONY:
export
release:
2018-09-27 01:21:45 +00:00
@echo "---> $(RELEASE_MESSAGE)"
ifeq ("$(OS)", "windows")
$(MAKE) --no-print-directory release-windows
else
$(MAKE) --no-print-directory release-unix
endif
# These are aliases used to make build commands uniform.
.PHONY: release-amd64
release-amd64:
$(MAKE) release ARCH=amd64
.PHONY: release-386
release-386:
$(MAKE) release ARCH=386
.PHONY: release-arm
release-arm:
$(MAKE) release ARCH=arm
.PHONY: release-arm64
release-arm64:
$(MAKE) release ARCH=arm64
#
# make build-archive - Packages the results of a build into a release tarball
#
.PHONY: build-archive
build-archive:
2018-09-27 01:21:45 +00:00
@echo "---> Creating OSS release archive."
mkdir teleport
cp -rf $(BUILDDIR)/* \
examples \
build.assets/install\
README.md \
CHANGELOG.md \
teleport/
echo $(GITTAG) > teleport/VERSION
tar $(TAR_FLAGS) -c teleport | gzip -n > $(RELEASE).tar.gz
rm -rf teleport
2018-09-27 01:21:45 +00:00
@echo "---> Created $(RELEASE).tar.gz."
#
# make release-unix - Produces a binary release tarball containing teleport,
# tctl, and tsh.
#
.PHONY:
release-unix: clean full build-archive
2022-10-06 08:36:23 +00:00
@if [ -f e/Makefile ]; then $(MAKE) -C e release; fi
#
Sign tsh.exe on tag builds (#7897) * Sign tsh.exe on tag builds This adds a Makefile step to sign tsh.exe when the `$WINDOWS_SIGNING_CERTIFICATE` env var is set to a base64-encoded pkcs12 code signing certificate. The certificate must not be password protected. This includes a sample cert (`cert-dummy.pfx`) for CI pipeline testing. It should be removed in any eventual PR, along with the other modifications to the drone pipeline. The cert is imported into the environment in the `Makefile` for testing purposes; in practice it will be imported from a secure secret store (drone secrets, etc). * Improve Windows code signing - Split signing into a separate step; `release-windows-unsigned` now performs the build, `release-windows` signs the binary. - Require `release-windows` to successfully generate a signed binary. - Clearly mark unsigned binaries and archives as such. - Guard against stdout secret leakage in Makefiles. - Move temporary cert data from Makefile into dronegen to test full pipeline. * Use an invalid cert string for testing purposes. * Pass certs to the build process via a statically named file Signed Windows builds now depend on a `.gitignore`'d `windows-signing-cert.pfx` at the root of the source directory. This should ease testing and help avoid accidental secret leakage. * Use production secret * Remove windows-signing-cert.pfx before continuing to the next step Additionally, fix variable reference as the bracket syntax does not seem to play nice with Drone. * Update .gitignore Co-authored-by: Andrew Lytvynov <andrew@goteleport.com> Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 22:34:57 +00:00
# make release-windows-unsigned - Produces a binary release archive containing only tsh.
#
Sign tsh.exe on tag builds (#7897) * Sign tsh.exe on tag builds This adds a Makefile step to sign tsh.exe when the `$WINDOWS_SIGNING_CERTIFICATE` env var is set to a base64-encoded pkcs12 code signing certificate. The certificate must not be password protected. This includes a sample cert (`cert-dummy.pfx`) for CI pipeline testing. It should be removed in any eventual PR, along with the other modifications to the drone pipeline. The cert is imported into the environment in the `Makefile` for testing purposes; in practice it will be imported from a secure secret store (drone secrets, etc). * Improve Windows code signing - Split signing into a separate step; `release-windows-unsigned` now performs the build, `release-windows` signs the binary. - Require `release-windows` to successfully generate a signed binary. - Clearly mark unsigned binaries and archives as such. - Guard against stdout secret leakage in Makefiles. - Move temporary cert data from Makefile into dronegen to test full pipeline. * Use an invalid cert string for testing purposes. * Pass certs to the build process via a statically named file Signed Windows builds now depend on a `.gitignore`'d `windows-signing-cert.pfx` at the root of the source directory. This should ease testing and help avoid accidental secret leakage. * Use production secret * Remove windows-signing-cert.pfx before continuing to the next step Additionally, fix variable reference as the bracket syntax does not seem to play nice with Drone. * Update .gitignore Co-authored-by: Andrew Lytvynov <andrew@goteleport.com> Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 22:34:57 +00:00
.PHONY: release-windows-unsigned
release-windows-unsigned: clean all
2018-09-27 01:21:45 +00:00
@echo "---> Creating OSS release archive."
mkdir teleport
cp -rf $(BUILDDIR)/* \
README.md \
CHANGELOG.md \
teleport/
Sign tsh.exe on tag builds (#7897) * Sign tsh.exe on tag builds This adds a Makefile step to sign tsh.exe when the `$WINDOWS_SIGNING_CERTIFICATE` env var is set to a base64-encoded pkcs12 code signing certificate. The certificate must not be password protected. This includes a sample cert (`cert-dummy.pfx`) for CI pipeline testing. It should be removed in any eventual PR, along with the other modifications to the drone pipeline. The cert is imported into the environment in the `Makefile` for testing purposes; in practice it will be imported from a secure secret store (drone secrets, etc). * Improve Windows code signing - Split signing into a separate step; `release-windows-unsigned` now performs the build, `release-windows` signs the binary. - Require `release-windows` to successfully generate a signed binary. - Clearly mark unsigned binaries and archives as such. - Guard against stdout secret leakage in Makefiles. - Move temporary cert data from Makefile into dronegen to test full pipeline. * Use an invalid cert string for testing purposes. * Pass certs to the build process via a statically named file Signed Windows builds now depend on a `.gitignore`'d `windows-signing-cert.pfx` at the root of the source directory. This should ease testing and help avoid accidental secret leakage. * Use production secret * Remove windows-signing-cert.pfx before continuing to the next step Additionally, fix variable reference as the bracket syntax does not seem to play nice with Drone. * Update .gitignore Co-authored-by: Andrew Lytvynov <andrew@goteleport.com> Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 22:34:57 +00:00
mv teleport/tsh teleport/tsh-unsigned.exe
echo $(GITTAG) > teleport/VERSION
Sign tsh.exe on tag builds (#7897) * Sign tsh.exe on tag builds This adds a Makefile step to sign tsh.exe when the `$WINDOWS_SIGNING_CERTIFICATE` env var is set to a base64-encoded pkcs12 code signing certificate. The certificate must not be password protected. This includes a sample cert (`cert-dummy.pfx`) for CI pipeline testing. It should be removed in any eventual PR, along with the other modifications to the drone pipeline. The cert is imported into the environment in the `Makefile` for testing purposes; in practice it will be imported from a secure secret store (drone secrets, etc). * Improve Windows code signing - Split signing into a separate step; `release-windows-unsigned` now performs the build, `release-windows` signs the binary. - Require `release-windows` to successfully generate a signed binary. - Clearly mark unsigned binaries and archives as such. - Guard against stdout secret leakage in Makefiles. - Move temporary cert data from Makefile into dronegen to test full pipeline. * Use an invalid cert string for testing purposes. * Pass certs to the build process via a statically named file Signed Windows builds now depend on a `.gitignore`'d `windows-signing-cert.pfx` at the root of the source directory. This should ease testing and help avoid accidental secret leakage. * Use production secret * Remove windows-signing-cert.pfx before continuing to the next step Additionally, fix variable reference as the bracket syntax does not seem to play nice with Drone. * Update .gitignore Co-authored-by: Andrew Lytvynov <andrew@goteleport.com> Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 22:34:57 +00:00
zip -9 -y -r -q $(RELEASE)-unsigned.zip teleport/
rm -rf teleport/
@echo "---> Created $(RELEASE)-unsigned.zip."
#
# make release-windows - Produces an archive containing a signed release of
# tsh.exe
#
.PHONY: release-windows
release-windows: release-windows-unsigned
@if [ ! -f "windows-signing-cert.pfx" ]; then \
echo "windows-signing-cert.pfx is missing or invalid, cannot create signed archive."; \
exit 1; \
fi
rm -rf teleport
@echo "---> Extracting $(RELEASE)-unsigned.zip"
unzip $(RELEASE)-unsigned.zip
Sign tsh.exe on tag builds (#7897) * Sign tsh.exe on tag builds This adds a Makefile step to sign tsh.exe when the `$WINDOWS_SIGNING_CERTIFICATE` env var is set to a base64-encoded pkcs12 code signing certificate. The certificate must not be password protected. This includes a sample cert (`cert-dummy.pfx`) for CI pipeline testing. It should be removed in any eventual PR, along with the other modifications to the drone pipeline. The cert is imported into the environment in the `Makefile` for testing purposes; in practice it will be imported from a secure secret store (drone secrets, etc). * Improve Windows code signing - Split signing into a separate step; `release-windows-unsigned` now performs the build, `release-windows` signs the binary. - Require `release-windows` to successfully generate a signed binary. - Clearly mark unsigned binaries and archives as such. - Guard against stdout secret leakage in Makefiles. - Move temporary cert data from Makefile into dronegen to test full pipeline. * Use an invalid cert string for testing purposes. * Pass certs to the build process via a statically named file Signed Windows builds now depend on a `.gitignore`'d `windows-signing-cert.pfx` at the root of the source directory. This should ease testing and help avoid accidental secret leakage. * Use production secret * Remove windows-signing-cert.pfx before continuing to the next step Additionally, fix variable reference as the bracket syntax does not seem to play nice with Drone. * Update .gitignore Co-authored-by: Andrew Lytvynov <andrew@goteleport.com> Co-authored-by: Andrew Lytvynov <andrew@goteleport.com>
2021-09-02 22:34:57 +00:00
@echo "---> Signing Windows binary."
@osslsigncode sign \
-pkcs12 "windows-signing-cert.pfx" \
-n "Teleport" \
-i https://goteleport.com \
-t http://timestamp.digicert.com \
-h sha2 \
-in teleport/tsh-unsigned.exe \
-out teleport/tsh.exe; \
success=$$?; \
rm -f teleport/tsh-unsigned.exe; \
if [ "$${success}" -ne 0 ]; then \
echo "Failed to sign tsh.exe, aborting."; \
exit 1; \
fi
zip -9 -y -r -q $(RELEASE).zip teleport/
rm -rf teleport/
2018-09-27 01:21:45 +00:00
@echo "---> Created $(RELEASE).zip."
Teleport 4.3 Docs (#3423) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Remove trailing whitespace from docs files Some editors will do this automatically on save. This causes a lot of diffs when editing the docs in such an editor. Clean them up once now and we'll try to keep it tidy going forward. * Add make rules for docs whitespace and milv docs-test-whitespace: checks for trailing whitespace in all .md files under docs/. docs-fix-whitespace: removes trailing whitespace in all .md files under docs/. docs-test-links: runs milv in all docs/ subdirectories that have milv.config.yaml. docs-test: runs whitespace and links tests, used during `make docs` * Document the new `--use-local-ssh-agent` flag for tsh The flag is used to bypass the local SSH agent even when it's running. Specifically, this helps with agents that don't support certs. The flag was added in #3721 * Remove pam_script.so docs from SSH PAM page With #3725 we now populate teleport-specific env vars in a way that's accessible to `pam_exec.so`. There's no longer any reason to install pam_script.so separately and duplicate our docs. Updates #3692 * Using the correct --insecure-no-tls flag * Run docs-fix-whitespace make rule in a busybox container * Fixes #3414 Co-authored-by: Andrew Lytvynov <andrew@gravitational.com> Co-authored-by: Gus Luxton <gus@gravitational.com> Co-authored-by: Steven Martin <steven@gravitational.com> Co-authored-by: Gus Luxton <webvictim@gmail.com>
2020-06-18 00:09:41 +00:00
#
# Remove trailing whitespace in all markdown files under docs/.
#
# Note: this runs in a busybox container to avoid incompatibilities between
# linux and macos CLI tools.
#
.PHONY:docs-fix-whitespace
docs-fix-whitespace:
docker run --rm -v $(PWD):/teleport busybox \
find /teleport/docs/ -type f -name '*.md' -exec sed -E -i 's/\s+$$//g' '{}' \;
#
# Test docs for trailing whitespace and broken links
#
.PHONY:docs-test
2021-03-10 18:01:48 +00:00
docs-test: docs-test-whitespace
Teleport 4.3 Docs (#3423) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Base fork for 4.3 docs * [docs] external email identities and Kube Users (#3628) * Remove trailing whitespace from docs files Some editors will do this automatically on save. This causes a lot of diffs when editing the docs in such an editor. Clean them up once now and we'll try to keep it tidy going forward. * Add make rules for docs whitespace and milv docs-test-whitespace: checks for trailing whitespace in all .md files under docs/. docs-fix-whitespace: removes trailing whitespace in all .md files under docs/. docs-test-links: runs milv in all docs/ subdirectories that have milv.config.yaml. docs-test: runs whitespace and links tests, used during `make docs` * Document the new `--use-local-ssh-agent` flag for tsh The flag is used to bypass the local SSH agent even when it's running. Specifically, this helps with agents that don't support certs. The flag was added in #3721 * Remove pam_script.so docs from SSH PAM page With #3725 we now populate teleport-specific env vars in a way that's accessible to `pam_exec.so`. There's no longer any reason to install pam_script.so separately and duplicate our docs. Updates #3692 * Using the correct --insecure-no-tls flag * Run docs-fix-whitespace make rule in a busybox container * Fixes #3414 Co-authored-by: Andrew Lytvynov <andrew@gravitational.com> Co-authored-by: Gus Luxton <gus@gravitational.com> Co-authored-by: Steven Martin <steven@gravitational.com> Co-authored-by: Gus Luxton <webvictim@gmail.com>
2020-06-18 00:09:41 +00:00
#
# Check for trailing whitespace in all markdown files under docs/
#
.PHONY:docs-test-whitespace
docs-test-whitespace:
if find docs/ -type f -name '*.md' | xargs grep -E '\s+$$'; then \
echo "trailing whitespace found in docs/ (see above)"; \
echo "run 'make docs-fix-whitespace' to fix it"; \
exit 1; \
fi
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
#
# Builds some tooling for filtering and displaying test progress/output/etc
#
TOOLINGDIR := ${abspath ./build.assets/tooling}
RENDER_TESTS := $(TOOLINGDIR)/bin/render-tests
$(RENDER_TESTS): $(wildcard $(TOOLINGDIR)/cmd/render-tests/*.go)
cd $(TOOLINGDIR) && go build -o "$@" ./cmd/render-tests
2016-02-16 21:18:58 +00:00
#
# Runs all Go/shell tests, called by CI/CD.
#
.PHONY: test
test: test-helm test-sh test-ci test-api test-go test-rust test-operator
$(TEST_LOG_DIR):
mkdir $(TEST_LOG_DIR)
.PHONY: helmunit/installed
helmunit/installed:
@if ! helm unittest -h >/dev/null; then \
echo 'Helm unittest plugin is required to test Helm charts. Run `helm plugin install https://github.com/quintush/helm-unittest` to install it'; \
exit 1; \
fi
# The CI environment is responsible for setting HELM_PLUGINS to a directory where
# quintish/helm-unittest is installed.
#
# The unittest plugin changed in teleport12, if the tests are failing, please ensure
# you are using https://github.com/quintush/helm-unittest and not the vbehar fork.
2022-03-20 19:01:58 +00:00
.PHONY: test-helm
test-helm: helmunit/installed
helm unittest -3 examples/chart/teleport-cluster
helm unittest -3 examples/chart/teleport-kube-agent
2022-03-20 19:01:58 +00:00
.PHONY: test-helm-update-snapshots
test-helm-update-snapshots: helmunit/installed
helm unittest -3 -u examples/chart/teleport-cluster
helm unittest -3 -u examples/chart/teleport-kube-agent
2022-03-20 19:01:58 +00:00
#
# Runs all Go tests except integration, called by CI/CD.
# Chaos tests have high concurrency, run without race detector and have TestChaos prefix.
2016-02-16 21:18:58 +00:00
#
.PHONY: test-go
test-go: ensure-webassets bpf-bytecode rdpclient $(TEST_LOG_DIR) $(RENDER_TESTS)
test-go: FLAGS ?= -race -shuffle on
test-go: PACKAGES = $(shell go list ./... | grep -v -e integration -e tool/tsh -e operator )
test-go: CHAOS_FOLDERS = $(shell find . -type f -name '*chaos*.go' | xargs dirname | uniq)
test-go: $(VERSRC) $(TEST_LOG_DIR)
$(CGOFLAG) go test -cover -json -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(RDPCLIENT_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS) \
| tee $(TEST_LOG_DIR)/unit.json \
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
| ${RENDER_TESTS}
Run tests and lint libfido2 code on buildbox (#11547) - Lint libfido2 (and other) Go build tags - `make test-go` exercises the libfido2 build tag, as long as `libfido2` is present in the system - Install `libfido2` (and dependencies) in the teleport-buildbox image Libraries are installed from source, instead of apt or ppas, so we can guarantee deterministic (and current!) versions. (Binary releases are not available.) At the present moment, `librdp_client` and `libfido2` can't be used together. This is because `librdp_client` embeds openssl/`libcrypto`, which is also a dependency for `libfido2`, causing duplicate symbol errors. In practice both libraries never coexist in the same binary, so it's easy to sidestep the issue (`librdp_client` links to `teleport`, while FIDO2 code is only used by `tsh`). I may be able to make them coexist, but not without changes to how go-libfido2 builds. This change is only for linting/testing libfido2 code, I'll address `tsh` releases in a future PR. #9160 * Install libfido2 in buildbox libfido2 and libcbor are installed from source to make sure we get deterministic versions (apt is outdated and ppas are likely to move forward with time). * Run libfido2 tests on test-go * Lint libfido2 Go build tag * Lint other Go build tags * Comment build tags that break the linter * Tidy modules * Re-enable roletester linter * Pass tags conditionally to golangci-lint * Clarify and improve libfido2 wildcard * Drop `:$LD_LIBRARY_PATH` from variable * Replace LD_LIBRARY_PATH with `ldconfig` * Test for ARM homebrew location too
2022-03-30 17:52:29 +00:00
# rdpclient and libfido2 don't play well together, so we run libfido2 tests
# separately.
# TODO(codingllama): Run libfido2 tests along with others once RDP doesn't
# embed openssl/libcrypto.
ifneq ("$(LIBFIDO2_TEST_TAG)", "")
$(CGOFLAG) go test -cover -json -tags "$(LIBFIDO2_TEST_TAG)" ./lib/auth/webauthncli/... $(FLAGS) $(ADDFLAGS) \
Run tests and lint libfido2 code on buildbox (#11547) - Lint libfido2 (and other) Go build tags - `make test-go` exercises the libfido2 build tag, as long as `libfido2` is present in the system - Install `libfido2` (and dependencies) in the teleport-buildbox image Libraries are installed from source, instead of apt or ppas, so we can guarantee deterministic (and current!) versions. (Binary releases are not available.) At the present moment, `librdp_client` and `libfido2` can't be used together. This is because `librdp_client` embeds openssl/`libcrypto`, which is also a dependency for `libfido2`, causing duplicate symbol errors. In practice both libraries never coexist in the same binary, so it's easy to sidestep the issue (`librdp_client` links to `teleport`, while FIDO2 code is only used by `tsh`). I may be able to make them coexist, but not without changes to how go-libfido2 builds. This change is only for linting/testing libfido2 code, I'll address `tsh` releases in a future PR. #9160 * Install libfido2 in buildbox libfido2 and libcbor are installed from source to make sure we get deterministic versions (apt is outdated and ppas are likely to move forward with time). * Run libfido2 tests on test-go * Lint libfido2 Go build tag * Lint other Go build tags * Comment build tags that break the linter * Tidy modules * Re-enable roletester linter * Pass tags conditionally to golangci-lint * Clarify and improve libfido2 wildcard * Drop `:$LD_LIBRARY_PATH` from variable * Replace LD_LIBRARY_PATH with `ldconfig` * Test for ARM homebrew location too
2022-03-30 17:52:29 +00:00
| tee $(TEST_LOG_DIR)/unit.json \
| ${RENDER_TESTS}
endif
# Make sure untagged touchid code build/tests.
ifneq ("$(TOUCHID_TAG)", "")
$(CGOFLAG) go test -cover -json ./lib/auth/touchid/... $(FLAGS) $(ADDFLAGS) \
| tee $(TEST_LOG_DIR)/unit.json \
| ${RENDER_TESTS}
endif
$(CGOFLAG_TSH) go test -cover -json -tags "$(PAM_TAG) $(FIPS_TAG) $(LIBFIDO2_TEST_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG)" github.com/gravitational/teleport/tool/tsh $(FLAGS) $(ADDFLAGS) \
| tee $(TEST_LOG_DIR)/unit.json \
| ${RENDER_TESTS}
$(CGOFLAG) go test -cover -json -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(RDPCLIENT_TAG)" -test.run=TestChaos $(CHAOS_FOLDERS) \
| tee $(TEST_LOG_DIR)/chaos.json \
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
| ${RENDER_TESTS}
2021-04-09 23:20:56 +00:00
.PHONY: test-ci
test-ci: $(TEST_LOG_DIR) $(RENDER_TESTS)
(cd .cloudbuild/scripts && \
go test -cover -json ./... \
| tee $(TEST_LOG_DIR)/ci.json \
| ${RENDER_TESTS})
2021-04-09 23:20:56 +00:00
#
# Runs all Go tests except integration and chaos, called by CI/CD.
#
UNIT_ROOT_REGEX := ^TestRoot
.PHONY: test-go-root
test-go-root: ensure-webassets bpf-bytecode rdpclient $(TEST_LOG_DIR) $(RENDER_TESTS)
test-go-root: FLAGS ?= -race -shuffle on
test-go-root: PACKAGES = $(shell go list $(ADDFLAGS) ./... | grep -v -e integration -e operator)
2021-04-09 23:20:56 +00:00
test-go-root: $(VERSRC)
$(CGOFLAG) go test -json -run "$(UNIT_ROOT_REGEX)" -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(RDPCLIENT_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS) \
| tee $(TEST_LOG_DIR)/unit-root.json \
| ${RENDER_TESTS}
#
# Runs Go tests on the api module. These have to be run separately as the package name is different.
#
.PHONY: test-api
test-api:
test-api: FLAGS ?= -race -shuffle on
test-api: PACKAGES = $(shell cd api && go list ./...)
test-api: $(VERSRC) $(TEST_LOG_DIR) $(RENDER_TESTS)
$(CGOFLAG) go test -json -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG)" $(PACKAGES) $(FLAGS) $(ADDFLAGS) \
| tee $(TEST_LOG_DIR)/api.json \
| ${RENDER_TESTS}
#
# Runs Teleport Operator tests.
# We have to run them using the makefile to ensure the installation of the k8s test tools (envtest)
#
.PHONY: test-operator
test-operator:
make -C operator test
#
# Runs cargo test on our Rust modules.
# (a no-op if cargo and rustc are not installed)
#
ifneq ($(CHECK_RUST),)
ifneq ($(CHECK_CARGO),)
.PHONY: test-rust
test-rust:
cargo test
else
.PHONY: test-rust
test-rust:
endif
endif
# Find and run all shell script unit tests (using https://github.com/bats-core/bats-core)
.PHONY: test-sh
test-sh:
@if ! type bats 2>&1 >/dev/null; then \
echo "Not running 'test-sh' target as 'bats' is not installed."; \
if [ "$${DRONE}" = "true" ]; then echo "This is a failure when running in CI." && exit 1; fi; \
exit 0; \
fi; \
find . -iname "*.bats" -exec dirname {} \; | uniq | xargs -t -L1 bats $(BATSFLAGS)
.PHONY: run-etcd
run-etcd:
examples/etcd/start-etcd.sh
#
# Integration tests. Need a TTY to work.
2021-02-15 19:43:39 +00:00
# Any tests which need to run as root must be skipped during regular integration testing.
#
.PHONY: integration
integration: FLAGS ?= -v -race
integration: PACKAGES = $(shell go list ./... | grep integration)
integration: $(TEST_LOG_DIR) $(RENDER_TESTS)
2018-06-15 22:05:15 +00:00
@echo KUBECONFIG is: $(KUBECONFIG), TEST_KUBE: $(TEST_KUBE)
$(CGOFLAG) go test -timeout 30m -json -tags "$(PAM_TAG) $(FIPS_TAG) $(BPF_TAG) $(RDPCLIENT_TAG)" $(PACKAGES) $(FLAGS) \
| tee $(TEST_LOG_DIR)/integration.json \
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
| $(RENDER_TESTS) -report-by test
2021-02-15 19:43:39 +00:00
#
# Integration tests which need to be run as root in order to complete successfully
# are run separately to all other integration tests. Need a TTY to work.
#
INTEGRATION_ROOT_REGEX := ^TestRoot
.PHONY: integration-root
integration-root: FLAGS ?= -v -race
integration-root: PACKAGES = $(shell go list ./... | grep integration)
integration-root: $(TEST_LOG_DIR) $(RENDER_TESTS)
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
$(CGOFLAG) go test -json -run "$(INTEGRATION_ROOT_REGEX)" $(PACKAGES) $(FLAGS) \
| tee $(TEST_LOG_DIR)/integration-root.json \
Attempts to make CI integration test logs more useful (#9626) Actually tracking down the cause of a failure in the integration tests can be hard: * It's hard to get an overall summary of what failed * The tests sometimes emit no output before timing out, meaning any diagnostic info is lost * The emitted logs are too voluminous for a human to parse * The emitted logs can present information out of order * It's often hard to tell where the output from one test ends and the next one begins This patch attempts to address these concerns without attempting to rewrite any of the underlying teleport logging. * It improves the render-tests script to (optionally) report progress per- test, rather than on a per-package basis. My working hypothesis on the tests that time out with no output is that go test ./integration is waiting for the entire set of integration tests tests to be complete before reporting success or failure. Reporting on a per-test cycle gives faster feedback and means that any timed-out builds should give at least some idea of where they are stuck. * Adds the render-tests filter to the integration and integration-root make targets. This will show an overall summary of test results, as well as - Discarding log output from passing tests to increase signal-to-noise ratio, and - Strongly delimiting the output from each failed test, making failures easier to find. * Removes the notion of a failure-only logger in favour of post-processing the log events with render-tests. The failure-only logger catches log output from the tests and only forwards it to the console if the test fails. Unfortunately, not all log output is guaranteed to pass through this logger (some teleport packages do not honour the configured logger, and reports from the go race detector certainly don't), meaning some output is presented at the time it happens, and other output is batched and displayed at the end of the test. This makes working out what happened where harder than it need be. In addition, this patch also promotes the render-tests script into a fully- fledged program, with appropriate makefile targets, make clean support, etc. It is now also more robust in the face on non-JSON output from go test (which happens if a package fails to compile).
2022-01-04 23:42:07 +00:00
| $(RENDER_TESTS) -report-by test
2021-02-15 19:43:39 +00:00
#
# Lint the source code.
# By default lint scans the entire repo. Pass GO_LINT_FLAGS='--new' to only scan local
# changes (or last commit).
#
.PHONY: lint
lint: lint-sh lint-helm lint-api lint-go lint-license lint-rust lint-tools lint-protos
.PHONY: lint-tools
lint-tools: lint-build-tooling lint-ci-scripts lint-backport
#
# Runs the clippy linter on our rust modules
# (a no-op if cargo and rustc are not installed)
#
ifneq ($(CHECK_RUST),)
ifneq ($(CHECK_CARGO),)
.PHONY: lint-rust
lint-rust:
cargo clippy --locked --all-targets -- -D warnings \
&& cargo fmt -- --check
else
.PHONY: lint-rust
lint-rust:
endif
endif
.PHONY: lint-go
lint-go: GO_LINT_FLAGS ?=
lint-go:
golangci-lint run -c .golangci.yml --build-tags='$(LIBFIDO2_TEST_TAG) $(TOUCHID_TAG) $(PIV_TEST_TAG)' $(GO_LINT_FLAGS)
2022-10-28 20:20:28 +00:00
.PHONY: fix-imports
fix-imports:
make -C build.assets/ fix-imports
.PHONY: fix-imports/host
fix-imports/host:
@if ! type gci >/dev/null 2>&1; then\
echo 'gci is not installed or is missing from PATH, consider installing it ("go install github.com/daixiang0/gci@latest") or use "make -C build.assets/ fix-imports"';\
exit 1;\
fi
gci write -s 'standard,default,prefix(github.com/gravitational/teleport)' --skip-generated .
2022-10-28 20:20:28 +00:00
.PHONY: lint-build-tooling
lint-build-tooling: GO_LINT_FLAGS ?=
lint-build-tooling:
cd build.assets/tooling && golangci-lint run -c ../../.golangci.yml $(GO_LINT_FLAGS)
.PHONY: lint-backport
lint-backport: GO_LINT_FLAGS ?=
lint-backport:
cd assets/backport && golangci-lint run -c ../../.golangci.yml $(GO_LINT_FLAGS)
.PHONY: lint-ci-scripts
lint-ci-scripts: GO_LINT_FLAGS ?=
lint-ci-scripts:
cd .cloudbuild/scripts/ && golangci-lint run -c ../../.golangci.yml $(GO_LINT_FLAGS)
# api is no longer part of the teleport package, so golangci-lint skips it by default
.PHONY: lint-api
lint-api: GO_LINT_API_FLAGS ?=
lint-api:
cd api && golangci-lint run -c ../.golangci.yml $(GO_LINT_API_FLAGS)
# TODO(awly): remove the `--exclude` flag after cleaning up existing scripts
.PHONY: lint-sh
lint-sh: SH_LINT_FLAGS ?=
lint-sh:
find . -type f -name '*.sh' | xargs \
shellcheck \
--exclude=SC2086 \
$(SH_LINT_FLAGS)
2020-11-17 14:49:56 +00:00
# lint AWS AMI scripts
# SC1091 prints errors when "source" directives are not followed
find assets/aws/files/bin -type f | xargs \
shellcheck \
--exclude=SC2086 \
--exclude=SC1091 \
--exclude=SC2129 \
2020-11-17 14:49:56 +00:00
$(SH_LINT_FLAGS)
# Lints all the Helm charts found in directories under examples/chart and exits on failure
# If there is a .lint directory inside, the chart gets linted once for each .yaml file in that directory
# We inherit yamllint's 'relaxed' configuration as it's more compatible with Helm output and will only error on
# show-stopping issues. Kubernetes' YAML parser is not particularly fussy.
# If errors are found, the file is printed with line numbers to aid in debugging.
.PHONY: lint-helm
lint-helm:
@if ! type yamllint 2>&1 >/dev/null; then \
echo "Not running 'lint-helm' target as 'yamllint' is not installed."; \
if [ "$${DRONE}" = "true" ]; then echo "This is a failure when running in CI." && exit 1; fi; \
exit 0; \
fi; \
for CHART in $$(find examples/chart -mindepth 1 -maxdepth 1 -type d); do \
if [ -d $${CHART}/.lint ]; then \
for VALUES in $${CHART}/.lint/*.yaml; do \
export HELM_TEMP=$$(mktemp); \
echo -n "Using values from '$${VALUES}': "; \
yamllint -c examples/chart/.lint-config.yaml $${VALUES} || { cat -en $${VALUES}; exit 1; }; \
helm lint --strict $${CHART} -f $${VALUES} || exit 1; \
helm template test $${CHART} -f $${VALUES} 1>$${HELM_TEMP} || exit 1; \
yamllint -c examples/chart/.lint-config.yaml $${HELM_TEMP} || { cat -en $${HELM_TEMP}; exit 1; }; \
done \
else \
export HELM_TEMP=$$(mktemp); \
helm lint --strict $${CHART} || exit 1; \
helm template test $${CHART} 1>$${HELM_TEMP} || exit 1; \
yamllint -c examples/chart/.lint-config.yaml $${HELM_TEMP} || { cat -en $${HELM_TEMP}; exit 1; }; \
fi; \
done
ADDLICENSE := $(GOPATH)/bin/addlicense
ADDLICENSE_ARGS := -c 'Gravitational, Inc' -l apache \
-ignore '**/*.c' \
-ignore '**/*.h' \
-ignore '**/*.html' \
-ignore '**/*.js' \
-ignore '**/*.py' \
-ignore '**/*.sh' \
-ignore '**/*.tf' \
-ignore '**/*.yaml' \
-ignore '**/*.yml' \
-ignore '**/Dockerfile' \
-ignore 'api/version.go' \
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
-ignore 'docs/pages/includes/**/*.go' \
-ignore 'e/**' \
-ignore 'gitref.go' \
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
-ignore 'lib/srv/desktop/rdp/rdpclient/target/**' \
2022-02-15 20:44:28 +00:00
-ignore 'lib/teleterm/api/protogen/**' \
Add a new usage reporter (#18142) * [draft] Add a new usage reporter This adds a new usage reporter service to the auth server. It's disabled by default in OSS and can only be turned on via startup hook in Cloud / Enterprise. In OSS, the audit log wrapper is never configured and any usage events are sent to a no-op discard reporter. Usage events are defined in prehog and can be sent to the new UsageReporter Service on the auth server. An audit event wrapper is used to capture certain events that are otherwise difficult to hook. Events are anonymized before submission, then held in a non-blocking queue for batching and submission purposes. * Remove dead code * Add SubmitUsageEvent RPC to Auth. This adds a new SubmitUsageEvent RPC to the Auth API that external clients (e.g. the UI) can use to submit usage events externally. * Slight refactor for unit testing * Add Prometheus metrics and add initial working prehog submitter * Add more metrics, tweak prehog client, and add unit tests * Further tweak http transport settings based on Teleport defaults * Add missing metrics * Fix goimports * Add new UI usage events * Update e ref * Add prehog directly for now. Improve logging. * update prehog * Add new prehog events; use username from request identity * add HTTP server for user events * Add username back to pre-onboard events * unauthenticated user events * Fix userevent build error * Use event-provided username where appropriate * Move barebones prehog reqs to lib/prehog and generate here. Also, use prod tunable values. * Fix license lints * De-flake tests by adding unfortunate amounts of synchronization. * Add missing license header * Misc PR cleanup for review * Update lib/events/usageevents/usageevents.go Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Address a batch of review comments Adds `anonymizer.AnonymizeString` and parent loggers * Update e ref * Clean up comments * Remove onboard prefix from recovery code event * Address another batch of feedback * Use defaults.HTTPClient() * Remove a noisy log message * Demote noisy log message to debug * Temporarily revert e ref for merge Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-12-05 17:13:54 +00:00
-ignore 'lib/prehog/gen/**' \
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
-ignore 'lib/web/build/**' \
-ignore 'version.go' \
-ignore 'webassets/**' \
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
-ignore 'ignoreme'
.PHONY: lint-license
lint-license: $(ADDLICENSE)
$(ADDLICENSE) $(ADDLICENSE_ARGS) -check * 2>/dev/null
.PHONY: fix-license
fix-license: $(ADDLICENSE)
$(ADDLICENSE) $(ADDLICENSE_ARGS) * 2>/dev/null
$(ADDLICENSE):
cd && go install github.com/google/addlicense@v1.0.0
2022-09-07 10:40:04 +00:00
# This rule updates version files and Helm snapshots based on the Makefile
# VERSION variable.
#
# Used prior to a release by bumping VERSION in this Makefile and then
# running "make update-version".
.PHONY: update-version
update-version: version test-helm-update-snapshots
2021-06-18 18:52:55 +00:00
# This rule triggers re-generation of version files if Makefile changes.
.PHONY: version
2022-09-07 10:40:04 +00:00
version: $(VERSRC)
2021-06-18 18:52:55 +00:00
# This rule triggers re-generation of version files specified if Makefile changes.
$(VERSRC): Makefile
2016-12-31 08:13:41 +00:00
VERSION=$(VERSION) $(MAKE) -f version.mk setver
# Update api module path, but don't fail on error.
$(MAKE) update-api-import-path || true
# This rule updates the api module path to be in sync with the current api release version.
# e.g. github.com/gravitational/teleport/api/vX -> github.com/gravitational/teleport/api/vY
#
# It will immediately fail if:
# 1. A suffix is present in the version - e.g. "v7.0.0-alpha"
# 2. The major version suffix in the api module path hasn't changed. e.g:
# - v7.0.0 -> v7.1.0 - both use version suffix "/v7" - github.com/gravitational/teleport/api/v7
# - v0.0.0 -> v1.0.0 - both have no version suffix - github.com/gravitational/teleport/api
#
# Note: any build flags needed to compile go files (such as build tags) should be provided below.
.PHONY: update-api-import-path
update-api-import-path:
go run build.assets/gomod/update-api-import-path/main.go -tags "bpf fips pam desktop_access_rdp linux"
$(MAKE) grpc
2016-06-13 18:27:19 +00:00
# make tag - prints a tag to use with git for the current version
# To put a new release on Github:
# - bump VERSION variable
# - run make setver
# - commit changes to git
# - build binaries with 'make release'
# - run `make tag` and use its output to 'git tag' and 'git push --tags'
.PHONY: update-tag
update-tag:
@test $(VERSION)
git tag $(GITTAG)
git tag api/$(GITTAG)
git push origin $(GITTAG) && git push origin api/$(GITTAG)
.PHONY: test-package
test-package: remove-temp-files
go test -v ./$(p)
2015-03-02 20:11:23 +00:00
.PHONY: test-grep-package
test-grep-package: remove-temp-files
go test -v ./$(p) -check.f=$(e)
2015-03-02 20:11:23 +00:00
.PHONY: cover-package
2015-05-04 15:28:32 +00:00
cover-package: remove-temp-files
go test -v ./$(p) -coverprofile=/tmp/coverage.out
go tool cover -html=/tmp/coverage.out
2015-03-02 20:11:23 +00:00
.PHONY: profile
2015-03-02 20:11:23 +00:00
profile:
go tool pprof http://localhost:6060/debug/pprof/profile
2015-03-02 20:11:23 +00:00
.PHONY: sloccount
2015-03-02 20:11:23 +00:00
sloccount:
find . -o -name "*.go" -print0 | xargs -0 wc -l
.PHONY: remove-temp-files
remove-temp-files:
find . -name flymake_* -delete
# Dockerized build: useful for making Linux releases on OSX
.PHONY:docker
docker:
make -C build.assets build
# Dockerized build: useful for making Linux binaries on macOS
.PHONY:docker-binaries
2020-07-20 20:18:00 +00:00
docker-binaries: clean
make -C build.assets build-binaries
# Interactively enters a Docker container (which you can build and run Teleport inside of)
.PHONY:enter
enter:
make -C build.assets enter
2017-05-27 01:03:19 +00:00
2022-04-22 10:50:24 +00:00
# Interactively enters a Docker container, as root (which you can build and run Teleport inside of)
.PHONY:enter-root
enter-root:
make -C build.assets enter-root
# Interactively enters a Docker container (which you can build and run Teleport inside of).
# Similar to `enter`, but uses the centos7 container.
.PHONY:enter/centos7
enter/centos7:
make -C build.assets enter/centos7
# Interactively enters a Docker container (which you can build and run Teleport Connect inside of).
# Similar to `enter`, but uses the teleterm container.
.PHONY:enter/teleterm
enter/teleterm:
make -C build.assets enter/teleterm
BUF := buf
# protos/all runs build, lint and format on all protos.
# Use `make grpc` to regenerate protos inside buildbox.
.PHONY: protos/all
protos/all: protos/build protos/lint protos/format
.PHONY: protos/build
protos/build: buf/installed
$(BUF) build
cd lib/teleterm && $(BUF) build
Add a new usage reporter (#18142) * [draft] Add a new usage reporter This adds a new usage reporter service to the auth server. It's disabled by default in OSS and can only be turned on via startup hook in Cloud / Enterprise. In OSS, the audit log wrapper is never configured and any usage events are sent to a no-op discard reporter. Usage events are defined in prehog and can be sent to the new UsageReporter Service on the auth server. An audit event wrapper is used to capture certain events that are otherwise difficult to hook. Events are anonymized before submission, then held in a non-blocking queue for batching and submission purposes. * Remove dead code * Add SubmitUsageEvent RPC to Auth. This adds a new SubmitUsageEvent RPC to the Auth API that external clients (e.g. the UI) can use to submit usage events externally. * Slight refactor for unit testing * Add Prometheus metrics and add initial working prehog submitter * Add more metrics, tweak prehog client, and add unit tests * Further tweak http transport settings based on Teleport defaults * Add missing metrics * Fix goimports * Add new UI usage events * Update e ref * Add prehog directly for now. Improve logging. * update prehog * Add new prehog events; use username from request identity * add HTTP server for user events * Add username back to pre-onboard events * unauthenticated user events * Fix userevent build error * Use event-provided username where appropriate * Move barebones prehog reqs to lib/prehog and generate here. Also, use prod tunable values. * Fix license lints * De-flake tests by adding unfortunate amounts of synchronization. * Add missing license header * Misc PR cleanup for review * Update lib/events/usageevents/usageevents.go Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Address a batch of review comments Adds `anonymizer.AnonymizeString` and parent loggers * Update e ref * Clean up comments * Remove onboard prefix from recovery code event * Address another batch of feedback * Use defaults.HTTPClient() * Remove a noisy log message * Demote noisy log message to debug * Temporarily revert e ref for merge Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-12-05 17:13:54 +00:00
cd lib/prehog && $(BUF) build
.PHONY: protos/format
protos/format: buf/installed
$(BUF) format -w
cd lib/teleterm && $(BUF) format -w
Add a new usage reporter (#18142) * [draft] Add a new usage reporter This adds a new usage reporter service to the auth server. It's disabled by default in OSS and can only be turned on via startup hook in Cloud / Enterprise. In OSS, the audit log wrapper is never configured and any usage events are sent to a no-op discard reporter. Usage events are defined in prehog and can be sent to the new UsageReporter Service on the auth server. An audit event wrapper is used to capture certain events that are otherwise difficult to hook. Events are anonymized before submission, then held in a non-blocking queue for batching and submission purposes. * Remove dead code * Add SubmitUsageEvent RPC to Auth. This adds a new SubmitUsageEvent RPC to the Auth API that external clients (e.g. the UI) can use to submit usage events externally. * Slight refactor for unit testing * Add Prometheus metrics and add initial working prehog submitter * Add more metrics, tweak prehog client, and add unit tests * Further tweak http transport settings based on Teleport defaults * Add missing metrics * Fix goimports * Add new UI usage events * Update e ref * Add prehog directly for now. Improve logging. * update prehog * Add new prehog events; use username from request identity * add HTTP server for user events * Add username back to pre-onboard events * unauthenticated user events * Fix userevent build error * Use event-provided username where appropriate * Move barebones prehog reqs to lib/prehog and generate here. Also, use prod tunable values. * Fix license lints * De-flake tests by adding unfortunate amounts of synchronization. * Add missing license header * Misc PR cleanup for review * Update lib/events/usageevents/usageevents.go Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Address a batch of review comments Adds `anonymizer.AnonymizeString` and parent loggers * Update e ref * Clean up comments * Remove onboard prefix from recovery code event * Address another batch of feedback * Use defaults.HTTPClient() * Remove a noisy log message * Demote noisy log message to debug * Temporarily revert e ref for merge Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-12-05 17:13:54 +00:00
cd lib/prehog && $(BUF) format -w
.PHONY: protos/lint
protos/lint: buf/installed
$(BUF) lint
cd api/proto && $(BUF) lint --config=buf-legacy.yaml
cd lib/teleterm && $(BUF) lint
Add a new usage reporter (#18142) * [draft] Add a new usage reporter This adds a new usage reporter service to the auth server. It's disabled by default in OSS and can only be turned on via startup hook in Cloud / Enterprise. In OSS, the audit log wrapper is never configured and any usage events are sent to a no-op discard reporter. Usage events are defined in prehog and can be sent to the new UsageReporter Service on the auth server. An audit event wrapper is used to capture certain events that are otherwise difficult to hook. Events are anonymized before submission, then held in a non-blocking queue for batching and submission purposes. * Remove dead code * Add SubmitUsageEvent RPC to Auth. This adds a new SubmitUsageEvent RPC to the Auth API that external clients (e.g. the UI) can use to submit usage events externally. * Slight refactor for unit testing * Add Prometheus metrics and add initial working prehog submitter * Add more metrics, tweak prehog client, and add unit tests * Further tweak http transport settings based on Teleport defaults * Add missing metrics * Fix goimports * Add new UI usage events * Update e ref * Add prehog directly for now. Improve logging. * update prehog * Add new prehog events; use username from request identity * add HTTP server for user events * Add username back to pre-onboard events * unauthenticated user events * Fix userevent build error * Use event-provided username where appropriate * Move barebones prehog reqs to lib/prehog and generate here. Also, use prod tunable values. * Fix license lints * De-flake tests by adding unfortunate amounts of synchronization. * Add missing license header * Misc PR cleanup for review * Update lib/events/usageevents/usageevents.go Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com> * Address a batch of review comments Adds `anonymizer.AnonymizeString` and parent loggers * Update e ref * Clean up comments * Remove onboard prefix from recovery code event * Address another batch of feedback * Use defaults.HTTPClient() * Remove a noisy log message * Demote noisy log message to debug * Temporarily revert e ref for merge Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com> Co-authored-by: Edoardo Spadolini <edoardo.spadolini@goteleport.com>
2022-12-05 17:13:54 +00:00
cd lib/prehog && $(BUF) lint
.PHONY: lint-protos
lint-protos: protos/lint
.PHONY: buf/installed
buf/installed:
@if ! type -p $(BUF) >/dev/null; then \
echo 'Buf is required to build/format/lint protos. Follow https://docs.buf.build/installation.'; \
exit 1; \
fi
# grpc generates GRPC stubs from service definitions.
# This target runs in the buildbox container.
2017-05-27 01:03:19 +00:00
.PHONY: grpc
grpc:
$(MAKE) -C build.assets grpc
2017-05-27 01:03:19 +00:00
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
# grpc/host generates GRPC stubs.
# Unlike grpc, this target runs locally.
.PHONY: grpc/host
grpc/host: protos/all
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
@build.assets/genproto.sh
print/env:
env
# grpc-teleterm generates Go, TypeScript and JavaScript gRPC stubs from definitions for Teleport
# Terminal. This target runs in the buildbox-teleterm container.
#
# It exists as a separate target because on M1 MacBooks we must build grpc_node_plugin from source.
# That involves apt-get install of cmake & build-essential as well pulling hundreds of megabytes of
# git repos. It would significantly increase the time it takes to build buildbox for M1 users that
# don't need to generate Teleterm gRPC files.
# TODO(ravicious): incorporate grpc-teleterm into grpc once grpc-tools adds arm64 binary.
# https://github.com/grpc/grpc-node/issues/1405
.PHONY: grpc-teleterm
grpc-teleterm:
$(MAKE) -C build.assets grpc-teleterm
Use to Buf to lint, format and generate api/ protos (#15856) Change the proto layout of `api/` to a more standard setup, allowing the use of modern tools (like Buf) to format/lint (and maybe, one day, generate sources). The new layout looks like this: ``` api/ proto/ <- root of protos and proto imports teleport/ <- base package for Teleport protos (akin to "google/" or "gogoproto/") legacy/ <- root of "legacy" protos (most linters disabled) client/ proto/ types/ events/ webauthn/ wrappers/ ``` Non-legacy `api/` protos are expected to follow this layout: ``` api/ proto/ teleport/ mynewpackage/ <- package name v1/ <- protos explicitly versioned gen/ proto/ <- root for generated sources (multi-language possible, separate from hand-written code) go/ mynewpackage/ v1 <- generate Go sources go here. ``` Some outstanding issues, like lack of `go_package` declarations and non-standard import paths (`import "github.com/gravitational/teleport/.../some.proto"`) are fixed. Legacy protos still have irregular package declarations. It's possible to fix that, but it's a bit harder to reason about, as generated sources change in possibly-meaningful ways. Future iterations could change legacy packages to match the directory structure and apply a similar change to protos within lib/ packages, but this seems sufficient for a first step. * Add Buf to buildbox * Unify API protos under Buf * Fix proto generation * Reformat protos * Update generated protos * Generate protos using Buf * Appease linter * Review: make sure gogo protobuf versions are in sync * Clean leftovers from previous attempts * Fix operator/Makefile * Rename internal make gRPC targets to `*/host` * Sort `make fix-license` targets (nit)
2022-08-26 18:11:38 +00:00
# grpc-teleterm/host generates GRPC stubs.
# Unlike grpc-teleterm, this target runs locally.
.PHONY: grpc-teleterm/host
grpc-teleterm/host: protos/all
cd lib/teleterm && $(BUF) generate
.PHONY: goinstall
goinstall:
go install $(BUILDFLAGS) \
github.com/gravitational/teleport/tool/tsh \
github.com/gravitational/teleport/tool/teleport \
github.com/gravitational/teleport/tool/tctl
2018-02-24 01:23:09 +00:00
# make install will installs system-wide teleport
.PHONY: install
install: build
@echo "\n** Make sure to run 'make install' as root! **\n"
cp -f $(BUILDDIR)/tctl $(BINDIR)/
cp -f $(BUILDDIR)/tsh $(BINDIR)/
cp -f $(BUILDDIR)/teleport $(BINDIR)/
mkdir -p $(DATADIR)
# Docker image build. Always build the binaries themselves within docker (see
# the "docker" rule) to avoid dependencies on the host libc version.
.PHONY: image
image: OS=linux
image: TARBALL_PATH_SECTION:=-s "$(shell pwd)"
image: clean docker-binaries build-archive oss-deb
2018-06-20 23:36:54 +00:00
cp ./build.assets/charts/Dockerfile $(BUILDDIR)/
cd $(BUILDDIR) && docker build --no-cache . -t $(DOCKER_IMAGE):$(VERSION)-$(ARCH) --target teleport \
--build-arg DEB_PATH="./teleport_$(VERSION)_$(ARCH).deb"
if [ -f e/Makefile ]; then $(MAKE) -C e image; fi
.PHONY: print-version
print-version:
@echo $(VERSION)
.PHONY: chart-ent
chart-ent:
$(MAKE) -C e chart
RUNTIME_SECTION ?=
TARBALL_PATH_SECTION ?=
ifneq ("$(RUNTIME)", "")
RUNTIME_SECTION := -r $(RUNTIME)
endif
ifneq ("$(OSS_TARBALL_PATH)", "")
TARBALL_PATH_SECTION := -s $(OSS_TARBALL_PATH)
endif
# build .pkg
.PHONY: pkg
pkg:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh ./build.assets/build-common.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
# arch and runtime are currently ignored on OS X
# we pass them through for consistency - they will be dropped by the build script
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p pkg -a $(ARCH) $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
if [ -f e/Makefile ]; then $(MAKE) -C e pkg; fi
# build tsh client-only .pkg
.PHONY: pkg-tsh
pkg-tsh:
./build.assets/build-pkg-tsh.sh -t oss -v $(VERSION) $(TARBALL_PATH_SECTION)
mkdir -p $(BUILDDIR)/
mv tsh*.pkg* $(BUILDDIR)/
# build .rpm
.PHONY: rpm
rpm:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh ./build.assets/build-common.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
cp -a ./build.assets/rpm $(BUILDDIR)/
cp -a ./build.assets/rpm-sign $(BUILDDIR)/
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p rpm -a $(ARCH) $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
if [ -f e/Makefile ]; then $(MAKE) -C e rpm; fi
# build unsigned .rpm (for testing)
.PHONY: rpm-unsigned
rpm-unsigned:
$(MAKE) UNSIGNED_RPM=true rpm
# build open source .deb only
.PHONY: oss-deb
oss-deb:
mkdir -p $(BUILDDIR)/
cp ./build.assets/build-package.sh ./build.assets/build-common.sh $(BUILDDIR)/
chmod +x $(BUILDDIR)/build-package.sh
cd $(BUILDDIR) && ./build-package.sh -t oss -v $(VERSION) -p deb -a $(ARCH) $(RUNTIME_SECTION) $(TARBALL_PATH_SECTION)
# build .deb
.PHONY: deb
deb: oss-deb
if [ -f e/Makefile ]; then $(MAKE) -C e deb; fi
# check binary compatibility with different OSes
.PHONY: test-compat
test-compat:
./build.assets/build-test-compat.sh
Merge Teleport V4.3 UI branch to master (#3583) * Add monorepo * Add reset/passwd capability for local users (#3287) * Add UserTokens to allow password resets * Pass context down through ChangePasswordWithToken * Rename UserToken to ResetPasswordToken * Add auto formatting for proto files * Add common Marshaller interfaces to reset password token * Allow enterprise "tctl" reuse OSS user methods (#3344) * Pass localAuthEnabled flag to UI (#3412) * Added LocalAuthEnabled prop to WebConfigAuthSetting struct in webconfig.go * Added LocalAuthEnabled state as part of webCfg in apiserver.go * update e-refs * Fix a regression bug after merge * Update tctl CLI output msgs (#3442) * Use local user client when resolving user roles * Update webapps ref * Add and retrieve fields from Cluster struct (#3476) * Set Teleport versions for node, auth, proxy init heartbeat * Add and retrieve fields NodeCount, PublicURL, AuthVersion from Clusters * Remove debug logging to avoid log pollution when getting public_addr of proxy * Create helper func GuessProxyHost to get the public_addr of a proxy host * Refactor newResetPasswordToken to use GuessProxyHost and remove publicUrl func * Remove webapps submodule * Add webassets submodule * Replace webapps sub-module reference with webassets * Update webassets path in Makefile * Update webassets 1b11b26 Simplify and clean up Makefile (#62) https://github.com/gravitational/webapps/commit/1b11b26 * Retrieve cluster details for user context (#3515) * Let GuessProxyHost also return proxy's version * Unit test GuessProxyHostAndVersion & GetClusterDetails * Update webassets 4dfef4e Fix build pipeline (#66) https://github.com/gravitational/webapps/commit/4dfef4e * Update e-ref * Update webassets 0647568 Fix OSS redirects https://github.com/gravitational/webapps/commit/0647568 * update e-ref * Update webassets e0f4189 Address security audit warnings Updates "minimist" package which is used by 7y old "optimist". https://github.com/gravitational/webapps/commit/e0f4189 * Add new attr to Session struct (#3574) * Add fields ServerHostname and ServerAddr * Set these fields on newSession * Ensure webassets submodule during build * Update e-ref * Ensure webassets before running unit-tests * Update E-ref Co-authored-by: Lisa Kim <lisa@gravitational.com> Co-authored-by: Pierre Beaucamp <pierre@gravitational.com> Co-authored-by: Jenkins <jenkins@gravitational.io>
2020-04-15 19:35:26 +00:00
.PHONY: ensure-webassets
ensure-webassets:
@if [ ! -d $(shell pwd)/webassets/teleport/ ]; then \
$(MAKE) init-webapps-submodules; \
fi;
.PHONY: ensure-webassets-e
ensure-webassets-e:
@if [ ! -d $(shell pwd)/webassets/e/teleport ]; then \
$(MAKE) init-webapps-submodules-e; \
fi;
.PHONY: init-webapps-submodules
init-webapps-submodules:
echo "init webassets submodule"
git submodule update --init webassets
.PHONY: init-webapps-submodules-e
init-webapps-submodules-e:
echo "init webassets oss and enterprise submodules"
git submodule update --init --recursive webassets
.PHONY: init-submodules-e
init-submodules-e: init-webapps-submodules-e
git submodule init e
git submodule update
# update-webassets creates a PR in the teleport repo to update webassets submodule.
.PHONY: update-webassets
update-webassets: WEBASSETS_BRANCH ?= 'master'
update-webassets: TELEPORT_BRANCH ?= 'master'
update-webassets:
build.assets/webapps/update-teleport-webassets.sh -w $(WEBASSETS_BRANCH) -t $(TELEPORT_BRANCH)
# dronegen generates .drone.yml config
#
# Usage:
# - install github.com/gravitational/tdr
# - set $DRONE_TOKEN and $DRONE_SERVER (https://drone.platform.teleport.sh)
# - tsh login --proxy=platform.teleport.sh
# - tsh app login drone
# - make dronegen
.PHONY: dronegen
dronegen:
go run ./dronegen
2022-02-01 20:07:23 +00:00
# backport will automatically create backports for a given PR as long as you have the "gh" tool
# installed locally. To backport, type "make backport PR=1234 TO=branch/1,branch/2".
.PHONY: backport
backport:
(cd ./assets/backport && go run main.go -pr=$(PR) -to=$(TO))