-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: n-marton <[email protected]>
- Loading branch information
Showing
30 changed files
with
1,531 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @Adyen/container-services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/rexec" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: build rexec proxy image | ||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: 'Login to GitHub Container Registry' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
- name: Log into registry | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push latest | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: ghcr.io/adyen/kubectl-rexec:latest | ||
- name: Build and push ref | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: ghcr.io/adyen/kubectl-rexec:${{github.ref_name}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Github Stale Issues Check | ||
|
||
on: | ||
schedule: | ||
- cron: '59 23 * * *' # Run every day just before midnight | ||
|
||
jobs: | ||
close_stale_prs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Close stale issues | ||
uses: actions/stale@v9 | ||
with: | ||
any-of-labels: 'Needs more info' | ||
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Please comment on this issue otherwise it will be closed in 7 days.' | ||
close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' | ||
days-before-issue-stale: 21 | ||
days-before-issue-close: 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
TruffleHog: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: TruffleHog OSS | ||
id: trufflehog | ||
uses: trufflesecurity/[email protected] | ||
continue-on-error: true | ||
with: | ||
path: ./ | ||
base: "${{ github.event.repository.default_branch }}" | ||
head: HEAD | ||
|
||
- name: Scan Results Status | ||
if: steps.trufflehog.outcome == 'failure' | ||
run: exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## How does rexec work? | ||
|
||
The setup consists of two parts, first we have a `ValidatingWebhookConfiguration` where, we deny requests targeting pod exec unless the user is allowed to bypass or the request is coming through the rexec endpont. | ||
|
||
The second part is the rexec `APIService` where we receive exec request with the custom plugin. Here we modify the request back to a normal exec and audit it while proxying back to the kube apiserver. This proxyiing is happening through impersonation, as the user credentials are removed by the kube apiserver before being proxied to here. | ||
|
||
![Diagram](diagram.png?raw=true "Diagram") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM golang:1.23-bookworm AS builder | ||
|
||
LABEL org.opencontainers.image.source=https://github.com/adyen/kubectl-rexec | ||
LABEL org.opencontainers.image.description="Rexec proxy" | ||
LABEL org.opencontainers.image.licenses=MIT | ||
|
||
WORKDIR /workspace | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
COPY rexec/main.go main.go | ||
COPY rexec/server rexec/server | ||
|
||
RUN CGO_ENABLED=0 go build -a -o rexec-server . | ||
|
||
FROM scratch | ||
WORKDIR / | ||
COPY --from=builder /workspace/rexec-server . | ||
|
||
ENTRYPOINT ["/rexec-server"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Configuration | ||
|
||
`--sys-debug` if set the api will log more verbose information about internal events | ||
|
||
`--audit-trace` if set, and tty was requested all keystrokes will be logged (otherwise the async auditer will merge keystrokes into command on each new lines) | ||
|
||
`--by-pass-user` repeatable flag for adding users to bypass list so they can use the standard exec command, handy for system users like `system:admin` | ||
|
||
`--by-pass-shared-key` this flags needs to be set if one runes more then one replica of rexec api, so the shared key between the apiservice part and the validatingwebhookpart are matching, otherwise said hey is autogenerated, it has to be a RFC 4122 compliant uuid | ||
|
||
`--max-strokes-per-line` with this flag we can alter the treshold we have on a linelength before async audit flushes, keep in mind the increasing it too high might lead oom kills on the rexec server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# kubectl-rexec | ||
![LOGO](LOGO.png) | ||
|
||
Kubectl exec does not provide any kind of audit what is actually done inside the container. Rexec plugin is here to help with that. | ||
|
||
## Contributing | ||
We strongly encourage you to contribute to our repository. Find out more in our [contribution guidelines](https://github.com/Adyen/.github/blob/master/CONTRIBUTING.md) | ||
|
||
## Requirements | ||
In kubernetes 1.30 `TranslateStreamCloseWebsocketRequests` featuregate is true by the default making protocol between kubectl and kube-apiserver is websocket while prior is SPDY, this solution handles only websockets so the k8s cluster either has to be 1.30 or 1.29 with `TranslateStreamCloseWebsocketRequests=true` feature flag. Version below 1.29 are not supported. | ||
|
||
## Installation | ||
See the [Getting started](https://github.com/Adyen/kubectl-rexec/blob/master/STARTED.md) guide. | ||
|
||
## Usage | ||
See the [Getting started](https://github.com/Adyen/kubectl-rexec/blob/master/STARTED.md) guide. | ||
|
||
## Documentation | ||
See the [Design](https://github.com/Adyen/kubectl-rexec/blob/master/DESIGN.md). | ||
|
||
## Support | ||
If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue. | ||
|
||
## License | ||
MIT license. For more information, see the LICENSE file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Getting started | ||
|
||
For a proper installation you should use tagged images and your own implementation of kubernetes manifests, for a quick start however feel free to follow the instruction below. | ||
|
||
## Installing proxy | ||
|
||
The following command is going to install the proxy component, while adding a webhook that disables normal kubectl exec. | ||
|
||
``` | ||
kustomize build manifests/ | kubectl -n kube-system apply -f - | ||
``` | ||
|
||
## Installing the plugin | ||
|
||
Ensure that you go bin directory is in the path. | ||
|
||
``` | ||
go install github.com/adyen/kubectl-rexec@latest | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
module github.com/adyen/kubectl-rexec | ||
|
||
go 1.23.1 | ||
|
||
require ( | ||
github.com/google/uuid v1.6.0 | ||
github.com/gorilla/mux v1.8.1 | ||
github.com/rs/zerolog v1.33.0 | ||
github.com/spf13/cobra v1.8.1 | ||
k8s.io/api v0.32.0 | ||
k8s.io/apimachinery v0.32.0 | ||
k8s.io/cli-runtime v0.31.4 | ||
k8s.io/client-go v0.32.0 | ||
k8s.io/component-base v0.31.4 | ||
k8s.io/kubectl v0.31.4 | ||
) | ||
|
||
require ( | ||
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect | ||
github.com/MakeNowJust/heredoc v1.0.0 // indirect | ||
github.com/blang/semver/v4 v4.0.0 // indirect | ||
github.com/chai2010/gettext-go v1.0.2 // indirect | ||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect | ||
github.com/daviddengcn/go-colortext v1.0.0 // indirect | ||
github.com/distribution/reference v0.6.0 // indirect | ||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect | ||
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect | ||
github.com/fatih/camelcase v1.0.0 // indirect | ||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect | ||
github.com/go-errors/errors v1.4.2 // indirect | ||
github.com/go-logr/logr v1.4.2 // indirect | ||
github.com/go-openapi/jsonpointer v0.21.0 // indirect | ||
github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
github.com/go-openapi/swag v0.23.0 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.4 // indirect | ||
github.com/google/btree v1.0.1 // indirect | ||
github.com/google/gnostic-models v0.6.8 // indirect | ||
github.com/google/go-cmp v0.6.0 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect | ||
github.com/gorilla/websocket v1.5.0 // indirect | ||
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect | ||
github.com/inconshreveable/mousetrap v1.1.0 // indirect | ||
github.com/jonboulle/clockwork v0.4.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect | ||
github.com/lithammer/dedent v1.1.0 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.19 // indirect | ||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect | ||
github.com/moby/spdystream v0.5.0 // indirect | ||
github.com/moby/term v0.5.0 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect | ||
github.com/opencontainers/go-digest v1.0.0 // indirect | ||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
github.com/xlab/treeprint v1.2.0 // indirect | ||
golang.org/x/net v0.30.0 // indirect | ||
golang.org/x/oauth2 v0.23.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/sys v0.26.0 // indirect | ||
golang.org/x/term v0.25.0 // indirect | ||
golang.org/x/text v0.19.0 // indirect | ||
golang.org/x/time v0.7.0 // indirect | ||
google.golang.org/protobuf v1.35.1 // indirect | ||
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/component-helpers v0.32.0 // indirect | ||
k8s.io/klog/v2 v2.130.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect | ||
k8s.io/metrics v0.32.0 // indirect | ||
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect | ||
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect | ||
sigs.k8s.io/kustomize/api v0.18.0 // indirect | ||
sigs.k8s.io/kustomize/kustomize/v5 v5.5.0 // indirect | ||
sigs.k8s.io/kustomize/kyaml v0.18.1 // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect | ||
sigs.k8s.io/yaml v1.4.0 // indirect | ||
) |
Oops, something went wrong.