Skip to content

Commit 5037ec2

Browse files
committed
Merge remote-tracking branch 'origin/main' into k0s-1-29
2 parents 0223537 + 8fa8276 commit 5037ec2

File tree

117 files changed

+3842
-1915
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+3842
-1915
lines changed

.github/actions/e2e/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ runs:
113113
export EXPECT_K0S_VERSION_PREVIOUS=${{ inputs.k0s-version-previous }}
114114
export EXPECT_K0S_VERSION_PREVIOUS_STABLE=${{ inputs.k0s-version-previous-stable }}
115115
export EXPECT_EMBEDDED_CLUSTER_UPGRADE_TARGET_VERSION=${{ inputs.upgrade-target-ec-version }}
116+
export SKIP_LXD_CLEANUP=true
116117
make e2e-test TEST_NAME=${{ inputs.test-name }}
117118
- name: Troubleshoot
118119
if: ${{ !cancelled() }}

.github/workflows/ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: Lint
4242
uses: golangci/golangci-lint-action@v6
4343
with:
44-
args: --build-tags exclude_graphdriver_btrfs
44+
args: --build-tags containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper,exclude_graphdriver_overlay
4545

4646
test:
4747
name: Unit tests
@@ -73,14 +73,16 @@ jobs:
7373
steps:
7474
- name: Checkout
7575
uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 0
7678
- name: Setup go
7779
uses: actions/setup-go@v5
7880
with:
7981
go-version-file: go.mod
8082
cache-dependency-path: "**/*.sum"
8183
- name: Install kind
8284
run: |
83-
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.24.0/kind-linux-amd64
85+
curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.27.0/kind-linux-amd64
8486
chmod +x ./kind
8587
sudo mv ./kind /usr/local/bin/kind
8688
- name: Run tests
@@ -113,6 +115,8 @@ jobs:
113115
- name: Checkout
114116
uses: actions/checkout@v4
115117
- name: Make manifests
118+
env:
119+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116120
run: make -C operator manifests
117121
- name: Check CRDs
118122
run: |
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Container Security Scans
2+
# This workflow orchestrates security scanning of container images using Anchore scanner.
3+
# It runs nightly and can be triggered manually to scan various container images for vulnerabilities.
4+
name: Container Security Scans
5+
6+
# Trigger configuration
7+
on:
8+
schedule:
9+
- cron: '0 0 * * *' # Runs nightly at midnight (UTC)
10+
workflow_dispatch: # Allows manual triggering through GitHub UI
11+
12+
# Security hardening: Start with no permissions and grant only what's needed
13+
permissions: {} # Remove all permissions by default
14+
15+
# Prevent multiple workflow runs from interfering with each other
16+
# This ensures only one scan runs at a time and new triggers cancel old runs
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
# Get the latest release tag first
23+
get-latest-tag:
24+
name: Get Latest Release Tag
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read # Needed to read releases
28+
outputs:
29+
tag_name: ${{ steps.get_release.outputs.tag_name }}
30+
steps:
31+
- name: Get latest release
32+
id: get_release
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const release = await github.rest.repos.getLatestRelease({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo
39+
});
40+
core.setOutput('tag_name', release.data.tag_name);
41+
42+
# Scan operator image using latest release tag
43+
scan-operator:
44+
name: Scan Operator Image
45+
needs: get-latest-tag # Wait for tag to be fetched
46+
uses: ./.github/workflows/scan-container-image.yml
47+
# Grant required permissions to the reusable workflow
48+
permissions:
49+
contents: read # Needed to read workflow files
50+
security-events: write # Needed to upload SARIF results
51+
with:
52+
# Use the latest release tag from the previous job
53+
image: replicated/embedded-cluster-operator-image:${{ needs.get-latest-tag.outputs.tag_name }}
54+
# Report findings of medium severity or higher
55+
severity-cutoff: medium
56+
# Continue even if vulnerabilities are found
57+
fail-build: false
58+
# Specify platform to scan
59+
platform: linux/amd64
60+
61+
# Scan local artifact mirror image using latest release tag
62+
scan-registry:
63+
name: Scan Local Artifact Mirror Image
64+
needs: get-latest-tag # Wait for tag to be fetched
65+
uses: ./.github/workflows/scan-container-image.yml
66+
# Grant required permissions to the reusable workflow
67+
permissions:
68+
contents: read # Needed to read workflow files
69+
security-events: write # Needed to upload SARIF results
70+
with:
71+
# Use the latest release tag from the previous job
72+
image: replicated/embedded-cluster-local-artifact-mirror:${{ needs.get-latest-tag.outputs.tag_name }}
73+
# Report findings of medium severity or higher
74+
severity-cutoff: medium
75+
# Continue even if vulnerabilities are found
76+
fail-build: false
77+
# Specify platform to scan
78+
platform: linux/amd64
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# This is a reusable workflow for scanning container images using Anchore's vulnerability scanner.
2+
# It can be called from other workflows to scan any container image and report findings to GitHub Security tab.
3+
name: Scan Container Image
4+
5+
# Define this as a reusable workflow that other workflows can call
6+
on:
7+
workflow_call:
8+
# Define the inputs that callers must/can provide
9+
inputs:
10+
image:
11+
required: true
12+
type: string
13+
description: 'Container image to scan (format: image:tag)'
14+
severity-cutoff:
15+
required: false
16+
type: string
17+
default: 'medium'
18+
description: 'Minimum severity to report (critical, high, medium, low, negligible)'
19+
fail-build:
20+
required: false
21+
type: boolean
22+
default: false
23+
description: 'Fail the workflow if vulnerabilities are found'
24+
platform:
25+
required: false
26+
type: string
27+
default: 'linux/amd64'
28+
description: 'Platform to scan (e.g., linux/amd64, linux/arm64)'
29+
30+
permissions: {} # Remove all permissions by default
31+
32+
jobs:
33+
scan:
34+
name: Scan Image
35+
runs-on: ubuntu-latest
36+
timeout-minutes: 30 # Default timeout for the job
37+
# Permissions required for security scanning and reporting
38+
permissions:
39+
security-events: write # Needed to upload SARIF results
40+
contents: read # Needed to read workflow files
41+
42+
steps:
43+
# Extract and normalize image details for use in later steps
44+
# Handles cases where tag might be missing (defaults to 'latest')
45+
# Creates a safe name for use in filenames and categories
46+
- name: Extract image details
47+
id: image_details
48+
run: |
49+
IMAGE_NAME=$(echo "${{ inputs.image }}" | cut -d':' -f1)
50+
IMAGE_TAG=$(echo "${{ inputs.image }}" | cut -d':' -f2)
51+
[[ "$IMAGE_TAG" == "$IMAGE_NAME" ]] && IMAGE_TAG="latest"
52+
SAFE_NAME=$(echo "${IMAGE_NAME}-${IMAGE_TAG}" | sed 's/[\/:]/-/g')
53+
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
54+
echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT
55+
echo "safe_name=${SAFE_NAME}" >> $GITHUB_OUTPUT
56+
57+
# Run Anchore vulnerability scanner on the specified image
58+
# Outputs findings in SARIF format for GitHub security dashboard
59+
- name: Scan image with Anchore
60+
uses: anchore/scan-action@v6
61+
id: scan
62+
with:
63+
image: "${{ inputs.image }}"
64+
fail-build: ${{ inputs.fail-build }}
65+
severity-cutoff: ${{ inputs.severity-cutoff }}
66+
output-format: sarif
67+
platform: ${{ inputs.platform }}
68+
69+
# Enrich the SARIF output with additional metadata about the scanned image
70+
# This helps with tracking and identifying scan results in GitHub Security tab
71+
- name: Enrich SARIF with image metadata
72+
run: |
73+
# Install jq for JSON processing
74+
sudo apt-get update && sudo apt-get install -y jq
75+
76+
# Add metadata to SARIF using jq
77+
# This includes image details, scan time, and repository information
78+
jq --arg imageRef "${{ inputs.image }}" \
79+
--arg repo "${{ steps.image_details.outputs.image_name }}" \
80+
--arg name "${{ steps.image_details.outputs.image_name }}" \
81+
--arg tag "${{ steps.image_details.outputs.image_tag }}" \
82+
--arg scanTime "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
83+
--arg platform "${{ inputs.platform }}" \
84+
'.runs[0].properties = {
85+
"imageRef": $imageRef,
86+
"repository": $repo,
87+
"scanTime": $scanTime,
88+
"platform": $platform,
89+
"imageMetadata": {
90+
"name": $name,
91+
"tag": $tag
92+
}
93+
}' results.sarif > enriched-results.sarif
94+
95+
mv enriched-results.sarif results.sarif
96+
97+
# Upload the SARIF results to GitHub Security tab
98+
# Note: This uploads to the repository where the workflow runs, not the image source
99+
- name: Upload SARIF file
100+
uses: github/codeql-action/upload-sarif@v3
101+
with:
102+
sarif_file: results.sarif
103+
# Create a unique category for each image to separate findings
104+
category: "container-scan-${{ steps.image_details.outputs.safe_name }}"
105+
106+
# Archive the SARIF results as an artifact for later reference
107+
# Useful for debugging or historical analysis
108+
- name: Archive scan results
109+
uses: actions/upload-artifact@v4
110+
with:
111+
name: "sarif-${{ steps.image_details.outputs.safe_name }}"
112+
path: results.sarif
113+
retention-days: 365

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,20 +275,20 @@ envtest:
275275
.PHONY: unit-tests
276276
unit-tests: envtest
277277
KUBEBUILDER_ASSETS="$(shell ./operator/bin/setup-envtest use $(ENVTEST_K8S_VERSION) --bin-dir $(shell pwd)/operator/bin -p path)" \
278-
go test -tags exclude_graphdriver_btrfs -v ./pkg/... ./cmd/...
278+
go test -tags $(GO_BUILD_TAGS) -v ./pkg/... ./cmd/...
279279
$(MAKE) -C operator test
280280

