Skip to content
Merged
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
82 changes: 13 additions & 69 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ jobs:
run: |
make docker-build

- name: Verify image ships no Node or snyk-broker
run: |
docker run --rm --entrypoint sh cortex-axon-agent:local -c '
for b in node npm npx snyk-broker; do
if command -v "$b"; then echo "unexpected binary: $b" >&2; exit 1; fi
done
if [ -e /usr/local/snyk-broker ]; then echo "unexpected /usr/local/snyk-broker" >&2; exit 1; fi
'

- name: Run scaffold test - Go
run: |
cd scaffold && ./scaffold_test.sh go
Expand All @@ -79,81 +88,16 @@ jobs:
run: |
cd scaffold && ./scaffold_test.sh python

# The proxied case is the one that matters most: it is the only test
# that proves the agent's outbound gRPC dial works through an HTTP
# proxy via CONNECT, which is the deployment shape most customers
# actually have.
- name: "Run Relay Test: With Proxy (TLS)"
run: make -C agent relay-test-with-proxy

- name: "Run Relay Test: No Proxy"
run: make -C agent relay-test-no-proxy

# The same end-to-end scenarios as docker-tests, run over the gRPC tunnel
# instead of snyk-broker. Both transports share relay_scenarios.sh, so this
# is the same suite rather than a parallel copy that can drift — it already
# had once, silently losing the agent-endpoint and credential-injection
# checks, and with them a real gap where the tunnel never stamped
# x-axon-relay-instance on responses.
#
# A separate job rather than more steps on docker-tests: the two transports
# then fail independently, and a gRPC regression is legible from the job
# name without opening the log.
#
# This job is the CI pipeline for the go-only (-grpc) image: it builds that
# variant and runs only the gRPC E2E suite against it. The snyk-broker and
# scaffold tests stay on the full image in docker-tests.
docker-tests-grpc:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.26.11'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
make -C agent setup proto

- name: Build Agent Local Image (go-only)
run: |
make docker-build-grpc

- name: Verify go-only image
env:
IMAGE: cortex-axon-agent:local-grpc
run: |
# No Node runtime or snyk-broker may ship in this variant.
docker run --rm --entrypoint sh "$IMAGE" -c '
for b in node npm npx snyk-broker; do
if command -v "$b"; then echo "unexpected binary: $b" >&2; exit 1; fi
done
if [ -e /usr/local/snyk-broker ]; then echo "unexpected /usr/local/snyk-broker" >&2; exit 1; fi
'
# The transport is pinned in the binary, so an override must be refused.
if out=$(docker run --rm -e AXON_RELAY_TRANSPORT=snyk-broker "$IMAGE" relay -a pin-check 2>&1); then
echo "agent accepted AXON_RELAY_TRANSPORT=snyk-broker" >&2; exit 1
fi
echo "$out" | grep -q 'only supports AXON_RELAY_TRANSPORT=grpc-tunnel' \
|| { echo "$out" >&2; echo "expected the forced-relay-mode error" >&2; exit 1; }

# The proxied case is the one that matters most for this transport: it
# is the only test that proves the agent's outbound gRPC dial works
# through an HTTP proxy via CONNECT, which is the deployment shape most
# customers actually have.
- name: "Run gRPC Relay Test: With Proxy (TLS)"
env:
AXON_AGENT_IMAGE: cortex-axon-agent:local-grpc
run: make -C agent grpc-relay-test-with-proxy

- name: "Run gRPC Relay Test: No Proxy"
env:
AXON_AGENT_IMAGE: cortex-axon-agent:local-grpc
run: make -C agent grpc-relay-test-no-proxy

helm-test:
runs-on: ubuntu-latest
needs: test
Expand Down
45 changes: 10 additions & 35 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,20 @@
# Builds, publishes and scans one variant of the agent image. docker.yml calls
# this once per variant so both flavors share one build definition: a second
# inlined copy is how two images drift into one being scanned and the other
# not (see trivy-scan.yml).
# Builds, publishes and scans the agent image. docker.yml calls this.
name: Agent Image

on:
workflow_call:
inputs:
variant:
description: VARIANT build arg for docker/Dockerfile (full or grpc).
required: true
type: string
tags:
description: docker/metadata-action `tags` spec for this variant.
description: docker/metadata-action `tags` spec.
required: true
type: string
flavor:
description: docker/metadata-action `flavor` spec for this variant.
required: false
type: string
default: ''
build-args:
description: >-
Extra docker/Dockerfile build args, one KEY=value per line, e.g.
NODE_VERSION=22.
APT_CACHE_BUST=2026-12-01.
required: false
type: string
default: ''
suffix:
description: >-
Keeps this variant's PR artifact and SARIF category apart from the
full image's. Empty for the full image, so its scan history is
unchanged.
required: false
type: string
default: ''

# Each job states what it needs below.
permissions: {}

