Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/devcontainers/features/kubectl-helm-minikube:1": {},
"ghcr.io/devcontainers-contrib/features/kind:1": {},
"ghcr.io/devcontainers/features/azure-cli:1": {}
},
"postCreateCommand": "bash .devcontainer/installMoreTools.sh && kind create cluster",
Expand All @@ -22,4 +21,4 @@
]
}
}
}
}
4 changes: 4 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
IS_NOT_MERGE_GROUP: ${{ github.event_name != 'merge_group' }}
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
if: env.IS_NOT_MERGE_GROUP
Expand All @@ -28,6 +29,9 @@ jobs:
if: env.IS_NOT_MERGE_GROUP
with:
go-version-file: go.mod
- name: Check BPF object stubs
if: env.IS_NOT_MERGE_GROUP
run: make lint-bpf-objects
- name: golangci-lint
if: env.IS_NOT_MERGE_GROUP
uses: golangci/golangci-lint-action@v9
Expand Down
21 changes: 8 additions & 13 deletions .github/workflows/images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
build-windows-binaries:
name: Build Windows Binaries
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
Expand Down Expand Up @@ -133,7 +133,7 @@ jobs:
TAG=$(make version)
echo "TAG=$TAG" >> "$GITHUB_ENV"
if [ "$IS_MERGE_GROUP" == "true" ]; then
az acr login -n ${{ vars.ACR_NAME }}
az acr login -n ${{ vars.ACR_NAME }}
make retina-image-win \
IMAGE_NAMESPACE=${{ github.repository }} \
PLATFORM=${{ matrix.platform }}/${{ matrix.arch }} \
Expand Down Expand Up @@ -207,18 +207,13 @@ jobs:
IS_MERGE_GROUP: ${{ github.event_name == 'merge_group' }}