281281
.PHONY: vet
282282
vet:
283-
go vet -tags exclude_graphdriver_btrfs ./...
283+
go vet -tags $(GO_BUILD_TAGS) ./...
284284

285285
.PHONY: e2e-tests
286286
e2e-tests: embedded-release
287-
go test -tags exclude_graphdriver_btrfs -timeout 60m -ldflags="$(LD_FLAGS)" -parallel 1 -failfast -v ./e2e
287+
go test -tags $(GO_BUILD_TAGS) -timeout 60m -ldflags="$(LD_FLAGS)" -parallel 1 -failfast -v ./e2e
288288

289289
.PHONY: e2e-test
290290
e2e-test:
291-
go test -tags exclude_graphdriver_btrfs -timeout 60m -ldflags="$(LD_FLAGS)" -v ./e2e -run ^$(TEST_NAME)$$
291+
go test -tags $(GO_BUILD_TAGS) -timeout 60m -ldflags="$(LD_FLAGS)" -v ./e2e -run ^$(TEST_NAME)$$
292292

293293
.PHONY: dryrun-tests
294294
dryrun-tests: export DRYRUN_MATCH = Test
@@ -312,11 +312,11 @@ clean:
312312

313313
.PHONY: lint
314314
lint:
315-
golangci-lint run -c .golangci.yml ./... --build-tags exclude_graphdriver_btrfs
315+
golangci-lint run -c .golangci.yml ./... --build-tags $(GO_BUILD_TAGS)
316316

