diff --git a/.commitlintrc.json b/.commitlintrc.json new file mode 100644 index 0000000..7e3f1cf --- /dev/null +++ b/.commitlintrc.json @@ -0,0 +1,13 @@ +{ + "extends": ["@commitlint/config-conventional"], + "rules": { + "subject-case": [ + 1, + "never", + ["sentence-case", "start-case", "pascal-case", "upper-case"] + ], + "header-max-length": [1, "always", 100], + "body-max-line-length": [1, "always", 100], + "footer-max-line-length": [1, "always", 100] + } +} diff --git a/.devcontainer/devcontainer-lock.json b/.devcontainer/devcontainer-lock.json new file mode 100644 index 0000000..facd626 --- /dev/null +++ b/.devcontainer/devcontainer-lock.json @@ -0,0 +1,24 @@ +{ + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "version": "2.7.2", + "resolved": "ghcr.io/devcontainers/features/common-utils@sha256:08e5a6ad4b672301c2010944217aeea4f428a87f4349d9bbf8bc97211238674b", + "integrity": "sha256:08e5a6ad4b672301c2010944217aeea4f428a87f4349d9bbf8bc97211238674b" + }, + "ghcr.io/devcontainers/features/docker-in-docker:4": { + "version": "4.1.3", + "resolved": "ghcr.io/devcontainers/features/docker-in-docker@sha256:fae40f3c8be5a7c3b0db344c1d30341bc2c91ba38d1d5b14cd2ad72e6d65d084", + "integrity": "sha256:fae40f3c8be5a7c3b0db344c1d30341bc2c91ba38d1d5b14cd2ad72e6d65d084" + }, + "ghcr.io/devcontainers/features/github-cli:1": { + "version": "1.1.3", + "resolved": "ghcr.io/devcontainers/features/github-cli@sha256:bd7ab48a832228f633239277552c30b353867fef2e5b037e064b4e64f0b843f2", + "integrity": "sha256:bd7ab48a832228f633239277552c30b353867fef2e5b037e064b4e64f0b843f2" + }, + "ghcr.io/devcontainers/features/go:1": { + "version": "1.4.1", + "resolved": "ghcr.io/devcontainers/features/go@sha256:2f2ed290df9a5f1841340b14cb8a287cf0574a816967dd84dcfe42fdd97b897e", + "integrity": "sha256:2f2ed290df9a5f1841340b14cb8a287cf0574a816967dd84dcfe42fdd97b897e" + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..b5a2bcd --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,33 @@ +{ + "name": "hoverkraft-tech/http-header-authenticator", + "image": "mcr.microsoft.com/devcontainers/base:debian@sha256:41ff7ce12ec45f2704f27a6e091831186ad922ec8112e6339425bfefdf5a70f9", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "configureZshAsDefaultShell": true + }, + "ghcr.io/devcontainers/features/docker-in-docker:4": { + "moby": false + }, + "ghcr.io/devcontainers/features/github-cli:1": {}, + "ghcr.io/devcontainers/features/go:1": { + "version": "1.27.4", + "golangciLintVersion": "2.15.0" + } + }, + "remoteUser": "vscode", + "init": true, + "postCreateCommand": "make setup", + "waitFor": "postCreateCommand", + "customizations": { + "vscode": { + "extensions": [ + "eamodio.gitlens", + "github.vscode-github-actions", + "ms-vscode.makefile-tools", + "redhat.vscode-yaml", + "golang.Go" + ], + "settings": {} + } + } +} diff --git a/.dockerignore b/.dockerignore index c5ca512..2491ea7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -35,4 +35,6 @@ helm .golangci.yml coverage.out Makefile -skaffold.yaml +/.devcontainer +/super-linter-output +/super-linter.log diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..db7df72 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 2 + +[*.py] +indent_size = 4 + +[*.go] +indent_style = tab + +[Makefile] +indent_style = tab diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 1515c59..103452c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,9 +1,10 @@ --- name: Bug report about: Create a report to help us improve - --- +# Bug report + **Describe the bug** A clear and concise description of what the bug is. @@ -17,7 +18,8 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Kubernetes (please complete the following information):** - - Kubernetes version [`kubectl version --short`] + +- Kubernetes version [`kubectl version --short`] **HRE pod logs** `kubectl logs hre-xxxxxxx` diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 066b2d9..2a9953c 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,9 +1,10 @@ --- name: Feature request about: Suggest an idea for this project - --- +# Feature request + **Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 993cdfc..9d0e73a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,39 +1,63 @@ -# .github/dependabot.yml +--- version: 2 updates: - - - package-ecosystem: "github-actions" - directory: "/" - open-pull-requests-limit: 20 + - package-ecosystem: github-actions + directory: / + commit-message: + prefix: build + include: scope + cooldown: + default-days: 7 + open-pull-requests-limit: 10 + schedule: + interval: weekly + day: friday + time: "04:00" groups: github-actions-dependencies: - patterns: - - '*' + patterns: ["*"] + - package-ecosystem: gomod + directory: / + commit-message: + prefix: build + include: scope + cooldown: + default-days: 7 + open-pull-requests-limit: 10 schedule: - interval: "weekly" + interval: weekly day: friday - time: '04:00' - - - package-ecosystem: "docker" - directory: "/" - open-pull-requests-limit: 20 + time: "04:10" groups: - docker-dependencies: - patterns: - - '*' + gomod-dependencies: + patterns: ["*"] + - package-ecosystem: docker + directories: ["/", "/.github/linters"] + commit-message: + prefix: build + include: scope + cooldown: + default-days: 7 + open-pull-requests-limit: 10 schedule: - interval: "weekly" + interval: weekly day: friday - time: '04:10' - - - package-ecosystem: "gomod" - directory: "/" - open-pull-requests-limit: 20 + time: "04:20" groups: - go-dependencies: - patterns: - - '*' + docker-dependencies: + patterns: ["*"] + - package-ecosystem: devcontainers + directory: / + commit-message: + prefix: build + include: scope + cooldown: + default-days: 7 + open-pull-requests-limit: 10 schedule: - interval: "weekly" + interval: weekly day: friday - time: '04:20' + time: "04:30" + groups: + devcontainers-dependencies: + patterns: ["*"] diff --git a/.github/linters/.checkov.yaml b/.github/linters/.checkov.yaml new file mode 100644 index 0000000..a012a12 --- /dev/null +++ b/.github/linters/.checkov.yaml @@ -0,0 +1,6 @@ +--- +quiet: true +# Supply the required synthetic authentication value so Checkov can render and scan the chart. +# This is a Helm values input, not a scan exclusion. +var-file: + - helm/chart/ci/default-values.yaml diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml new file mode 100644 index 0000000..07b34f1 --- /dev/null +++ b/.github/linters/.yaml-lint.yml @@ -0,0 +1,14 @@ +--- +extends: default +rules: + line-length: + max: 160 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + truthy: + check-keys: false + comments: + min-spaces-from-content: 1 +# Helm templates are validated after rendering by the chart and security checks. +ignore: | + **/helm/chart/templates/** diff --git a/.github/linters/Dockerfile b/.github/linters/Dockerfile new file mode 100644 index 0000000..e7515af --- /dev/null +++ b/.github/linters/Dockerfile @@ -0,0 +1,7 @@ +# TODO: pin the release of https://github.com/hoverkraft-tech/docker-base-images/pull/310. +FROM ghcr.io/hoverkraft-tech/docker-base-images/super-linter:pr-310-b5fda05@sha256:c78bd0f4672ce61fc393d4081d15dcf41002d9b4455e35723c1644c007da522b + +ARG UID=1000 +ARG GID=1000 +USER ${UID}:${GID} +HEALTHCHECK --interval=5m --timeout=10s --start-period=30s --retries=3 CMD ["/bin/sh", "-c", "test -d /github/home"] diff --git a/.github/linters/actionlint.yml b/.github/linters/actionlint.yml new file mode 100644 index 0000000..c629978 --- /dev/null +++ b/.github/linters/actionlint.yml @@ -0,0 +1,16 @@ +# FIXME: Remove this scoped exception when Actionlint supports code-quality. +# https://github.com/rhysd/actionlint/pull/674 + +paths: + .github/workflows/__shared-ci.yml: + ignore: + - ^unknown permission scope "code-quality"\. + .github/workflows/main-ci.yml: + ignore: + - ^unknown permission scope "code-quality"\. + .github/workflows/pull-request-ci.yml: + ignore: + - ^unknown permission scope "code-quality"\. + .github/workflows/release.yml: + ignore: + - ^unknown permission scope "code-quality"\. diff --git a/.github/linters/trivy-data/registries.yaml b/.github/linters/trivy-data/registries.yaml new file mode 100644 index 0000000..b12c6de --- /dev/null +++ b/.github/linters/trivy-data/registries.yaml @@ -0,0 +1,6 @@ +--- +# Project images are published to Docker Hub and GitHub Container Registry. +ksv0125: + trusted_registries: + - docker.io + - ghcr.io diff --git a/.github/linters/trivy.yaml b/.github/linters/trivy.yaml new file mode 100644 index 0000000..29e011e --- /dev/null +++ b/.github/linters/trivy.yaml @@ -0,0 +1,16 @@ +--- +exit-code: 1 +exit-on-eol: 2 +scan: + disable-telemetry: true + scanners: + - vuln + - misconfig + - secret +misconfiguration: + helm: + values: + - helm/chart/ci/default-values.yaml +rego: + data: + - .github/linters/trivy-data diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..1641c3f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +# Pull request + +## Change + +Describe the problem and resulting behavior. + +## Validation + +List the checks run and any behavior that still needs verification. diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 8334d0d..0000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,74 +0,0 @@ -template: | - # What's Changed - $CHANGES - **Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...$RESOLVED_VERSION -name-template: "Version $RESOLVED_VERSION" -tag-template: "$RESOLVED_VERSION" - -categories: - - title: '๐Ÿš€ Features' - labels: - - 'feature' - - 'feat' - - title: '๐Ÿ› Bug Fixes' - labels: - - 'fix' - - 'bugfix' - - 'bug' - - title: '๐Ÿงฐ Maintenance' - label: 'chore' - - title: '๐Ÿ“š Documentation' - label: 'docs' - - title: '๐Ÿงช Tests' - label: 'test' - - title: '๐Ÿท๏ธ Version Tags' - label: 'version' - - title: '๐Ÿ”– Release Tags' - label: 'release' - - title: '๐Ÿงฉ Dependencies' - label: 'dependencies' - - title: '๐Ÿ”’ Security' - label: 'security' - - title: '๐Ÿšจ Breaking Changes' - label: 'breaking' - - title: '๐Ÿงน Code Cleanup' - label: 'cleanup' - - title: '๐Ÿ”ง Config' - label: 'config' - - title: '๐Ÿ“ฆ Packages' - label: 'package' - - title: '๐Ÿ”ฅ Removals' - label: 'removal' - - title: '๐Ÿšง Work In Progress' - label: 'wip' - - title: '๐Ÿ”€ Merges' - label: 'merge' - - title: '๐ŸŽจ Style' - label: 'style' - - title: '๐Ÿ”Š Logging' - label: 'logging' - - title: '๐Ÿ”‡ Silence' - label: 'silence' - - title: '๐Ÿค– CI/CD' - label: 'ci' - -version-resolver: - major: - labels: - - "release-major" - minor: - labels: - - "release-minor" - patch: - labels: - - "release-patch" - default: patch - -autolabeler: - - label: "release-major" - title: - - "/^BREAKING CHANGE:/" - - label: "release-minor" - title: - - "/^feat:/" - - "/^feat\\(.+\\):/" diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..f80a29c --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,66 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended"], + "enabledManagers": ["custom.regex", "gomod", "asdf"], + "semanticCommits": "enabled", + "semanticCommitType": "build", + "minimumReleaseAge": "7 days", + "customManagers": [ + { + "customType": "regex", + "managerFilePatterns": ["/^\\.devcontainer/devcontainer\\.json$/"], + "matchStrings": [ + "\"ghcr.io/devcontainers/features/go:1\":\\s*\\{\\s*\"version\":\\s*\"(?[0-9.]+)\"" + ], + "datasourceTemplate": "golang-version", + "depNameTemplate": "go" + }, + { + "customType": "regex", + "managerFilePatterns": ["/^\\.devcontainer/devcontainer\\.json$/"], + "matchStrings": [ + "\"golangciLintVersion\":\\s*\"(?[0-9.]+)\"" + ], + "datasourceTemplate": "github-releases", + "depNameTemplate": "golangci/golangci-lint" + }, + { + "customType": "regex", + "managerFilePatterns": ["/^Makefile$/"], + "matchStrings": [ + "golang.org/x/vuln/cmd/govulncheck@(?v[0-9.]+)" + ], + "datasourceTemplate": "go", + "depNameTemplate": "golang.org/x/vuln" + }, + { + "customType": "regex", + "managerFilePatterns": ["/^Makefile$/"], + "matchStrings": [ + "GOSS_IMAGE := (?[^\\s:]+):(?[^\\s@]+)@(?sha256:[a-f0-9]{64})" + ], + "datasourceTemplate": "docker", + "versioningTemplate": "docker" + } + ], + "packageRules": [ + { + "description": "Dependabot owns Go module dependencies and minimum Go requirements.", + "matchManagers": ["gomod"], + "enabled": false + }, + { + "description": "Only the explicit compiler toolchain is maintained by Renovate.", + "matchManagers": ["gomod"], + "matchDepTypes": ["toolchain"], + "enabled": true, + "groupName": "Go toolchain" + }, + { + "description": "Maintain the Helm CLI in .tool-versions; chart dependencies belong to Dependabot.", + "matchManagers": ["asdf"], + "matchDepNames": ["!helm"], + "enabled": false + } + ] +} diff --git a/.github/workflows/__checks.yml b/.github/workflows/__checks.yml new file mode 100644 index 0000000..72f9967 --- /dev/null +++ b/.github/workflows/__checks.yml @@ -0,0 +1,137 @@ +--- +name: Internal - CI checks + +on: + workflow_call: + inputs: + candidate-images: + description: Build temporary candidate images for release validation + type: boolean + default: false + outputs: + chart-helm-set: + description: Installation overrides for the validated immutable image + value: ${{ jobs.test-image.outputs.helm-set }} + job-results: + description: Build and validation results for promotion + value: ${{ toJSON(jobs) }} + +permissions: {} + +jobs: + lint: + name: Repository quality + uses: hoverkraft-tech/ci-github-common/.github/workflows/linter.yml@68fd463bb94cf9f7dc1db68d190cf57af3dfa8ca # PR #700 (unreleased) + permissions: + actions: read + contents: read + issues: write + packages: read + pull-requests: write + security-events: write + statuses: write + with: + # Keep the repository-managed CodeQL default setup for Go. + codeql-languages: "" + + test: + name: Go checks and coverage + # TODO: Replace this candidate pin with a released SHA after https://github.com/hoverkraft-tech/ci-github-go/pull/14 + uses: hoverkraft-tech/ci-github-go/.github/workflows/continuous-integration.yml@388094568fd032e8745c061821d3f94ff9f791ad # PR #14 (unreleased) + permissions: + actions: read + contents: read + id-token: write + + docker-build-images: + name: "Docker: Build Images" + needs: [lint, test] + uses: hoverkraft-tech/ci-github-container/.github/workflows/docker-build-images.yml@a5dc1ea7c1f4c2dffc3267c5be7304d01284f2ec # 4.2.1 + permissions: + attestations: write + actions: read + contents: read + id-token: write + issues: read + packages: write + pull-requests: read + secrets: + oci-registry-password: ${{ secrets.GITHUB_TOKEN }} + with: + candidate: ${{ inputs.candidate-images }} + images: | + [{ + "name": "app", + "dockerfile": "./Dockerfile", + "platforms": [ + "linux/amd64", + "linux/arm64" + ] + }] + test-image: + strategy: + fail-fast: false + matrix: + include: + - platform: linux/amd64 + runner: ubuntu-latest + - platform: linux/arm64 + runner: ubuntu-24.04-arm + name: Test container authentication + needs: docker-build-images + runs-on: ${{ matrix.runner }} + permissions: + actions: read + contents: read + packages: read + outputs: + validated-images: ${{ needs.docker-build-images.outputs.built-images }} + helm-set: ${{ steps.image.outputs.helm-set }} + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: hoverkraft-tech/ci-github-container/actions/docker/setup@3a669abdd308f05e7f43e16b57f0d40bed555969 # PR #1003 (unreleased) + with: + setup-buildx: "false" + oci-registry-username: ${{ github.actor }} + oci-registry-password: ${{ github.token }} + - name: Test the production image on each published platform + uses: hoverkraft-tech/ci-github-container/actions/docker/test-image@3a669abdd308f05e7f43e16b57f0d40bed555969 # PR #1003 (unreleased) + with: + image: ${{ fromJSON(needs.docker-build-images.outputs.built-images).app.images[0] }} + working-directory: tests/container-image + platform: ${{ matrix.platform }} + + - name: Map the validated digest into chart values + id: image + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + env: + BUILT_IMAGES: ${{ needs.docker-build-images.outputs.built-images }} + with: + script: | + const { images, digest } = JSON.parse(process.env.BUILT_IMAGES).app; + const reference = images[0].split('@')[0]; + const separator = reference.lastIndexOf(':'); + if (separator <= reference.lastIndexOf('/') || !/^sha256:[a-f0-9]{64}$/.test(digest)) { + throw new Error('Expected a tagged image with an immutable digest'); + } + core.setOutput('helm-set', [ + 'securityHeader.value=ci-test-value', + `image.repository=${reference.slice(0, separator)}`, + `image.tag=${reference.slice(separator + 1)}@${digest}`, + 'imagePullSecrets[0].name=regcred', + ].join('\n')); + + chart-testing: + name: Test chart with the validated image + needs: [docker-build-images, test-image] + uses: hoverkraft-tech/ci-github-container/.github/workflows/helm-chart-ci.yml@a5dc1ea7c1f4c2dffc3267c5be7304d01284f2ec # 4.2.1 + permissions: + contents: read + packages: read + with: + path: helm/chart + config: ct.yaml + images: ${{ needs.docker-build-images.outputs.built-images }} + helm-set: ${{ needs.test-image.outputs.helm-set }} diff --git a/.github/workflows/__renovate.yml b/.github/workflows/__renovate.yml new file mode 100644 index 0000000..f4244a3 --- /dev/null +++ b/.github/workflows/__renovate.yml @@ -0,0 +1,39 @@ +--- +name: Internal - Renovate dependency updates +permissions: {} +concurrency: + group: ${{ github.workflow }} + cancel-in-progress: false +jobs: + renovate: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - name: Generate GitHub App token + id: generate-token + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0 + with: + client-id: ${{ vars.CI_BOT_APP_CLIENT_ID }} + private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }} + permission-checks: read + permission-contents: write + permission-issues: write + permission-pull-requests: write + permission-statuses: write + permission-workflows: write + - name: Run Renovate + uses: renovatebot/github-action@acdd6bda8b035c99ce59d5675816af2aa65a1774 # v46.3.14 + with: + token: ${{ steps.generate-token.outputs.token }} + env: + RENOVATE_PLATFORM: github + RENOVATE_REPOSITORIES: ${{ github.repository }} + RENOVATE_ONBOARDING: "false" + RENOVATE_REQUIRE_CONFIG: required + RENOVATE_USERNAME: ${{ steps.generate-token.outputs.app-slug }}[bot] + RENOVATE_PLATFORM_COMMIT: enabled + if: vars.CI_BOT_APP_CLIENT_ID != '' +"on": + workflow_dispatch: null + schedule: + - cron: 23 4 * * 5 diff --git a/.github/workflows/__shared-ci.yml b/.github/workflows/__shared-ci.yml index 3208f06..3311fcc 100644 --- a/.github/workflows/__shared-ci.yml +++ b/.github/workflows/__shared-ci.yml @@ -1,141 +1,61 @@ +--- name: Internal - Common Continuous Integration tasks on: workflow_call: inputs: - tag: - description: "Tag Version (semver - x.x.x)" - type: string - required: false + candidate-images: + description: Build temporary candidate images for release validation + type: boolean + default: false outputs: - built-images: - value: ${{ jobs.docker-build-images.outputs.built-images }} + chart-helm-set: + description: Installation overrides for the validated immutable image + value: ${{ jobs.checks.outputs.chart-helm-set }} + job-results: + description: Build and validation results for promotion + value: ${{ jobs.checks.outputs.job-results }} -jobs: - - golangci-lint: - name: "Go: Lint" - runs-on: self-hosted - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - uses: actions/setup-go@v5.0.0 - with: - go-version: '1.21' - - name: Run linters - uses: golangci/golangci-lint-action@v4 - with: - version: v1.54 - - go-test: - name: "Go: Test" - strategy: - matrix: - go-version: ['1.21'] - platform: [self-hosted] - runs-on: ${{ matrix.platform }} - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - if: success() - uses: actions/setup-go@v5.0.0 - with: - go-version: ${{ matrix.go-version }} - - name: Run tests - run: go test ./... -v -covermode=count - - go-coverage: - name: "Go: Coverage" - runs-on: self-hosted - steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Install Go - if: success() - uses: actions/setup-go@v5.0.0 - with: - go-version: '1.21' - - name: Calc coverage - run: | - go test ./... -v -covermode=count -coverprofile=coverage.out - - name: Convert coverage.out to coverage.lcov - uses: jandelgado/gcov2lcov-action@v1.0.9 - with: - version: v1.0.6 - - name: Coveralls - uses: coverallsapp/github-action@v2.2.3 - with: - github-token: ${{ secrets.github_token }} - file: coverage.lcov - allow-empty: true - - chart-testing: - name: "Helm: Chart Testing" - runs-on: self-hosted - steps: - - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # Install tools with asdf - - name: Install tools with asdf - uses: asdf-vm/actions/install@v3 - - - uses: actions/setup-python@v5 - with: - python-version: '3.9' - check-latest: true - - - name: Set up chart-testing - uses: helm/chart-testing-action@v2.6.1 - - - name: Run chart-testing (list-changed) - id: list-changed - run: | - changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) - if [[ -n "$changed" ]]; then - echo "changed=true" >> "$GITHUB_OUTPUT" - fi - - - name: Run chart-testing (lint) - if: steps.list-changed.outputs.changed == 'true' - run: ct lint --target-branch ${{ github.event.repository.default_branch }} +permissions: {} - - name: Create kind cluster - if: steps.list-changed.outputs.changed == 'true' - uses: helm/kind-action@v1.9.0 - - - name: Run chart-testing (install) - if: steps.list-changed.outputs.changed == 'true' - run: ct install --target-branch ${{ github.event.repository.default_branch }} - - docker-build-images: - name: "Docker: Build Images" - needs: [golangci-lint, go-test, go-coverage, chart-testing] - uses: hoverkraft-tech/ci-github-container/.github/workflows/docker-build-images.yml@0.15.1 +jobs: + checks: + uses: $/.github/workflows/__checks.yml permissions: - actions: write + actions: read contents: read - id-token: write - issues: read + issues: write packages: write - pull-requests: read - secrets: - oci-registry-password: ${{ secrets.GITHUB_TOKEN }} + pull-requests: write + security-events: write + statuses: write + id-token: write + attestations: write + with: + candidate-images: ${{ inputs.candidate-images }} + reports: + if: always() + needs: checks + uses: hoverkraft-tech/ci-github-common/.github/workflows/publish-ci-reports.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0 + permissions: + actions: read + contents: read + pull-requests: write + code-quality: write + id-token: write + security-events: write + with: + job-results: ${{ needs.checks.outputs.job-results || toJSON(needs) }} + test-coverage-reporters: | + auto + coveralls + complete: + name: CI complete + if: always() + needs: + - checks + - reports + uses: hoverkraft-tech/ci-github-common/.github/workflows/check-jobs.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0 + permissions: {} with: - runs-on: '["self-hosted"]' - oci-registry: "ghcr.io" - images: | - [{ - "name": "app", - "tag": "${{ inputs.tag }}", - "dockerfile": "./Dockerfile", - "platforms": [ - "linux/amd64", - "linux/arm64" - ] - }] + job-results: ${{ toJSON(needs) }} diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml index b9af944..5079c33 100644 --- a/.github/workflows/main-ci.yml +++ b/.github/workflows/main-ci.yml @@ -1,23 +1,35 @@ +--- name: Main - Continuous Integration on: + workflow_dispatch: + schedule: + - cron: "25 8 * * 1" push: branches: - main -permissions: - contents: read +# jscpd:ignore-start +# GitHub requires permissions and the shared-workflow call in each event entrypoint. +permissions: {} -jobs: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: ci: name: Continuous Integration - uses: ./.github/workflows/__shared-ci.yml + uses: $/.github/workflows/__shared-ci.yml permissions: - actions: write + code-quality: write + attestations: write + actions: read contents: read id-token: write - issues: read + issues: write packages: write - pull-requests: read - secrets: inherit + pull-requests: write + security-events: write + statuses: write +# jscpd:ignore-end diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..07d024f --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,19 @@ +--- +name: Prepare release + +on: + pull_request: + types: [opened, reopened, synchronize, edited] + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + release: + uses: hoverkraft-tech/ci-github-publish/.github/workflows/prepare-release.yml@bf24f894f60a3def62a8750f3964d05acb052c11 # 3.1.2 + permissions: + contents: read + pull-requests: write diff --git a/.github/workflows/pull-request-ci.yml b/.github/workflows/pull-request-ci.yml index bf5ee4a..2b7fc14 100644 --- a/.github/workflows/pull-request-ci.yml +++ b/.github/workflows/pull-request-ci.yml @@ -1,33 +1,30 @@ +--- name: Pull request - Continuous Integration on: + merge_group: pull_request: branches: - main -jobs: +permissions: {} - pull-request-labeler: - name: Pull request labeler - runs-on: self-hosted - permissions: - contents: write - pull-requests: write - steps: - - uses: release-drafter/release-drafter@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - disable-releaser: true +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: ci: name: Continuous Integration - uses: ./.github/workflows/__shared-ci.yml + uses: $/.github/workflows/__shared-ci.yml permissions: - actions: write + code-quality: write + attestations: write + actions: read contents: read id-token: write - issues: read + issues: write packages: write - pull-requests: read - secrets: inherit + pull-requests: write + security-events: write + statuses: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9717db2..052007d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,104 +1,107 @@ -name: ๐Ÿš€ Release +--- +# Prepare committed chart versions, validate the dispatched tag, then publish. +name: Release on: + # checkov:skip=CKV_GHA_7:Force overrides only the no-change plan, never validation or publication checks. workflow_dispatch: + inputs: + force: + description: Release even without changes + type: boolean + default: false + schedule: + - cron: "25 8 * * 1" + +permissions: {} + +concurrency: + group: release-${{ github.repository }} + cancel-in-progress: false jobs: - check-branches: - name: Check branches - runs-on: self-hosted - steps: - - name: Check branch - run: | - if [[ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]]; then - echo "This action can only be run on the ${{ github.event.repository.default_branch }} branch" - exit 1 - fi + prepare: + uses: hoverkraft-tech/ci-github-container/.github/workflows/prepare-chart-release.yml@a5dc1ea7c1f4c2dffc3267c5be7304d01284f2ec # 4.2.1 + permissions: + actions: write + contents: write + pull-requests: read + with: + path: helm/chart + update-app-version: true + force: ${{ github.event_name == 'workflow_dispatch' && inputs.force }} + github-app-client-id: ${{ vars.CI_BOT_APP_CLIENT_ID }} + secrets: + github-app-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }} - ci: - needs: check-branches - name: Continuous Integration - uses: ./.github/workflows/__shared-ci.yml + validate: + needs: prepare + if: needs.prepare.outputs.status == 'ready' + uses: $/.github/workflows/__shared-ci.yml permissions: + code-quality: write + actions: read + attestations: write contents: read id-token: write - issues: read + issues: write packages: write - pull-requests: read - - update_release_draft: - name: Draft a new release - # we want to publish a new tag only if ci succeeds - needs: ci - permissions: - contents: write pull-requests: write - runs-on: self-hosted - steps: - - id: update_release_draft - uses: release-drafter/release-drafter@v6 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - publish: true - disable-autolabeler: true + security-events: write + statuses: write + with: + candidate-images: true - - uses: docker/login-action@v3 - with: - registry: "ghcr.io" - username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} - - - uses: docker/login-action@v3 - with: - registry: "docker.io" - username: ${{ secrets.DOCKERHUB_REGISTRY_USER }} - password: ${{ secrets.DOCKERHUB_REGISTRY_PASSWORD }} + promote: + needs: [prepare, validate] + # TODO: Replace this candidate pin with a released SHA after https://github.com/hoverkraft-tech/ci-github-container/pull/1001 + uses: hoverkraft-tech/ci-github-container/.github/workflows/docker-promote-images.yml@c9feed706862fc88f0fd33d287e6d6c12e738f74 # PR #1001 (unreleased) + permissions: + actions: read + attestations: read + contents: read + deployments: write + packages: write + pull-requests: read + with: + job-results: ${{ needs.validate.outputs.job-results }} + additional-destinations: | + {"app":["docker.io/webofmars/http-header-authenticator:${{ needs.prepare.outputs.tag }}"]} + secrets: + oci-registry-password: ${{ secrets.GITHUB_TOKEN }} + destination-credentials: | + {"docker.io":{ + "username":${{ toJSON(vars.DOCKERHUB_REGISTRY_USERNAME) }}, + "password":${{ toJSON(secrets.DOCKERHUB_REGISTRY_PASSWORD) }} + }} - - name: Push built images to Docker.io - run: | - APP_IMAGE="${{ fromJson(needs.ci.outputs.built-images).app.images[0] }}" - docker pull "$APP_IMAGE" - APP_TAG="${{ steps.update_release_draft.outputs.tag_name }}" - APP_REGISTRY_PATH="docker.io/webofmars" - APP_DOCKERIO_IMAGE="${APP_REGISTRY_PATH}/http-header-authenticator:$APP_TAG" - docker tag "$APP_IMAGE" "$APP_DOCKERIO_IMAGE" - docker push "$APP_DOCKERIO_IMAGE" + release-chart: + needs: [prepare, validate, promote] + uses: hoverkraft-tech/ci-github-container/.github/workflows/helm-chart-release.yml@a5dc1ea7c1f4c2dffc3267c5be7304d01284f2ec # 4.2.1 + permissions: + contents: read + packages: write + id-token: write + with: + path: helm/chart + config: ct.yaml + helm-set: ${{ needs.validate.outputs.chart-helm-set }} + runs-on: '["self-hosted"]' + oci-registry: harbor.hoverkraft.cloud + oci-repository: public/charts + secrets: + oci-registry-username: ${{ secrets.HARBOR_REGISTRY_USER }} + oci-registry-password: ${{ secrets.HARBOR_REGISTRY_PASSWORD }} - helm-push: - name: "Helm: push chart to harbor registry" - needs: ci - runs-on: self-hosted + release: + needs: [prepare, release-chart] + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: read steps: - # Get a local copy of the code - - uses: actions/checkout@v4 - - # install tools with asdf - - name: ๐Ÿ“ฆ Install tools with asdf - uses: asdf-vm/actions/install@v3 - - # login to harbor repo - - name: ๐Ÿ”’ Login to harbor repo - run: | - echo "+ login to harbor OCI registry" - helm registry login ${HARBOR_REGISTRY} -u "${HARBOR_REGISTRY_USER}" -p "${HARBOR_REGISTRY_PASSWORD}" - env: - HARBOR_REGISTRY_USER: ${{ secrets.HARBOR_REGISTRY_USER }} - HARBOR_REGISTRY_PASSWORD: ${{ secrets.HARBOR_REGISTRY_PASSWORD }} - HARBOR_REGISTRY: harbor.hoverkraft.cloud - - # Push the chart - - name: โš“ Push Helm Chart to Harbor registry - uses: hoverkraft-tech/helm-push@v5.0.0 + - uses: hoverkraft-tech/ci-github-publish/actions/release/create@bf24f894f60a3def62a8750f3964d05acb052c11 # 3.1.2 with: - useOCIRegistry: true - username: ${{ secrets.HARBOR_REGISTRY_USER }} - # NOTE: access-token is the password for OCI registry - # cf https://github.com/bsord/helm-push/blob/5ec3320fb5720a0a5aa210d871999f2b836f2d97/entrypoint.sh#L37 - access-token: ${{ secrets.HARBOR_REGISTRY_PASSWORD }} - registry-url: oci://harbor.hoverkraft.cloud/public/charts - chart-folder: helm/chart - force: true - update-dependencies: true - version: ${{ github.event.inputs.tagVersion }} - appVersion: ${{ github.event.inputs.tagVersion }} + tag: ${{ needs.prepare.outputs.tag }} + target-ref: ${{ github.sha }} + changelog-summary: ${{ secrets.CHANGELOG_SUMMARY }} diff --git a/.github/workflows/semantic-pull-request.yml b/.github/workflows/semantic-pull-request.yml new file mode 100644 index 0000000..7f79d25 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yml @@ -0,0 +1,14 @@ +--- +name: Pull Request - Semantic Lint + +on: + pull_request: + types: [opened, reopened, edited, synchronize] + +permissions: {} + +jobs: + title: + uses: hoverkraft-tech/ci-github-common/.github/workflows/semantic-pull-request.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0 + permissions: + contents: read diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 1ccd41c..2f4b986 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,20 +1,15 @@ +--- name: Mark stale issues and pull requests on: schedule: - cron: "30 1 * * *" +permissions: {} + jobs: stale: - runs-on: self-hosted - - steps: - - uses: actions/stale@v9.0.0 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: "This issue is stale" - stale-pr-message: "This PR is stale" - stale-issue-label: "no-issue-activity" - exempt-issue-labels: "awaiting-approval,work-in-progress" - stale-pr-label: "no-pr-activity" - exempt-pr-labels: "awaiting-approval,work-in-progress" + permissions: + issues: write + pull-requests: write + uses: hoverkraft-tech/ci-github-common/.github/workflows/stale.yml@26f3d6878844ec53849eec6ac75af8d14ea402e9 # 5.0.0 diff --git a/.gitignore b/.gitignore index a197e1e..6baf34e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ .env .cache coverage.out + +junit.xml +golangci-lint.sarif + +# Local developer tools and CI reports +/.cache/ +/bin/ +/super-linter-output/ +/super-linter.log +/.devcontainer/.env diff --git a/.golangci.yml b/.golangci.yml index 26c0ac6..120de21 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,76 +1,31 @@ -# This file contains all available configuration options -# with their default values. - -# options for analysis running +--- +version: "2" run: - # default concurrency is a available CPU number - # concurrency: 4 - - # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 5m - - # exit code when at least one issue was found, default is 1 issues-exit-code: 1 - - # include test files or not, default is true tests: true - - # list of build tags, all linters use it. Default is empty list. - # build-tags: - # - mytag - - # which dirs to skip: issues from them won't be reported; - # can use regexp here: generated.*, regexp is applied on full path; - # default value is empty list, but default dirs are skipped independently - # from this option's value (see skip-dirs-use-default). - # "/" will be replaced by current OS file path separator to properly work - # on Windows. - # skip-dirs: - # - src/external_libs - # - autogenerated_by_my_lib - - # default is true. Enables skipping of directories: - # vendor$, third_party$, testdata$, examples$, Godeps$, builtin$ - skip-dirs-use-default: true - - # which files to skip: they will be analyzed, but issues from them - # won't be reported. Default value is empty list, but there is - # no need to include all autogenerated files, we confidently recognize - # autogenerated files. If it's not please let us know. - # "/" will be replaced by current OS file path separator to properly work - # on Windows. - # skip-files: - # - ".*\\.my\\.go$" - # - lib/bad.go - - # by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules": - # If invoked with -mod=readonly, the go command is disallowed from the implicit - # automatic updating of go.mod described above. Instead, it fails when any changes - # to go.mod are needed. This setting is most useful to check that go.mod does - # not need updates, such as in a continuous integration and testing system. - # If invoked with -mod=vendor, the go command assumes that the vendor - # directory holds the correct copies of dependencies and ignores - # the dependency descriptions in go.mod. - # modules-download-mode: readonly|release|vendor - - # Allow multiple parallel golangci-lint instances running. - # If false (default) - golangci-lint acquires file lock on start. - # allow-parallel-runners: false - - -# output configuration options output: - # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" - format: code-climate - - # print lines of code with issue, default is true - print-issued-lines: true - - # print linter name in the end of issue text, default is true - print-linter-name: true - - # make issues output unique by line, default is true - uniq-by-line: true - + formats: + code-climate: + path: stdout +linters: + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ issues: - exclude: [] + uniq-by-line: true +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..5241466 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +# Helm Go templates are validated by the chart checks. +/helm/chart/templates/** diff --git a/.tool-versions b/.tool-versions index 666cc48..f651ac6 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1 @@ -skaffold 2.8.0 helm 3.12.1 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..32897a5 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,8 @@ +# Agent instructions + +Follow the [Hoverkraft organization guidance](https://github.com/hoverkraft-tech/.github/blob/main/AGENTS.md). + +Read the [development guide](docs/development/README.md) before changing code or CI. +Use the commands in `Makefile`; `make ci` validates without rewriting tracked files. +Keep the application checks and the shared repository linter passing. Fix findings +instead of adding broad exclusions. Preserve the existing deployment and release contracts. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..76dbff5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing + +Start with the [development guide](docs/development/README.md) for the devcontainer, +local commands and CI checks. Use Conventional Commits for commits and PR titles. +Run `make ci` before requesting review and describe the behavior changed and checks run. diff --git a/Dockerfile b/Dockerfile index 9355c34..2f62da9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,20 @@ -# build stage -FROM golang:alpine AS builder -RUN apk add --no-cache git +FROM golang:1.27-alpine@sha256:70bd7ddea8b6cbe5d6943cde279d6b67feb10cc924fb9100d1d8757c1575b280 AS builder WORKDIR /go/src/app COPY go.* . -COPY src/ . RUN --mount=type=cache,target=/go/pkg/mod \ - --mount=type=cache,target=/root/.cache/go-build \ - go get -d -v ./... + go mod download && go mod verify +COPY src/ . RUN --mount=type=cache,target=/go/pkg/mod \ --mount=type=cache,target=/root/.cache/go-build \ - go build -o /go/bin/http-header-authenticator -v ./... + CGO_ENABLED=0 go build -mod=readonly -trimpath -o /go/bin/http-header-authenticator ./... -# final stage -FROM alpine:3.18 -RUN apk --no-cache add ca-certificates +FROM alpine:3.24@sha256:f59abe656b692d901e184be3445e084786602108599d2a51d229c0f5a48c71bf +RUN addgroup -g 10001 app && adduser -D -u 10001 -G app app +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=builder /go/bin/http-header-authenticator /usr/local/bin/http-header-authenticator -COPY entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/bin/sh", "/entrypoint.sh"] -LABEL "name"="http-header-authenticator" "version"="0.1.0" +COPY --chmod=755 entrypoint.sh /entrypoint.sh +USER 10001:10001 EXPOSE 8080 ENV GIN_MODE=release +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 CMD ["wget", "-q", "--spider", "http://127.0.0.1:8080/health"] +ENTRYPOINT ["/entrypoint.sh"] diff --git a/Makefile b/Makefile index ee1ccfd..4821bf4 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,78 @@ -ci: go-tests go-cover golang-ci +.DEFAULT_GOAL := help +.PHONY: help setup lint lint-code lint-repository lint-fix test audit build docker-build test-image ci -go-tests: src/* go.mod go.sum - go test -v ./... +LINTER_IMAGE := http-header-authenticator-linter:local +IMAGE := http-header-authenticator:local +# Match the shared docker/test-image action's Goss toolchain. +GOSS_IMAGE := ghcr.io/goss-org/goss:v0.4.10@sha256:8d3924f722a04a660e9e6c2403be0399d737c0187fc065714d26b992286c3f0a -go-cover: src/* go.mod go.sum - go test -coverprofile=coverage.out ./... +help: ## Show development commands + @awk 'BEGIN {FS = ":.*## "} /^[a-zA-Z_-]+:.*## / {printf "%-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST) -golang-ci: src/* go.mod go.sum - docker run --rm -t \ - -v ${PWD}:/app \ - -v ${PWD}/.cache/golang-ci:/root/.cache \ - -w /app golangci/golangci-lint:v1.54.2 golangci-lint run +setup: ## Download and verify Go dependencies + go mod download + go mod verify + +lint-code: ## Check formatting, module tidiness and Go diagnostics + @test -z "$$(gofmt -l $$(git ls-files '*.go'))" || { gofmt -l $$(git ls-files '*.go'); exit 1; } + go mod tidy -diff + golangci-lint run --timeout=5m + +test: ## Run race tests with atomic coverage + go test -mod=readonly -race -count=1 -timeout=5m -covermode=atomic -coverprofile=coverage.out ./... + +audit: ## Audit Go dependencies and the standard library + go run golang.org/x/vuln/cmd/govulncheck@v1.10.0 ./... + +build: ## Build the application without publishing + go build -mod=readonly -trimpath -o bin/http-header-authenticator ./src/github.com/hoverkraft-tech/http-header-authenticator + +docker-build: ## Build the production image without publishing + docker build --tag "$(IMAGE)" . + +test-image: docker-build ## Build and test the production image with the CI suite + @set -eu; \ + image_id=$$(docker image inspect --format '{{.Id}}' "$(IMAGE)"); \ + platform=$$(docker image inspect --format '{{.Os}}/{{.Architecture}}' "$$image_id"); \ + socket=$$(docker context inspect --format '{{.Endpoints.docker.Host}}'); \ + if [ -n "$${DOCKER_HOST:-}" ] && [ -z "$${DOCKER_CONTEXT:-}" ]; then socket=$$DOCKER_HOST; fi; \ + case "$$socket" in unix://*) socket=$${socket#unix://} ;; *) echo 'Image tests require a local Unix Docker socket.' >&2; exit 1 ;; esac; \ + test -S "$$socket"; \ + mkdir -p .cache/container-tests; \ + rm -f .cache/container-tests/junit.xml; \ + tools=$$(mktemp -d "$(CURDIR)/.cache/container-tests/tools.XXXXXX"); \ + tool_container=; test_container=; \ + trap 'if [ -n "$$test_container" ]; then docker rm --force --volumes "$$test_container" >/dev/null; fi; if [ -n "$$tool_container" ]; then docker rm --force --volumes "$$tool_container" >/dev/null; fi; rm -rf "$$tools"' EXIT; \ + trap 'exit 130' INT; trap 'exit 143' TERM; \ + tool_container=$$(docker create --platform "$$platform" "$(GOSS_IMAGE)" /bin/true); \ + docker cp "$$tool_container:/usr/bin/goss" "$$tools/goss"; \ + chmod 755 "$$tools/goss"; \ + set --; \ + while IFS= read -r option || [ -n "$$option" ]; do \ + case "$$option" in ''|'#'*) continue ;; esac; \ + set -- "$$@" "$$option"; \ + done < tests/container-image/docker-args; \ + test_container=$$(docker create "$$@" --platform "$$platform" \ + --volume "$$tools/goss:/goss-bin:ro" \ + --volume "$(CURDIR)/tests/container-image:/goss:ro" \ + --entrypoint /goss-bin "$$image_id" -g /goss/goss.yaml validate --format junit); \ + echo 'Running image checks; JUnit report: .cache/container-tests/junit.xml'; \ + timeout --kill-after=5s 300s docker start --attach "$$test_container" > .cache/container-tests/junit.xml + +lint-fix: ## Apply Go and repository formatting fixes + go fmt ./... + golangci-lint run --fix --timeout=5m + $(call run_linter,-e FIX_YAML_PRETTIER=true -e FIX_MARKDOWN=true -e FIX_MARKDOWN_PRETTIER=true -e FIX_BIOME_FORMAT=true -e FIX_SHELL_SHFMT=true) + +lint: lint-code lint-repository ## Run application and repository checks + +lint-repository: ## Run Hoverkraft's shared repository linter + $(call run_linter,) + +ci: setup ## Run local validation without rewriting tracked files + $(MAKE) lint test audit build + +define run_linter + docker build --build-arg UID=$(shell id -u) --build-arg GID=$(shell id -g) --tag $(LINTER_IMAGE) .github/linters + docker run --rm -v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" -e DEFAULT_WORKSPACE="$(CURDIR)" $(1) $(LINTER_IMAGE) +endef diff --git a/README.md b/README.md index 47a2b01..dc93236 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,65 @@ # http-header-authenticator -Go micro-service used to authenticate http requests based on provided fix http headers +
+ Hoverkraft logo +
-## usage +--- + +[![Main - Continuous Integration](https://github.com/hoverkraft-tech/http-header-authenticator/actions/workflows/main-ci.yml/badge.svg)](https://github.com/hoverkraft-tech/http-header-authenticator/actions/workflows/main-ci.yml) +[![GitHub release](https://img.shields.io/github/v/release/hoverkraft-tech/http-header-authenticator)](https://github.com/hoverkraft-tech/http-header-authenticator/releases) +[![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md) + +## Overview + +Go service that authenticates HTTP requests against a configured header and value. + +## Usage ```sh http-header-authenticator check -H 'X-acme-auth' -V 'SomeSecurePassword' ``` ```sh -curl -H 'X-acme-auth: SomeSecurePassword' localhost:8080 # -> 200 -curl localhost:8080 # -> 404 +curl -H 'X-acme-auth: SomeSecurePassword' localhost:8080/check # -> 200 +curl localhost:8080/check # -> 403 ``` -Can be used with nginx-ingress controller to authenticate requests comming from CDN servers -See https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#global-auth-url for inspiration +Use it as an external authentication service for an ingress controller, for example +to authenticate requests coming from a CDN. `/health` reports service readiness. -## installation +## Installation -### using helm +### Helm ```sh helm upgrade http-header-authenticator oci://harbor.hoverkraft.cloud/public/charts/http-header-authenticator \ - --install --create-namespace --namespace http-header-authenticator + --install --create-namespace --namespace http-header-authenticator \ + --set-string securityHeader.name=X-Auth-Token \ + --set-string securityHeader.value="$AUTH_TOKEN" ``` -### docker +Set `AUTH_TOKEN` to your authentication secret before installing. The chart runs as +a non-root user with a read-only filesystem and resource budgets. Its NetworkPolicy +allows incoming HTTP traffic and denies outbound connections. Adjust these values +for your cluster and workload. + +### Docker - [Docker Hub](https://hub.docker.com/repository/docker/webofmars/http-header-authenticator) ```shell -docker-compose up -d --build +AUTH_TOKEN='replace-with-a-strong-secret' docker compose up -d --build ``` -### from sources +### From source ```shell go build -o ./bin/http-header-authenticator ./src/github.com/hoverkraft-tech/http-header-authenticator ``` + +See the [development guide](docs/development/README.md) for local checks. + +## Contributing + +Contributions are welcome. Read [Contributing](CONTRIBUTING.md) before proposing a change. diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..f225acd --- /dev/null +++ b/biome.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.5.14/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "formatter": { + "indentStyle": "space", + "indentWidth": 2 + }, + "linter": { + "enabled": true + } +} diff --git a/ct.yaml b/ct.yaml index 4d04ac8..7780537 100644 --- a/ct.yaml +++ b/ct.yaml @@ -1,3 +1,4 @@ +--- chart-dirs: - helm charts: diff --git a/docker-compose.debug.yml b/docker-compose.debug.yml index 3c8f6b5..6d7833f 100644 --- a/docker-compose.debug.yml +++ b/docker-compose.debug.yml @@ -1,5 +1,4 @@ -version: '3.4' - +--- services: http-header-authenticator: image: http-header-authenticator @@ -7,4 +6,12 @@ services: context: . dockerfile: ./Dockerfile ports: - - 8080:8080 + - 127.0.0.1:8080:8080 + read_only: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true + environment: + HEADER: X-test-secret + VALUE: ${AUTH_TOKEN:?Set AUTH_TOKEN to a strong secret} diff --git a/docker-compose.yml b/docker-compose.yml index 86aaa2a..62be3e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,4 @@ -version: '3.4' - +--- services: http-header-authenticator: image: http-header-authenticator @@ -7,7 +6,12 @@ services: context: . dockerfile: ./Dockerfile environment: - HEADER: 'X-test-secret' - VALUE: 'changeme' + HEADER: X-test-secret + VALUE: ${AUTH_TOKEN:?Set AUTH_TOKEN to a strong secret} ports: - - 8080:8080 + - 127.0.0.1:8080:8080 + read_only: true + cap_drop: + - ALL + security_opt: + - no-new-privileges:true diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..565dd63 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,4 @@ +# Documentation + +- [Development](development/README.md): devcontainer, local checks and CI. +- [Project usage](../README.md): application purpose, prerequisites and everyday commands. diff --git a/docs/development/README.md b/docs/development/README.md new file mode 100644 index 0000000..f21f313 --- /dev/null +++ b/docs/development/README.md @@ -0,0 +1,125 @@ +# Development + +## Environment + +Open this repository in Visual Studio Code and select "Reopen in Container". The devcontainer +installs Go tooling, Docker and the GitHub CLI, then runs `make setup`. +The committed feature lockfile makes the feature resolution reproducible. +Runtime and tool versions live in [devcontainer.json](../../.devcontainer/devcontainer.json). + +For a host setup, install Docker and the same language tools, then run `make setup`. +Use the supported Go toolchain and golangci-lint declared in the devcontainer. `go.mod` declares the minimum language version. + +## Commands + +| Command | Purpose | +| ----------------- | ---------------------------------------------------------- | +| `make setup` | Install or verify dependencies | +| `make lint` | Check application code and repository files | +| `make lint-fix` | Apply supported formatting fixes | +| `make test-image` | Build and test the production image with the CI Goss suite | +| `make test` | Run tests and collect coverage | +| `make audit` | Check production dependencies for vulnerabilities | +| `make build` | Build locally without publishing | +| `make ci` | Run the complete local validation sequence | + +`make lint-repository` uses the same pinned Hoverkraft Super-Linter image and +tool configuration as CI, without a repository validator allowlist. It checks +workflows, action pinning policy, configuration, +Markdown, spelling, shell scripts, Dockerfiles and infrastructure security. +Language lint runs through the project-owned tools in `make lint-code` and the shared +language CI, so dependency resolution and tool configuration stay consistent. +Super-Linter checks Go recursively through `GO_MODULES`; its standalone-file mode +cannot combine files from multiple packages and is disabled. `GOTOOLCHAIN=local` +keeps its bundled compiler compatible with its golangci-lint binary. The dedicated +Go CI still uses the project toolchain. + +## Continuous integration + +The separate `CI complete` job depends on `checks` and `reports`. Add new jobs to +[the checks group](../../.github/workflows/__checks.yml); GitHub exports their +results automatically, so publication and gate dependencies stay unchanged. +It fails on failed, cancelled or unexpectedly skipped jobs. Report publication +can succeed while reporting failed tests; the producer and `CI complete` remain +failed. Require the resulting `CI complete / Check jobs` check for merging instead of treating the reporting +workflow as the overall CI verdict. + +Pull requests, merge queues and main-branch pushes run the shared language checks +and repository linter. A weekly run detects newly disclosed dependency vulnerabilities. +Repository lint uses Common's default scope: changed files on pull requests and +all files on other triggers, matching the other consumer projects. +Shared CI reports consolidate native reports after the producer jobs finish; producer +failures continue to block validation. The semantic PR workflow and repository linter +share [.commitlintrc.json](../../.commitlintrc.json). + +External actions and reusable workflows use reviewed release SHAs with matching +version comments. Dependabot maintains these references. The pending shared workflow +capabilities use immutable candidate commits with linked TODOs; replace those pins +with the first containing release after the supporting PRs merge. + +Dependabot is the primary updater for Go modules, GitHub Actions, Docker images +and devcontainer features, with weekly groups and a seven-day cooldown. +Renovate is limited to versions outside those supported manifests: Go and +golangci-lint feature options, and the govulncheck version and Goss image tag/digest +embedded in the Makefile. +It also maintains the explicit Go `toolchain` directive and the Helm CLI in +`.tool-versions`. It cannot update module dependencies or raise the minimum Go version. +The scheduled [Renovate workflow](../../.github/workflows/__renovate.yml) uses +`CI_BOT_APP_CLIENT_ID` and `CI_BOT_APP_PRIVATE_KEY`; its +[configuration](../../.github/renovate.json) explicitly limits enabled managers. +Review the lockfile and run `make ci` when updating dependencies or features. + +## Image and chart checks + +Tests run once with race detection and detailed JUnit results, using the Go +toolchain declared in `go.mod`, aligned with the production Dockerfile. +Lint, audit, build and atomic coverage use the same toolchain. The +shared Go action retains the native coverage profile and validates source paths. + +One terminal `reports` job waits for all code, container and Helm checks. It +publishes annotations and a consolidated summary with expandable details. +Coverage uses GitHub Code Quality when available and is also submitted to +Coveralls. Coveralls keeps its coverage comment. Common publishes a separate PR +overview for test and lint results, with failures visible and successful checks +collapsed, and retains coverage in the Actions summary. The summary labels its +normalized line coverage separately from the native Go statement coverage. + +Helm validation and publication +use the dedicated container workflows. The Harbor robot username and password +remain secrets passed only to chart publication. Image builds wait for code and repository checks; container +health/authentication and Helm installation checks validate the built digest before +release promotion. The shared `docker-promote-images.yml` publishes the validated +digest to GHCR and the explicitly configured Docker Hub destination in one locked, +journaled operation. It preserves and verifies the copied signatures and provenance. +Chart publication waits for both registries to succeed. Registry destinations and +credentials remain unchanged. + +## Container and chart policy + +The image runs as UID/GID 10001 and has an HTTP health check. The chart disables +service account token mounting, drops capabilities, uses a read-only root filesystem, +sets resource budgets and denies outbound traffic. Adjust the budgets for your workload. + +Raw YAML formatters exclude Helm Go templates; the chart checks and security scanners +validate their rendered manifests. Scoped scanner annotations document Helm namespace +and image inputs, plus the existing environment-based authentication interface. +CI installs the built image by digest. Deploy into a dedicated namespace and pass a +strong authentication value explicitly. + +Chart validation uses the synthetic token in +[ci/default-values.yaml](../../helm/chart/ci/default-values.yaml). Production installs +must provide `securityHeader.value`; the chart has no default authentication token. + +The existing GitHub CodeQL default setup continues to scan Go. The shared +linter disables its additional CodeQL job because GitHub rejects advanced-setup +results while default setup is enabled. Actionlint, Zizmor and Checkov still check +workflow correctness and security. + +### Container checks + +`make test-image` and CI use `tests/container-image/goss.yaml` and the same runtime +restrictions from `docker-args`. The suite starts the real entrypoint, checks the +health probe, accepts the configured header and rejects wrong or missing values. +It runs as the production user with a read-only root filesystem, no Linux +capabilities and no privilege escalation. CI repeats this suite on native amd64 +and arm64 runners before chart testing and image promotion. diff --git a/entrypoint.sh b/entrypoint.sh old mode 100644 new mode 100755 index ce7bdb6..eea3c8e --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,11 +1,13 @@ -#!/bin/ash - -# shellcheck shell=dash - +#!/bin/sh set -eu -set -o pipefail -[ -z "${HEADER}" ] && echo "HEADER is required" && exit 1 -[ -z "${VALUE}" ] && echo "VALUE is required" && exit 1 +if [ -z "${HEADER:-}" ]; then + echo "HEADER is required" >&2 + exit 1 +fi +if [ -z "${VALUE:-}" ]; then + echo "VALUE is required" >&2 + exit 1 +fi -/usr/local/bin/http-header-authenticator check -H "${HEADER}" -V "${VALUE}" +exec /usr/local/bin/http-header-authenticator check -H "${HEADER}" -V "${VALUE}" diff --git a/go.mod b/go.mod index a90c0ff..451498b 100644 --- a/go.mod +++ b/go.mod @@ -1,42 +1,48 @@ module github.com/hoverkraft-tech/http-header-authenticator -go 1.21 +go 1.26.0 + +toolchain go1.27.4 require ( - github.com/gin-contrib/logger v0.2.6 github.com/gin-contrib/requestid v0.0.6 - github.com/gin-gonic/gin v1.9.1 + github.com/gin-gonic/gin v1.12.0 github.com/rs/zerolog v1.31.0 github.com/spf13/cobra v1.7.0 ) require ( - github.com/bytedance/sonic v1.9.2 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect + github.com/bytedance/gopkg v0.1.3 // indirect + github.com/bytedance/sonic v1.15.0 // indirect + github.com/bytedance/sonic/loader v0.5.0 // indirect + github.com/cloudwego/base64x v0.1.6 // indirect + github.com/gabriel-vasile/mimetype v1.4.12 // indirect + github.com/gin-contrib/sse v1.1.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.1 // indirect - github.com/goccy/go-json v0.10.2 // indirect + github.com/go-playground/validator/v10 v10.30.1 // indirect + github.com/goccy/go-json v0.10.5 // indirect + github.com/goccy/go-yaml v1.19.2 // indirect github.com/google/uuid v1.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect - github.com/leodido/go-urn v1.2.4 // indirect + github.com/klauspost/cpuid/v2 v2.3.0 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.8 // indirect + github.com/pelletier/go-toml/v2 v2.2.4 // indirect + github.com/quic-go/qpack v0.6.0 // indirect + github.com/quic-go/quic-go v0.59.1 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - golang.org/x/arch v0.4.0 // indirect - golang.org/x/crypto v0.11.0 // indirect - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/text v0.11.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect + github.com/ugorji/go/codec v1.3.1 // indirect + go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect + golang.org/x/arch v0.22.0 // indirect + golang.org/x/crypto v0.59.0 // indirect + golang.org/x/net v0.63.0 // indirect + golang.org/x/sys v0.50.0 // indirect + golang.org/x/text v0.44.0 // indirect + google.golang.org/protobuf v1.36.10 // indirect ) diff --git a/go.sum b/go.sum index 042f944..275678c 100644 --- a/go.sum +++ b/go.sum @@ -1,28 +1,30 @@ -github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= -github.com/bytedance/sonic v1.9.2 h1:GDaNjuWSGu09guE9Oql0MSTNhNCLlWwO8y/xM5BzcbM= -github.com/bytedance/sonic v1.9.2/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= -github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams= -github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M= +github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM= +github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE= +github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k= +github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE= +github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo= +github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M= +github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= -github.com/gin-contrib/logger v0.2.6 h1:u+tvbiQhGEyuJgZSHNja3WD800ILduVyk5xKop160dw= -github.com/gin-contrib/logger v0.2.6/go.mod h1:ZDkY/xiMqbZdz83enCHjMqxJUFRzB8bq0kjyMmjr3qU= +github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw= +github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s= github.com/gin-contrib/requestid v0.0.6 h1:mGcxTnHQ45F6QU5HQRgQUDsAfHprD3P7g2uZ4cSZo9o= github.com/gin-contrib/requestid v0.0.6/go.mod h1:9i4vKATX/CdggbkY252dPVasgVucy/ggBeELXuQztm4= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w= +github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM= github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk= -github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= -github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU= +github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8= +github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -30,15 +32,18 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= -github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w= +github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4= +github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M= +github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM= +github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -46,40 +51,41 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y= +github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= -github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= -github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= -github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= -github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= +github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4= +github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8= +github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII= +github.com/quic-go/quic-go v0.59.1 h1:0Gmua0HW1Tv7ANR7hUYwRyD0MG5OJfgvYSZasGZzBic= +github.com/quic-go/quic-go v0.59.1/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= @@ -92,54 +98,56 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= -github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.4.0 h1:A8WCeEWhLwPBKNbFi5Wv5UTCBx5zzubnXDlMOFAzFMc= -golang.org/x/arch v0.4.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY= +github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4= +go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE= +go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0= +go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y= +go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU= +golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI= +golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c= +golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0= +golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= +golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE= +google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= @@ -147,4 +155,3 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/helm/chart-schema.yaml b/helm/chart-schema.yaml index 2a26d9b..c2bf60e 100644 --- a/helm/chart-schema.yaml +++ b/helm/chart-schema.yaml @@ -1,3 +1,4 @@ +--- name: str() home: str(required=False) version: str() diff --git a/helm/chart/Chart.yaml b/helm/chart/Chart.yaml index 12d495d..6bfb19d 100644 --- a/helm/chart/Chart.yaml +++ b/helm/chart/Chart.yaml @@ -1,3 +1,4 @@ +--- apiVersion: v2 name: http-header-authenticator description: A Helm chart for http-header-authenticator diff --git a/helm/chart/ci/default-values.yaml b/helm/chart/ci/default-values.yaml new file mode 100644 index 0000000..bcdca02 --- /dev/null +++ b/helm/chart/ci/default-values.yaml @@ -0,0 +1,4 @@ +--- +# Synthetic value for chart linting and isolated CI installs only. +securityHeader: + value: ci-test-value diff --git a/helm/chart/templates/NOTES.txt b/helm/chart/templates/NOTES.txt index 319f01b..11358fc 100644 --- a/helm/chart/templates/NOTES.txt +++ b/helm/chart/templates/NOTES.txt @@ -10,8 +10,8 @@ export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") echo http://$NODE_IP:$NODE_PORT {{- else if contains "LoadBalancer" .Values.service.type }} - NOTE: It may take a few minutes for the LoadBalancer IP to be available. - You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "chart.fullname" . }}' + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + Watch its status with 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "chart.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "chart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") echo http://$SERVICE_IP:{{ .Values.service.port }} {{- else if contains "ClusterIP" .Values.service.type }} diff --git a/helm/chart/templates/deployment.yaml b/helm/chart/templates/deployment.yaml index 3ab2f7d..4bf128c 100644 --- a/helm/chart/templates/deployment.yaml +++ b/helm/chart/templates/deployment.yaml @@ -1,6 +1,12 @@ +# trivy:ignore:KSV-0110 The installer selects .Release.Namespace with --namespace. apiVersion: apps/v1 kind: Deployment metadata: + annotations: + checkov.io/skip1: "CKV_K8S_21=Install into a dedicated namespace with --namespace; honor the Helm release namespace." + checkov.io/skip2: "CKV_K8S_43=Release tags are chart inputs; CI installs and tests the built tag@sha256 digest." + checkov.io/skip3: "CKV_K8S_35=The application accepts HEADER and VALUE through its documented environment interface." + namespace: {{ .Release.Namespace }} name: {{ include "chart.fullname" . }} labels: {{- include "chart.labels" . | nindent 4 }} @@ -25,6 +31,7 @@ spec: imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} + automountServiceAccountToken: false serviceAccountName: {{ include "chart.serviceAccountName" . }} securityContext: {{- toYaml .Values.podSecurityContext | nindent 8 }} diff --git a/helm/chart/templates/hpa.yaml b/helm/chart/templates/hpa.yaml index a91f61b..60bf55e 100644 --- a/helm/chart/templates/hpa.yaml +++ b/helm/chart/templates/hpa.yaml @@ -2,6 +2,9 @@ apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: + annotations: + checkov.io/skip1: "CKV_K8S_21=Install into a dedicated namespace with --namespace; honor the Helm release namespace." + namespace: {{ .Release.Namespace }} name: {{ include "chart.fullname" . }} labels: {{- include "chart.labels" . | nindent 4 }} diff --git a/helm/chart/templates/ingress.yaml b/helm/chart/templates/ingress.yaml index 63c1311..e3b60ff 100644 --- a/helm/chart/templates/ingress.yaml +++ b/helm/chart/templates/ingress.yaml @@ -15,11 +15,13 @@ apiVersion: extensions/v1beta1 {{- end }} kind: Ingress metadata: + namespace: {{ .Release.Namespace }} name: {{ $fullName }} labels: {{- include "chart.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} annotations: + checkov.io/skip1: "CKV_K8S_21=Install into a dedicated namespace with --namespace; honor the Helm release namespace." + {{- with .Values.ingress.annotations }} {{- toYaml . | nindent 4 }} {{- end }} spec: diff --git a/helm/chart/templates/networkpolicy.yaml b/helm/chart/templates/networkpolicy.yaml new file mode 100644 index 0000000..a4118be --- /dev/null +++ b/helm/chart/templates/networkpolicy.yaml @@ -0,0 +1,21 @@ +{{- if .Values.networkPolicy.enabled }} +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: {{ include "chart.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "chart.labels" . | nindent 4 }} +spec: + podSelector: + matchLabels: + {{- include "chart.selectorLabels" . | nindent 6 }} + policyTypes: + - Ingress + - Egress + ingress: + - ports: + - protocol: TCP + port: http + egress: [] +{{- end }} diff --git a/helm/chart/templates/secrets.yaml b/helm/chart/templates/secrets.yaml index 68d9acd..07ed59a 100644 --- a/helm/chart/templates/secrets.yaml +++ b/helm/chart/templates/secrets.yaml @@ -1,9 +1,12 @@ apiVersion: v1 kind: Secret metadata: + annotations: + checkov.io/skip1: "CKV_K8S_21=Install into a dedicated namespace with --namespace; honor the Helm release namespace." + namespace: {{ .Release.Namespace }} name: {{ include "chart.fullname" . }} labels: {{- include "chart.labels" . | nindent 4 }} data: HEADER: {{ .Values.securityHeader.name | default "X-Auth-Token" | b64enc }} - VALUE: {{ .Values.securityHeader.value | default "1234567890" | b64enc }} + VALUE: {{ required "Set securityHeader.value to a strong authentication token" .Values.securityHeader.value | b64enc }} diff --git a/helm/chart/templates/service.yaml b/helm/chart/templates/service.yaml index dfc5b3a..b42054e 100644 --- a/helm/chart/templates/service.yaml +++ b/helm/chart/templates/service.yaml @@ -1,6 +1,9 @@ apiVersion: v1 kind: Service metadata: + annotations: + checkov.io/skip1: "CKV_K8S_21=Install into a dedicated namespace with --namespace; honor the Helm release namespace." + namespace: {{ .Release.Namespace }} name: {{ include "chart.fullname" . }} labels: {{- include "chart.labels" . | nindent 4 }} diff --git a/helm/chart/templates/serviceaccount.yaml b/helm/chart/templates/serviceaccount.yaml index 26a57fa..f2e90a8 100644 --- a/helm/chart/templates/serviceaccount.yaml +++ b/helm/chart/templates/serviceaccount.yaml @@ -2,11 +2,13 @@ apiVersion: v1 kind: ServiceAccount metadata: + namespace: {{ .Release.Namespace }} name: {{ include "chart.serviceAccountName" . }} labels: {{- include "chart.labels" . | nindent 4 }} - {{- with .Values.serviceAccount.annotations }} annotations: + checkov.io/skip1: "CKV_K8S_21=Install into a dedicated namespace with --namespace; honor the Helm release namespace." + {{- with .Values.serviceAccount.annotations }} {{- toYaml . | nindent 4 }} {{- end }} {{- end }} diff --git a/helm/chart/values.yaml b/helm/chart/values.yaml index 78e5171..98a80ee 100644 --- a/helm/chart/values.yaml +++ b/helm/chart/values.yaml @@ -1,86 +1,61 @@ -# Default values for chart. -# This is a YAML-formatted file. -# Declare variables to be passed into your templates. - +--- +# Override resource budgets for your workload. Install into a dedicated namespace. securityHeader: name: X-Auth-Token - value: "1234567890" - + # Required: provide a strong authentication token when installing. + value: "" replicaCount: 1 - image: - repository: webofmars/http-header-authenticator - pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. + repository: docker.io/webofmars/http-header-authenticator + pullPolicy: Always tag: "" - imagePullSecrets: [] nameOverride: "" fullnameOverride: "" - serviceAccount: - # Specifies whether a service account should be created create: true - # Annotations to add to the service account annotations: {} - # The name of the service account to use. - # If not set and create is true, a name is generated using the fullname template name: "" - podAnnotations: {} - -podSecurityContext: {} - # fsGroup: 2000 - -securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 - +podSecurityContext: + runAsNonRoot: true + runAsUser: 10001 + runAsGroup: 10001 + seccompProfile: + type: RuntimeDefault +securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL service: type: ClusterIP port: 8080 - ingress: enabled: false className: "" annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local paths: - path: / pathType: ImplementationSpecific tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local - -resources: {} - # We usually recommend not to specify default resources and to leave this as a conscious - # choice for the user. This also increases chances charts run on environments with little - # resources, such as Minikube. If you do want to specify resources, uncomment the following - # lines, adjust them as necessary, and remove the curly braces after 'resources:'. - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi - +resources: + requests: + cpu: 10m + memory: 32Mi + limits: + cpu: 500m + memory: 128Mi autoscaling: enabled: false minReplicas: 1 maxReplicas: 100 targetCPUUtilizationPercentage: 80 - # targetMemoryUtilizationPercentage: 80 - nodeSelector: {} - tolerations: [] - affinity: {} +networkPolicy: + enabled: true diff --git a/helm/lintconf.yaml b/helm/lintconf.yaml index 9fb5aca..c0bc53e 100644 --- a/helm/lintconf.yaml +++ b/helm/lintconf.yaml @@ -1,3 +1,4 @@ +--- rules: braces: min-spaces-inside: 0 @@ -20,7 +21,7 @@ rules: require-starting-space: true min-spaces-from-content: 2 document-end: disable - document-start: disable # No --- to start a file + document-start: disable # No --- to start a file empty-lines: max: 2 max-start: 0 @@ -29,10 +30,10 @@ rules: max-spaces-after: 1 indentation: spaces: consistent - indent-sequences: whatever # - list indentation will handle both indentation and without + indent-sequences: whatever # - list indentation will handle both indentation and without check-multi-line-strings: false key-duplicates: enable - line-length: disable # Lines can be any length + line-length: disable # Lines can be any length new-line-at-end-of-file: disable new-lines: type: unix diff --git a/skaffold.yaml b/skaffold.yaml deleted file mode 100644 index d29937e..0000000 --- a/skaffold.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: skaffold/v4beta7 -kind: Config -build: - local: - tryImportMissing: true - useBuildkit: true - tagPolicy: - gitCommit: {} - artifacts: - - image: http-header-authenticator - docker: - dockerfile: Dockerfile -deploy: {} diff --git a/src/github.com/hoverkraft-tech/http-header-authenticator/main.go b/src/github.com/hoverkraft-tech/http-header-authenticator/main.go index 19b06f9..89ce00c 100644 --- a/src/github.com/hoverkraft-tech/http-header-authenticator/main.go +++ b/src/github.com/hoverkraft-tech/http-header-authenticator/main.go @@ -22,7 +22,7 @@ func main() { var checkCmd = &cobra.Command{ Use: "check", Short: "Check the presence of an HTTP header in a request", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { if headerName == "" || expectedValue == "" { fmt.Println("Header name and expected value are required.") return @@ -31,25 +31,7 @@ func main() { l := zerolog.New(os.Stdout).With().Timestamp().Logger() l.Info().Msg(fmt.Sprintf("Expected header is '%s' and expected value is '%s'", headerName, expectedValue)) - r := gin.New() - r.Use(gin.Recovery()) - r.Use(requestid.New()) - r.Use(CustomLoggerMiddleware(l)) - - // Health check endpoint - r.GET("/health", func(c *gin.Context) { - c.String(http.StatusOK, "OK") - }) - - // Check the presence of the header in all requests - r.NoRoute(func(c *gin.Context) { - value := c.GetHeader(headerName) - if value == expectedValue { - c.JSON(http.StatusOK, "HTTP header is present with the expected value.") - } else { - c.JSON(http.StatusForbidden, "HTTP header is not present with the expected value.") - } - }) + r := newRouter(headerName, expectedValue, l) fmt.Printf("Server is starting on port 8080...\n") if err := r.Run(":8080"); err != nil { @@ -83,3 +65,26 @@ func CustomLoggerMiddleware(logger zerolog.Logger) gin.HandlerFunc { } } } + +func newRouter(headerName, expectedValue string, logger zerolog.Logger) *gin.Engine { + r := gin.New() + r.Use(gin.Recovery()) + r.Use(requestid.New()) + r.Use(CustomLoggerMiddleware(logger)) + + // Health check endpoint + r.GET("/health", func(c *gin.Context) { + c.String(http.StatusOK, "OK") + }) + + // Check the presence of the header in all requests + r.NoRoute(func(c *gin.Context) { + value := c.GetHeader(headerName) + if value == expectedValue { + c.JSON(http.StatusOK, "HTTP header is present with the expected value.") + } else { + c.JSON(http.StatusForbidden, "HTTP header is not present with the expected value.") + } + }) + return r +} diff --git a/src/github.com/hoverkraft-tech/http-header-authenticator/main_test.go b/src/github.com/hoverkraft-tech/http-header-authenticator/main_test.go new file mode 100644 index 0000000..8a59ac7 --- /dev/null +++ b/src/github.com/hoverkraft-tech/http-header-authenticator/main_test.go @@ -0,0 +1,39 @@ +package main + +import ( + "io" + "net/http" + "net/http/httptest" + "testing" + + "github.com/gin-gonic/gin" + "github.com/rs/zerolog" +) + +func TestAuthentication(t *testing.T) { + gin.SetMode(gin.TestMode) + router := newRouter("X-Test-Token", "expected", zerolog.New(io.Discard)) + for _, test := range []struct { + name string + path string + value string + want int + }{ + {"matching header", "/check", "expected", http.StatusOK}, + {"wrong header", "/check", "wrong", http.StatusForbidden}, + {"missing header", "/check", "", http.StatusForbidden}, + {"health without authentication", "/health", "", http.StatusOK}, + } { + t.Run(test.name, func(t *testing.T) { + request := httptest.NewRequest(http.MethodGet, test.path, nil) + if test.value != "" { + request.Header.Set("X-Test-Token", test.value) + } + response := httptest.NewRecorder() + router.ServeHTTP(response, request) + if response.Code != test.want { + t.Fatalf("status = %d, want %d; body: %s", response.Code, test.want, response.Body.String()) + } + }) + } +} diff --git a/tests/container-image/check-http.sh b/tests/container-image/check-http.sh new file mode 100755 index 0000000..55de720 --- /dev/null +++ b/tests/container-image/check-http.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -eu + +work="$(mktemp -d)" +service_pid= +cleanup() { + status=$? + trap - EXIT + if [ -n "$service_pid" ]; then + kill "$service_pid" 2>/dev/null || true + wait "$service_pid" 2>/dev/null || true + fi + if [ "$status" -ne 0 ]; then cat "$work/service.log" >&2; fi + rm -rf "$work" + exit "$status" +} +trap cleanup EXIT +trap 'exit 130' INT +trap 'exit 143' TERM + +# Goss checks run concurrently, so startup and HTTP assertions share one lifecycle. +HEADER=X-Test-Token VALUE=ci-test-value /entrypoint.sh >"$work/service.log" 2>&1 & +service_pid=$! +/goss-bin -g /goss/http.yaml validate --retry-timeout 15s --sleep 1s --format documentation +# Exercise the same probe used by the image's Docker HEALTHCHECK. +wget -q --spider http://127.0.0.1:8080/health diff --git a/tests/container-image/docker-args b/tests/container-image/docker-args new file mode 100644 index 0000000..4d41d1a --- /dev/null +++ b/tests/container-image/docker-args @@ -0,0 +1,4 @@ +--read-only +--cap-drop=ALL +--security-opt=no-new-privileges +--tmpfs=/tmp:uid=10001,gid=10001,mode=0700 diff --git a/tests/container-image/goss.yaml b/tests/container-image/goss.yaml new file mode 100644 index 0000000..ba2ece8 --- /dev/null +++ b/tests/container-image/goss.yaml @@ -0,0 +1,10 @@ +--- +command: + application-user: + exec: id -u + exit-status: 0 + stdout: ["10001"] + authentication: + exec: sh /goss/check-http.sh + exit-status: 0 + timeout: 25000 diff --git a/tests/container-image/http.yaml b/tests/container-image/http.yaml new file mode 100644 index 0000000..ef33997 --- /dev/null +++ b/tests/container-image/http.yaml @@ -0,0 +1,16 @@ +--- +http: + health: + url: http://127.0.0.1:8080/health + status: 200 + accepted-header: + url: http://127.0.0.1:8080/check + request-headers: ["X-Test-Token: ci-test-value"] # gitleaks:allow - test token + status: 200 + wrong-header: + url: http://127.0.0.1:8080/check + request-headers: ["X-Test-Token: wrong-value"] # gitleaks:allow - invalid test token + status: 403 + missing-header: + url: http://127.0.0.1:8080/check + status: 403