Expand Down Expand Up @@ -63,9 +42,9 @@ jobs:
uses: actions/cache@v5
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ inputs.variant }}-${{ github.sha }}
key: ${{ runner.os }}-buildx-agent-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-${{ inputs.variant }}-
${{ runner.os }}-buildx-agent-

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
Expand All @@ -81,7 +60,6 @@ jobs:
images: |
ghcr.io/${{ github.repository_owner }}/cortex-axon-agent
tags: ${{ inputs.tags }}
flavor: ${{ inputs.flavor }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
Expand All @@ -92,7 +70,6 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_VERSION=${{ github.ref_name }}-${{ github.sha }}
VARIANT=${{ inputs.variant }}
${{ inputs.build-args }}
# arm64 via QEMU is slow, so only build it on main branch or tags (not workflow_dispatch)
platforms: ${{ env.IS_ARM64_BUILD == 'true' && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
Expand All @@ -113,16 +90,14 @@ jobs:
if: env.IS_PUBLISH != 'true'
uses: actions/upload-artifact@v4
with:
name: docker-image${{ inputs.suffix }}
name: docker-image
path: /tmp/docker-image.tar
retention-days: 1

outputs:
image-tag: ${{ steps.local-tag.outputs.tag }}
# The primary tag metadata-action resolved -- the semver version on a
# tag build, the branch name on main. The go-only image publishes a
# single tag per release, <version>-grpc (0.3.11-grpc from v0.3.11 or
# v0.3.11-grpc), and main-grpc on main, so this is that tag. The release scan
# tag build, the branch name on main. The release scan
# targets this rather than a hardcoded :main, so a tag build reports on
# the image that tag actually published.
published-ref: ghcr.io/${{ github.repository_owner }}/cortex-axon-agent:${{ steps.meta.outputs.version }}
Expand All @@ -139,7 +114,7 @@ jobs:
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: docker-image${{ inputs.suffix }}
name: docker-image
path: /tmp

- name: Load Docker image
Expand All @@ -163,7 +138,7 @@ jobs:
# Matches the release scan's category so PR and post-merge findings
# for this image track one series instead of churning against
# each other in the Security tab.
category: trivy-cortex-axon-agent${{ inputs.suffix }}
category: trivy-cortex-axon-agent

# The bypass-trivy-fail label lets a PR merge past CVEs it did not
# introduce. The findings are still uploaded above and listed here.
Expand Down Expand Up @@ -195,5 +170,5 @@ jobs:
uses: ./.github/workflows/trivy-scan.yml
with:
image-ref: ${{ needs.build.outputs.published-ref }}
category: trivy-cortex-axon-agent${{ inputs.suffix }}
category: trivy-cortex-axon-agent
secrets: inherit
61 changes: 8 additions & 53 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ on:
permissions: {}

jobs:
# cortex-axon-agent:<tag> -- both relay transports (snyk-broker and grpc-tunnel).
# Skipped for a -grpc release tag: semver would read v0.3.10-grpc as a
# prerelease and publish the full image as 0.3.10-grpc.
full:
name: Agent image (full)
if: ${{ !(startsWith(github.ref, 'refs/tags/') && endsWith(github.ref, '-grpc')) }}
# cortex-axon-agent:<tag>
image:
name: Agent image
# A called workflow cannot hold a permission its caller did not grant:
# push to ghcr, and upload Trivy SARIF from both scan jobs.
permissions:
Expand All @@ -30,65 +27,23 @@ jobs:
security-events: write
uses: ./.github/workflows/docker-image.yml
with:
variant: full
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
secrets: inherit

# cortex-axon-agent:<version>-grpc -- go-only: no Node or snyk-broker, and the
# binary is pinned to AXON_RELAY_TRANSPORT=grpc-tunnel. Every release tag
# publishes it next to the full image: v0.3.11 publishes 0.3.11 (full) and
# 0.3.11-grpc. A v0.3.10-grpc tag publishes only this one, as 0.3.10-grpc,
# which lets a go-only build go out without re-releasing the others. A push
# to main publishes main-grpc. PRs build and scan it without publishing.
#
# Intermediate stage: once snyk-broker is fully deprecated, the full image
# becomes go-only and this variant (and every -grpc tag) collapses back into
# it.
grpc:
name: Agent image (go-only)
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
permissions:
contents: read
packages: write
security-events: write
uses: ./.github/workflows/docker-image.yml
with:
variant: grpc
# The optional (-grpc) group strips a -grpc tag's own suffix so the
# flavor suffix is not applied twice (0.3.10-grpc-grpc).
#
# latest-grpc moves with the full image's latest: only on a plain v*
# release tag. A one-off v*-grpc tag (often an older version) leaves it
# alone so it cannot roll latest-grpc backwards. latest=false turns off
# the auto latest, which would fire on both; onlatest makes the explicit
# one latest-grpc rather than overwriting the full image's latest.
tags: |
type=match,pattern=^v(.*?)(-grpc)?$,group=1
type=ref,event=branch
type=ref,event=pr
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-grpc') }}
flavor: |
latest=false
suffix=-grpc,onlatest=true
suffix: -grpc
secrets: inherit

# `build` is a required status check on main, named after the single job
# this workflow used to have. The image jobs above now report as
# "Agent image (full) / build" etc., so without this the required check
# never reports and every PR sits blocked. It passes only when every image
# job that ran passed; a job skipped by its `if` (e.g. full on a -grpc tag)
# does not count against it.
# this workflow used to have. The image job above reports as
# "Agent image / build" etc., so without this the required check never
# reports and every PR sits blocked.
build:
needs: [full, grpc]
needs: [image]
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: All agent images built
- name: Agent image built
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
run: |
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ jobs:
category: trivy-cortex-axon-agent
secrets: inherit

agent-grpc:
name: Agent image (go-only)
permissions:
contents: read
packages: read
security-events: write
uses: ./.github/workflows/trivy-scan.yml
with:
image-ref: ghcr.io/${{ github.repository_owner }}/cortex-axon-agent:main-grpc
category: trivy-cortex-axon-agent-grpc
secrets: inherit

tunnel-server:
name: Tunnel server image
permissions:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tunnel-load-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ jobs:
# pulling the images the image workflows already publish to ghcr.io, or
# driving the build through docker/bake-action with cache type=gha.

# Measured peak footprint is ~5GB: a 1.26GB agent image (it bundles Node
# for snyk-broker), a 126MB server image, ~1.2GB of base images and
# Measured peak footprint is ~5GB: a 1.26GB agent image (measured when
# it still bundled Node), a 126MB server image, ~1.2GB of base images and
# ~2.5GB of build cache, against the runner's 14GB. Printed so a disk
# failure is diagnosable from the log rather than a mystery.
- name: Report free disk
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- '**'
paths:
- 'agent/test/*.json'
- 'agent/server/snykbroker/accept_files/**'
- 'agent/server/acceptfile/accept_files/**'


jobs:
Expand Down
5 changes: 2 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"SCAFFOLD_DIR": "${workspaceFolder}/scaffold",
"SCAFFOLD_DOCKER_IMAGE": "cortex-axon-agent:local",
"PORT" : "7399",
"BUILTIN_PLUGIN_DIR": "${workspaceFolder}/agent/server/snykbroker/plugins",
"BUILTIN_PLUGIN_DIR": "${workspaceFolder}/agent/server/acceptfile/plugins",
"ENABLE_PPROF": "true"
}
},
Expand Down Expand Up @@ -118,8 +118,7 @@
"SCAFFOLD_DIR": "${workspaceFolder}/scaffold",
"SCAFFOLD_DOCKER_IMAGE": "cortex-axon-agent:local",
"PORT": "7399",
"BUILTIN_PLUGIN_DIR": "${workspaceFolder}/agent/server/snykbroker/plugins",
"RELAY_MODE": "grpc-tunnel",
"BUILTIN_PLUGIN_DIR": "${workspaceFolder}/agent/server/acceptfile/plugins",
"BROKER_SERVER_URL": "localhost:50052",
"BROKER_TOKEN": "4f49654b-000-0000-000-9deef1d9f2f6",
"CORTEX_TENANT_ID": "1",
Expand Down
4 changes: 0 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ Guidance for AI coding agents working in this repository.

- Never include customer names or identifiers, always anonymize references

# Architecture notes

- The snyk-broker component is always used in websocket mode. Data transport never uses long polling.

# Protocol compatibility

- Changes under `proto/` MUST be wire compatible in both directions. Tunnel servers and agents are deployed independently and run mixed versions, so existing functionality must never depend on which side is upgraded first.
Expand Down
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@ run-agent:
.PHONY: run-agent

DOCKER_TAG ?= cortex-axon-agent:local
# full or grpc (go-only, no Node); see the top of docker/Dockerfile.
DOCKER_VARIANT ?= full
# Extra `--build-arg`s, e.g. NODE_VERSION (see deps-full in docker/Dockerfile).
# Extra `--build-arg`s, e.g. APT_CACHE_BUST (see docker/Dockerfile).
DOCKER_BUILD_ARGS ?=

docker-build: docker/Dockerfile
docker build -t $(DOCKER_TAG) --build-arg VARIANT=$(DOCKER_VARIANT) $(DOCKER_BUILD_ARGS) --progress=plain -f $< .
docker build -t $(DOCKER_TAG) $(DOCKER_BUILD_ARGS) --progress=plain -f $< .
.PHONY: docker-build

docker-build-grpc:
$(MAKE) docker-build DOCKER_VARIANT=grpc DOCKER_TAG=cortex-axon-agent:local-grpc
.PHONY: docker-build-grpc

setup:
$(MAKE) -C agent setup

Expand Down
Loading
Loading