317317
.PHONY: lint-and-fix
318318
lint-and-fix:
319-
golangci-lint run --fix -c .golangci.yml ./... --build-tags exclude_graphdriver_btrfs
319+
golangci-lint run --fix -c .golangci.yml ./... --build-tags $(GO_BUILD_TAGS)
320320

321321
.PHONY: scan
322322
scan:
@@ -329,7 +329,7 @@ scan:
329329

330330
.PHONY: buildtools
331331
buildtools:
332-
go build -tags exclude_graphdriver_btrfs -o ./output/bin/buildtools ./cmd/buildtools
332+
go build -tags $(GO_BUILD_TAGS) -o ./output/bin/buildtools ./cmd/buildtools
333333

334334
.PHONY: list-distros
335335
list-distros:

cmd/buildtools/k0s.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ var k0sImageComponents = map[string]addonComponent{
7676
return fmt.Sprintf("registry.k8s.io/pause:%s", opts.upstreamVersion.Original()), nil
7777
},
7878
},
79+
"quay.io/k0sproject/envoy-distroless": {
80+
name: "envoy-distroless",
81+
getWolfiPackageName: func(opts addonComponentOptions) string {
82+
return fmt.Sprintf("envoy-%d.%d", opts.upstreamVersion.Major(), opts.upstreamVersion.Minor())
83+
},
84+
},
7985
}
8086

8187
var updateK0sImagesCommand = &cli.Command{

cmd/buildtools/utils.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"bufio"
5+
"bytes"
56
"context"
67
"errors"
78
"fmt"
@@ -145,10 +146,12 @@ func ResolveApkoPackageVersion(componentName, packageName, packageVersion string
145146
fmt.Sprintf("PACKAGE_NAME=%s", packageName),
146147
fmt.Sprintf("PACKAGE_VERSION=%s", packageVersion),
147148
}
149+
var errBuf bytes.Buffer
148150
cmd := exec.Command("make", args...)
151+
cmd.Stderr = &errBuf
149152
out, err := cmd.Output()
150153
if err != nil {
151-
return "", fmt.Errorf("run command: %w: %s", err, string(out))
154+
return "", fmt.Errorf("run command: %w: %s", err, errBuf.String())
152155
}
153156
return strings.TrimSpace(string(out)), nil
154157
}

0 commit comments

Comments
 (0)