retina-shell-images:
name: Build Retina Shell Images (${{ matrix.platform }}, ${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
name: Build Retina Shell Images
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}

strategy:
matrix:
include:
- platform: linux
arch: amd64
runner: ubuntu-latest
- platform: linux
arch: arm64
runner: ubuntu-24.04-arm
platform: ["linux"]
arch: ["amd64", "arm64"]

steps:
- name: Checkout code
Expand Down Expand Up @@ -343,7 +338,7 @@ jobs:
shell: bash
run: |
set -euo pipefail
az acr login -n ${{ vars.ACR_NAME }}
az acr login -n ${{ vars.ACR_NAME }}
make manifest COMPONENT=${{ matrix.components }} \
IMAGE_REGISTRY=${{ vars.ACR_NAME }} \

Expand Down Expand Up @@ -395,7 +390,7 @@ jobs:
azure-tenant-id: ${{ secrets.AZURE_TENANT_ID }}
azure-client-id: ${{ secrets.AZURE_CLIENT_ID }}
azure-app-insights-key: ${{ secrets.AZURE_APP_INSIGHTS_KEY }}

perf-test-advanced:
if: ${{ github.event_name == 'merge_group'}}
needs: [manifests]
Expand Down
64 changes: 26 additions & 38 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,55 +1,43 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
# Binaries
*.exe
*.exe~
*.dll
*.so
*.dylib

# Avoid checking in keys
*.pem

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# logs
*.log

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# Object files
*.o
bin/
dist/

# docusaurus
site/yarn.lock
site/.docusaurus/
site/node_modules/
# Go
go.work

output
#vscode
.vscode/
# Keys and certificates
*.pem
.certs/

dist/
bin/
# Logs and output
*.log
*.out
.output/

image-metadata-*.json
*packetmonitorsupport*/
*.pem
# Test artifacts
*results*.json
netperf-*.json
netperf-*.csv
image-metadata-*.json
*packetmonitorsupport*/
test-summary

.certs/
# Build artifacts
.artifacts/

artifacts/
# Documentation site
site/yarn.lock
site/.docusaurus/
site/node_modules/

test-summary
# IDE and editor
.vscode/
.clangd
.clang-format
20 changes: 17 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ help: ## Display this help
##@ Tools

GOFUMPT = go tool mvdan.cc/gofumpt
GOLANGCI_LINT = go tool github.com/golangci/golangci-lint/cmd/golangci-lint
GOLANGCI_LINT = go tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
GORELEASER = go tool github.com/goreleaser/goreleaser
CONTROLLER_GEN = go tool sigs.k8s.io/controller-tools/cmd/controller-gen
GINKGO = go tool github.com/onsi/ginkgo
Expand Down Expand Up @@ -141,10 +141,24 @@ fmt: ## run gofumpt on $FMT_PKG (default "retina").
$(GOFUMPT) -w $(FMT_PKG)

lint: ## Fast lint vs default branch showing only new issues.
$(GOLANGCI_LINT) run --new-from-rev main --timeout 10m -v $(LINT_PKG)/...
CGO_ENABLED=0 $(GOLANGCI_LINT) run --new-from-rev main --timeout 10m -v $(LINT_PKG)/...

lint-existing: ## Lint the current branch in entirety.
$(GOLANGCI_LINT) run -v $(LINT_PKG)/...
CGO_ENABLED=0 $(GOLANGCI_LINT) run -v $(LINT_PKG)/...

lint-bpf-objects: ## Check that committed .o files are empty stubs (build generates real ones).
@echo "Checking for non-empty .o files..."
@non_empty=$$(git ls-files '*.o' | xargs -I{} sh -c 'test -s "{}" && echo "{}"'); \
if [ -n "$$non_empty" ]; then \
echo "ERROR: The following .o files must be empty stubs:"; \
echo "$$non_empty"; \
echo "Run 'make empty-bpf-objects' to fix."; \
exit 1; \
fi
@echo "All .o files are empty stubs. OK."

empty-bpf-objects: ## Empty all tracked .o files (they are stubs for the linter).
git ls-files '*.o' | xargs -I{} truncate -s 0 {}

clean: ## clean build artifacts
$(RMDIR) $(OUTPUT_DIR)
Expand Down
10 changes: 5 additions & 5 deletions cli/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8 AS builder
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.25.7-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM mcr.microsoft.com/oss/go/microsoft/golang@sha256:408661cbcfcbf24c06fc4f85c23566b42af722fdef5a5044782859e682916be7 AS builder

ARG VERSION
ARG APP_INSIGHTS_ID
Expand All @@ -16,21 +16,21 @@ ARG GOARCH=amd64
ENV GOARCH=${GOARCH}

RUN --mount=type=cache,target="/root/.cache/go-build" \
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
GOOS=$GOOS GOARCH=$GOARCH go build \
-ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" \
-X "github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID"="$APP_INSIGHTS_ID" \
-X "github.com/microsoft/retina/internal/buildinfo.RetinaAgentImageName"="$AGENT_IMAGE_NAME"" \
-a -o kubectl-retina cli/main.go

# Target 1: Distroless (secure, minimal)
# skopeo inspect docker://mcr.microsoft.com/azurelinux/distroless/minimal:3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/azurelinux/distroless/minimal@sha256:0801b80a0927309572b9adc99bd1813bc680473175f6e8175cd4124d95dbd50c AS distroless-target
FROM mcr.microsoft.com/azurelinux/distroless/minimal@sha256:0801b80a0927309572b9adc99bd1813bc680473175f6e8175cd4124d95dbd50c AS distroless-target
WORKDIR /
COPY --from=builder /workspace/kubectl-retina .

# Target 2: Shell-enabled (operational, init container support)
# skopeo inspect docker://mcr.microsoft.com/cbl-mariner/base/core:2.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/cbl-mariner/base/core@sha256:4d97d662d71c1fda938ed9df36d8f490d9107cff37e89c0efa932d073285ad85 AS shell-target
FROM mcr.microsoft.com/cbl-mariner/base/core@sha256:4d97d662d71c1fda938ed9df36d8f490d9107cff37e89c0efa932d073285ad85 AS shell-target
WORKDIR /
COPY --from=builder /workspace/kubectl-retina /bin/kubectl-retina
RUN chmod +x /bin/kubectl-retina
Expand Down
18 changes: 10 additions & 8 deletions controller/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pinned base images

# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8 AS golang
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.25.7-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM mcr.microsoft.com/oss/go/microsoft/golang@sha256:408661cbcfcbf24c06fc4f85c23566b42af722fdef5a5044782859e682916be7 AS golang

# skopeo inspect docker://mcr.microsoft.com/azurelinux/base/core:3.0 --format "{{.Name}}@{{.Digest}}"
FROM mcr.microsoft.com/azurelinux/base/core@sha256:9948138108a3d69f1dae62104599ac03132225c3b7a5ac57b85a214629c8567d AS azurelinux-core
Expand All @@ -19,21 +19,23 @@ ARG GOOS=linux # default to linux
ENV GOARCH=${GOARCH}
ENV GOOS=${GOOS}
RUN if [ "$GOOS" = "linux" ] ; then \
tdnf install -y clang lld bpftool libbpf-devel; \
tdnf install -y clang lld bpftool libbpf-devel; \
fi
COPY ./pkg/plugin /go/src/github.com/microsoft/retina/pkg/plugin
WORKDIR /go/src/github.com/microsoft/retina
RUN if [ "$GOOS" = "linux" ] ; then \
go mod init github.com/microsoft/retina; \
go generate -skip "mockgen" -x /go/src/github.com/microsoft/retina/pkg/plugin/...; \
tar czf /gen.tar.gz ./pkg/plugin; \
rm go.mod; \
go mod init github.com/microsoft/retina; \
go generate -skip "mockgen" -x /go/src/github.com/microsoft/retina/pkg/plugin/...; \
tar czf /gen.tar.gz ./pkg/plugin; \
rm go.mod; \
fi
COPY ./go.mod ./go.sum ./
RUN go mod download
COPY . .
RUN if [ "$GOOS" = "linux" ] ; then \
rm -rf ./pkg/plugin && tar xvf /gen.tar.gz ./pkg/plugin; \
rm -rf ./pkg/plugin && tar xvf /gen.tar.gz ./pkg/plugin; \
find ./pkg/plugin -path "*/_cprog/*.go" -delete; \
find ./pkg/plugin -name "*.go" -exec sed -i '/^[[:space:]]*_[[:space:]]*".*\/_cprog"/d' {} \;; \
fi

# capture binary
Expand Down
4 changes: 2 additions & 2 deletions controller/Dockerfile.gogen
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.25.7-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:408661cbcfcbf24c06fc4f85c23566b42af722fdef5a5044782859e682916be7

# Default linux/architecture.
ARG GOOS=linux
Expand Down
4 changes: 2 additions & 2 deletions controller/Dockerfile.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.24.11-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:531bd02db17b0c2ec919f10fc203a6a8c825e8ca01f40c3a1e32e1cf7119c6d8
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.25.7-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:408661cbcfcbf24c06fc4f85c23566b42af722fdef5a5044782859e682916be7

LABEL Name=retina-builder Version=0.0.1

Expand Down
45 changes: 25 additions & 20 deletions controller/Dockerfile.windows-2019
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
# pinned base image
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.25.7-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
ARG BUILDPLATFORM
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:408661cbcfcbf24c06fc4f85c23566b42af722fdef5a5044782859e682916be7 AS builder

# Build args
ARG VERSION
ARG APP_INSIGHTS_ID

ENV GOOS=windows
ENV GOARCH=amd64

WORKDIR /usr/src/retina
# Copy the source
COPY . .

RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /usr/bin/controller.exe -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" -X "github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID"="$APP_INSIGHTS_ID"" ./controller/
RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /usr/bin/captureworkload.exe ./captureworkload/

# Copy into final image
# skopeo inspect docker://mcr.microsoft.com/windows/servercore:ltsc2019 --override-os windows --format "{{.Name}}@{{.Digest}}"
FROM mcr.microsoft.com/windows/servercore@sha256:a3d7773c4a836c2efd3ecb89f4fcb41199ee56d454225cf72a65b603bf569eca AS ltsc2019
FROM mcr.microsoft.com/windows/servercore@sha256:a3d7773c4a836c2efd3ecb89f4fcb41199ee56d454225cf72a65b603bf569eca AS agent-win
COPY --from=builder /usr/src/retina/windows/kubeconfigtemplate.yaml kubeconfigtemplate.yaml
COPY --from=builder /usr/src/retina/windows/setkubeconfigpath.ps1 setkubeconfigpath.ps1
COPY --from=builder /usr/bin/controller.exe controller.exe
COPY --from=builder /usr/bin/captureworkload.exe captureworkload.exe

FROM ltsc2019 AS agent-win
ARG GOARCH=amd64 # default to amd64
ARG GOOS=windows # default to windows
ARG OS_VERSION=ltsc2019
ARG REPO_PATH
ARG BINARIES_PATH
ENV GOARCH=${GOARCH}
ENV GOOS=${GOOS}
ENV OS_VERSION=${OS_VERSION}
ENV BINARIES_PATH=${BINARIES_PATH}
ENV REPO_PATH=${REPO_PATH}
# CVE-2013-3900 Mitigation
RUN reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Wintrust\Config" /v "EnableCertPaddingCheck" /t REG_DWORD /d "1" /f
RUN reg add "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Cryptography\Wintrust\Config" /v "EnableCertPaddingCheck" /t REG_DWORD /d "1" /f
COPY ${REPO_PATH}/windows/kubeconfigtemplate.yaml kubeconfigtemplate.yaml
COPY ${REPO_PATH}/windows/setkubeconfigpath.ps1 setkubeconfigpath.ps1
COPY ${BINARIES_PATH}/captureworkload.exe captureworkload.exe
COPY ${BINARIES_PATH}/controller.exe controller.exe
ADD https://github.com/microsoft/etl2pcapng/releases/download/v1.10.0/etl2pcapng.exe /etl2pcapng.exe

CMD ["controller.exe", "start", "--kubeconfig=.\\kubeconfig"]
44 changes: 24 additions & 20 deletions controller/Dockerfile.windows-2022
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# pinned base image
# skopeo inspect docker://mcr.microsoft.com/oss/go/microsoft/golang:1.25.7-azurelinux3.0 --format "{{.Name}}@{{.Digest}}"
ARG BUILDPLATFORM
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/oss/go/microsoft/golang@sha256:408661cbcfcbf24c06fc4f85c23566b42af722fdef5a5044782859e682916be7 AS builder

# Build args
ARG VERSION
ARG APP_INSIGHTS_ID

ENV GOOS=windows
ENV GOARCH=amd64

WORKDIR /usr/src/retina
# Copy the source
COPY . .

RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /usr/bin/controller.exe -ldflags "-X github.com/microsoft/retina/internal/buildinfo.Version="$VERSION" -X "github.com/microsoft/retina/internal/buildinfo.ApplicationInsightsID"="$APP_INSIGHTS_ID"" ./controller/
RUN --mount=type=cache,target="/root/.cache/go-build" go build -v -o /usr/bin/captureworkload.exe ./captureworkload/

# skopeo inspect docker://mcr.microsoft.com/windows/servercore:ltsc2022 --override-os windows --format "{{.Name}}@{{.Digest}}"
FROM mcr.microsoft.com/windows/servercore@sha256:3750d7fcd320130cc2ce61954902b71729e85ec2c07c5a2e83a6d6c7f34a61e5 AS ltsc2022
FROM --platform=windows/amd64 mcr.microsoft.com/windows/servercore@sha256:3750d7fcd320130cc2ce61954902b71729e85ec2c07c5a2e83a6d6c7f34a61e5 AS agent-win
COPY --from=builder /usr/src/retina/windows/kubeconfigtemplate.yaml kubeconfigtemplate.yaml
COPY --from=builder /usr/src/retina/windows/setkubeconfigpath.ps1 setkubeconfigpath.ps1
COPY --from=builder /usr/bin/controller.exe controller.exe
COPY --from=builder /usr/bin/captureworkload.exe captureworkload.exe

FROM ltsc2022 AS agent-win
ARG GOARCH=amd64 # default to amd64
ARG GOOS=windows # default to windows
ARG OS_VERSION=ltsc2022
ARG REPO_PATH
ARG BINARIES_PATH
ENV GOARCH=${GOARCH}
ENV GOOS=${GOOS}
ENV OS_VERSION=${OS_VERSION}
ENV BINARIES_PATH=${BINARIES_PATH}
ENV REPO_PATH=${REPO_PATH}
# CVE-2013-3900 Mitigation
RUN reg add "HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Wintrust\Config" /v "EnableCertPaddingCheck" /t REG_DWORD /d "1" /f
RUN reg add "HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Cryptography\Wintrust\Config" /v "EnableCertPaddingCheck" /t REG_DWORD /d "1" /f
COPY ${REPO_PATH}/windows/kubeconfigtemplate.yaml kubeconfigtemplate.yaml
COPY ${REPO_PATH}/windows/setkubeconfigpath.ps1 setkubeconfigpath.ps1
COPY ${BINARIES_PATH}/captureworkload.exe captureworkload.exe
COPY ${BINARIES_PATH}/controller.exe controller.exe
ADD https://github.com/microsoft/etl2pcapng/releases/download/v1.10.0/etl2pcapng.exe /etl2pcapng.exe

CMD ["controller.exe", "start", "--kubeconfig=.\\kubeconfig"]
Loading