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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitleaks.toml → .betterleaks.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright The Linux Foundation and each contributor to LFX.
# SPDX-License-Identifier: MIT

title = "gitleaks config"
title = "betterleaks config"

[extend]
# useDefault will extend the base configuration with the default gitleaks config:
Expand All @@ -18,7 +18,7 @@ paths = [
'''.mypy_cache''',
'''./cmd/project-api/service_handler_test.go''',
'''./cmd/project-api/service_endpoint_test.go''',
'''(.*?)gitleaks\.toml$''',
'''(.*?)betterleaks\.toml$''',
'''(?i)(.*?)(png|jpeg|jpg|gif|doc|docx|pdf|bin|xls|xlsx|pyc|zip)$''',
'''(go.mod|go.sum)$''',
'''(.*?)(swagger\.yml|swagger\.yaml)$''',
Expand Down
File renamed without changes.
10 changes: 6 additions & 4 deletions .github/workflows/ko-build-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
Expand Down Expand Up @@ -51,15 +51,17 @@ jobs:
-B \
--platform linux/amd64,linux/arm64 \
-t ${{ github.sha }} \
-t ${{ steps.container_tag.outputs.tag }} \
-t "${VERSION}" \
--sbom spdx
- name: Build root-project-setup for PR
env:
VERSION: ${{ steps.container_tag.outputs.tag }}
run: |
ko build github.com/linuxfoundation/lfx-v2-project-service/scripts/root-project-setup \
-B \
--platform linux/amd64,linux/arm64 \
-t ${{ github.sha }} \
-t ${{ steps.container_tag.outputs.tag }} \
-t "${VERSION}" \
--sbom spdx
- name: Build project-cli for PR
env:
Expand All @@ -74,5 +76,5 @@ jobs:
-B \
--platform linux/amd64,linux/arm64 \
-t ${{ github.sha }} \
-t ${{ steps.container_tag.outputs.tag }} \
-t "${VERSION}" \
--sbom spdx
2 changes: 1 addition & 1 deletion .github/workflows/ko-build-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
contents: read
packages: write
steps:
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
Expand Down
31 changes: 20 additions & 11 deletions .github/workflows/ko-build-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
chart_version: ${{ steps.prepare.outputs.chart_version }}
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false

Expand All @@ -51,6 +51,7 @@ jobs:
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version-file: go.mod
cache: false

- name: Setup Ko
uses: ko-build/setup-ko@d006021bd0c28d1ce33a07e7943d48b079944c8d # v0.9
Expand All @@ -69,18 +70,20 @@ jobs:
ko build github.com/linuxfoundation/lfx-v2-project-service/cmd/project-api \
-B \
--platform linux/amd64,linux/arm64 \
-t ${{ github.ref_name }} \
-t ${{ steps.prepare.outputs.app_version }} \
-t "${GITHUB_REF_NAME}" \
-t "${VERSION}" \
-t latest \
--sbom spdx

- name: Build and publish root-project-setup image
env:
VERSION: ${{ steps.prepare.outputs.app_version }}
run: |
ko build github.com/linuxfoundation/lfx-v2-project-service/scripts/root-project-setup \
-B \
--platform linux/amd64,linux/arm64 \
-t ${{ github.ref_name }} \
-t ${{ steps.prepare.outputs.app_version }} \
-t "${GITHUB_REF_NAME}" \
-t "${VERSION}" \
-t latest \
--sbom spdx

Expand All @@ -96,8 +99,8 @@ jobs:
ko build github.com/linuxfoundation/lfx-v2-project-service/cmd/project-cli \
-B \
--platform linux/amd64,linux/arm64 \
-t ${{ github.ref_name }} \
-t ${{ steps.prepare.outputs.app_version }} \
-t "${GITHUB_REF_NAME}" \
-t "${VERSION}" \
-t latest \
--sbom spdx

Expand All @@ -113,7 +116,7 @@ jobs:
image_name: ${{ steps.publish-ghcr.outputs.image_name }}
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
persist-credentials: false

Expand Down Expand Up @@ -145,9 +148,11 @@ jobs:
- name: Sign the Helm chart in GHCR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IMAGE_NAME: ${{ steps.publish-ghcr.outputs.image_name }}
CHART_DIGEST: ${{ steps.publish-ghcr.outputs.digest }}
run: |
set -euo pipefail
cosign sign --yes '${{ steps.publish-ghcr.outputs.image_name }}@${{ steps.publish-ghcr.outputs.digest }}'
cosign sign --yes "${IMAGE_NAME}@${CHART_DIGEST}"

create-ghcr-helm-provenance:
needs:
Expand All @@ -156,7 +161,9 @@ jobs:
actions: read
id-token: write
packages: write
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0
# Tag ref required: pinning the commit SHA breaks SLSA builder ref resolution.
# yamllint disable-line rule:line-length
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@v2.1.0 # zizmor: ignore[unpinned-uses]
with:
image: ${{ needs.release-helm-chart.outputs.image_name }}
digest: ${{ needs.release-helm-chart.outputs.digest }}
Expand Down Expand Up @@ -194,7 +201,9 @@ jobs:
with:
client-id: ${{ env.TRIGGER_CLIENT_ID }}
private-key: ${{ env.TRIGGER_PRIVATE_KEY }}
owner: linuxfoundation
# zizmor flags owner plus repositories as all-repository access;
# repositories scopes the token, so this is a false positive.
owner: linuxfoundation # zizmor: ignore[github-app]
repositories: lfx-v2-argocd
permission-actions: write

Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ jobs:
- name: MegaLinter
id: ml
# Use the Go flavor.
uses: oxsecurity/megalinter/flavors/go@62c799d895af9bcbca5eacfebca29d527f125a57 # 9.1.0
uses: oxsecurity/megalinter/flavors/go@f2fe8c1cba37091848df3e524066c8c23ef353ed # v10.2.0
env:
# All available variables are described in documentation
# https://megalinter.io/configuration/
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Allow GITHUB_TOKEN for working around rate limits (aquasecurity/trivy#7668).
REPOSITORY_TRIVY_UNSECURED_ENV_VARIABLES: GITHUB_TOKEN
# Allow GITHUB_TOKEN for zizmor's GitHub API-backed audits (e.g. ref-version-mismatch).
ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES: GITHUB_TOKEN
# Allow Go to auto-select a compatible toolchain when go.mod requires a
# newer version than the one bundled in the MegaLinter image.
# The image defaults to GOTOOLCHAIN=local with Go 1.26. This lets the
# Go linters download the go.mod toolchain (Go 1.27).
GOTOOLCHAIN: auto
15 changes: 1 addition & 14 deletions .grype.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,4 @@
# Grype vulnerability scan configuration.
# See: https://github.com/anchore/grype#configuration

ignore:
# GHSA-hfvc-g4fc-pqhx affects go.opentelemetry.io/otel/sdk.
# Fixed in v1.43.0, which requires Go 1.25. Cannot upgrade until the MegaLinter
# Docker image (currently Go 1.24.7) supports Go 1.25.
- vulnerability: GHSA-hfvc-g4fc-pqhx

# GHSA-w8rr-5gcm-pp58 affects several opentelemetry exporter packages.
# Fixed versions (v1.43.0 / v0.19.0) require Go 1.25. Same constraint as above.
- vulnerability: GHSA-w8rr-5gcm-pp58

# GHSA-xmrv-pmrh-hhx2 affects github.com/aws/aws-sdk-go-v2 packages.
# Fixed in aws-sdk-go-v2/service/s3 v1.97.3 and eventstream v1.7.8, but upgrading
# these pulls in otel v1.43.0 transitively, which again requires Go 1.25.
- vulnerability: GHSA-xmrv-pmrh-hhx2
ignore: []
20 changes: 5 additions & 15 deletions .mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ DISABLE_ERRORS_LINTERS:
- REPOSITORY_CHECKOV
- REPOSITORY_DEVSKIM
YAML_YAMLLINT_CONFIG_FILE: .yamllint
REPOSITORY_KICS_ARGUMENTS: >-
scan --no-progress --exclude-severities="medium,low,info,trace" --exclude-paths="./api/project/v1/gen/*"
# zizmor's online audits (e.g. ref-version-mismatch, which verifies
# SHA-pinned action tags, and impostor-commit) need the GitHub API, which
# requires GITHUB_TOKEN.
ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES:
- GITHUB_TOKEN
SPELL_CSPELL_ANALYZE_FILE_NAMES: false
# Make sure Vale is setup to run with the styles it needs.
SPELL_VALE_PRE_COMMANDS:
Expand All @@ -43,16 +46,3 @@ API_SPECTRAL_FILTER_REGEX_EXCLUDE: "gen/"
FILTER_REGEX_EXCLUDE: '(templates/.*\.yml|templates/.*\.yaml)'
KUBERNETES_DIRECTORY: charts/lfx-v2-project-service
KUBERNETES_HELM_ARGUMENTS: charts/lfx-v2-project-service
# The golangci-lint bundled with MegaLinter is built with Go 1.26 and cannot
# load a go 1.27.3 module. Install golangci-lint v2.15.0 (checksum verified)
# and let go download the go.mod toolchain. Remove once a MegaLinter release
# ships golangci-lint >= 2.15.0 and Go >= 1.27.3.
GO_GOLANGCI_LINT_PRE_COMMANDS:
- command: >-
go env -w GOTOOLCHAIN=auto &&
curl -sSfL -o /tmp/golangci-lint.tar.gz
https://github.com/golangci/golangci-lint/releases/download/v2.15.0/golangci-lint-2.15.0-linux-amd64.tar.gz &&
echo "9b7fe6a6bf6334b98decf8d86b11415ea7889afdabdd1959fdce23af2a9ebcea /tmp/golangci-lint.tar.gz" | sha256sum -c - &&
tar -xzf /tmp/golangci-lint.tar.gz -C /tmp &&
install /tmp/golangci-lint-2.15.0-linux-amd64/golangci-lint /usr/bin/golangci-lint
cwd: "workspace"
80 changes: 24 additions & 56 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ The LFX V2 Project Service is a RESTful API service that manages projects within

### Key Technologies

- **Language**: Go 1.27.3+
- **Language**: Go 1.27.4+
- **API Framework**: Goa v3 (code generation framework)
- **Messaging**: NATS with JetStream for event-driven architecture
- **Storage**: NATS Key-Value stores (no traditional database)
Expand Down Expand Up @@ -242,72 +242,40 @@ scripts/ # One-off and operational programs and shell scripts (ad
### Prerequisites

```bash
# Install Go 1.27.3+
# Install Go 1.27.4+
# Install Goa framework
go install goa.design/goa/v3/cmd/goa@v3.22.6

# Install linting tools
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
```

### Go Toolchain Version

Freely bump `go.mod`'s `go` directive to the latest available *patch*
release (e.g. `1.X.Y` → `1.X.{Y+1}`) to pick up security fixes. Do **not**
bump the *minor* version (e.g. `1.X.x` → `1.{X+1}.x`) unless the user
explicitly asks for it, **and** you've validated it against the Go version
MegaLinter itself bundles — MegaLinter's `golangci-lint` binary is
statically compiled against a specific Go version and refuses to analyze a
module whose `go.mod` directive is newer than that. (This is a property of
`golangci-lint` itself, not of MegaLinter's `osv-scanner`/`trivy`-based
`REPOSITORY_OSV_SCANNER` check, which is a separate, unrelated linter.) A
`go.mod` directive newer than what `golangci-lint` was built with breaks it
outright. This is a hard ceiling with no environment-variable workaround —
`GOTOOLCHAIN: auto` only affects invocations of the `go` command itself
and does nothing for this precompiled binary's own internal version
checks (confirmed empirically: setting it in both the workflow and
`.mega-linter.yml` still failed).

Also be careful with `go get -u`/`go mod tidy`: an indirect dependency
bump (e.g. a Kubernetes client library) can silently drag `go.mod`'s `go`
directive forward with it if that dependency's own `go.mod` requires a
newer Go version than the current directive. Check `git diff -- go.mod`
after any dependency refresh and revert/pin the offending dependency to an
older compatible release if it pulled the directive past the validated
ceiling.

To find MegaLinter's bundled Go version:
### Go version

```bash
# 1. Find the MegaLinter flavor and pinned version tag used in CI.
grep -A1 'oxsecurity/megalinter' .github/workflows/*.yml
# e.g. "uses: oxsecurity/megalinter/flavors/<flavor>@<sha> # <tag>"

# 2. Fetch that flavor's Dockerfile and read its GO_ALPINE_VERSION build
# arg -- this is what the final image installs as `go`, not
# GO_IMAGE_VERSION (which only applies to an intermediate builder
# stage).
curl -s "https://raw.githubusercontent.com/oxsecurity/megalinter/<tag>/flavors/<flavor>/Dockerfile" \
| grep -i 'GO_ALPINE_VERSION'
```
This repo targets Go 1.27.x (currently 1.27.4, the latest patch). This
supersedes the Go version policy in the `lfx-megalinter` skill, which targets
the latest stable minor minus one: don't move `go.mod` back to Go 1.26. Take
every 1.27.x patch release, and update `go.mod`, this file, `DEVELOPMENT.md`
and the script READMEs together (`git grep -nE '1\.27\.[0-9]+'` finds them).
Release images are built with the `go.mod` version, since the ko build
workflows read it through `go-version-file: go.mod`.

MegaLinter (v10.2.0) runs Go 1.26.10 in its image, so
`.github/workflows/mega-linter.yml` sets `GOTOOLCHAIN: auto` to let its Go
linters download the `go.mod` toolchain. Its bundled golangci-lint 2.15.0 is
built with Go 1.27.0 and lints this module. osv-scanner's govulncheck call
analysis is built with Go 1.26 and cannot load it, so osv-scanner falls back
to matching vulnerabilities by version: any known vulnerability in a
dependency version fails the check, reachable or not. Moving to Go 1.28 needs
a MegaLinter release whose bundled golangci-lint is built with Go 1.28.

Check `git diff -- go.mod` after `go get -u` or `go mod tidy`: a dependency
whose own `go.mod` requires a newer Go can drag the `go` directive forward
with it. Revert or pin that dependency if it moves the directive past 1.27.

`go.mod`'s `go` directive must never exceed that bundled version at the
*minor* version level (e.g. `1.X`). Note this is a proxy for what
`golangci-lint`'s own binary was built with, not a guarantee — if a
MegaLinter run still fails after following this procedure, check
`golangci-lint --version` inside the pinned MegaLinter image directly to
see the Go version it actually reports. `golangci-lint`'s own version
check normalizes `go.mod`'s `go` directive down to its major/minor
components before comparing, so a newer *patch* release within the same
minor version as MegaLinter's bundled Go does not get blocked — the real
ceiling is matching MegaLinter's bundled `golangci-lint` minor version,
not staying behind its exact patch release.

There's no built-in `go` subcommand to look up the latest patch release for
a given minor version — query the official `go.dev/dl` JSON feed instead:
To find the latest patch release for the minor version pinned in `go.mod`:

```bash
# Find the latest patch release for the minor version pinned in go.mod.
MINOR=$(grep '^go ' go.mod | awk '{print $2}' | cut -d. -f1,2)
curl -s "https://go.dev/dl/?mode=json&include=all" \
| jq -r --arg m "go${MINOR}." '.[].version | select(startswith($m))' \
Expand Down
2 changes: 1 addition & 1 deletion DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This guide provides comprehensive instructions for developers working on the LFX

Before you begin development, ensure you have the following tools installed:

- **Go 1.27.3+** - [Download and install Go](https://golang.org/dl/). The exact version is the `go` directive in `go.mod`.
- **Go 1.27.4+** - [Download and install Go](https://golang.org/dl/). The exact version is the `go` directive in `go.mod`.
- **Goa v3** - Code generation framework

```bash
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ RUN go build -o /go/bin/project-svc -trimpath -ldflags="-w -s" github.com/linuxf
# Run our go binary standalone
FROM cgr.dev/chainguard/static:latest

# Implicit with base image; setting explicitly for linters.
USER nonroot
# Numeric UID of the Chainguard nonroot user (implicit with the base image).
USER 65532

COPY --from=builder /go/bin/project-svc /cmd/project-api

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ This service uses the generic FGA sync handlers for managing fine-grained access
--version 0.1.12
```

2. Install the `lfx-v2-project-service` helm chart from this current repository. You have two options: either install from the OCI registry or from the source. If you don't plan to develop the service, you can just use the packaged version from the [github packages](https://github.com/linuxfoundation/lfx-v2-project-service/pkgs/container/lfx-v2-project-service%2Fchart%2Flfx-v2-project-service). <!-- markdown-link-check-disable-line -->
2. Install the `lfx-v2-project-service` helm chart from this current repository. You have two options: either install from the OCI registry or from the source. If you don't plan to develop the service, you can just use the packaged version from the [github packages](https://github.com/linuxfoundation/lfx-v2-project-service/pkgs/container/lfx-v2-project-service%2Fchart%2Flfx-v2-project-service).

```bash
# From OCI registry
Expand Down Expand Up @@ -247,7 +247,7 @@ This service uses the generic FGA sync handlers for managing fine-grained access
project_super_admin
```

Currently, you should use the existing [token helper script](https://github.com/linuxfoundation/lfx-architecture-scratch/tree/main/2024-12%20ReBAC%20Demo/token_helper) to generate the ID token. The script is only accessible if you are LF staff. The team has a TODO in order to include the helper script in a public repo or come up with a better solution for generating ID tokens for local testing. <!-- markdown-link-check-disable-line -->
Currently, you should use the existing [token helper script](https://github.com/linuxfoundation/lfx-architecture-scratch/tree/main/2024-12%20ReBAC%20Demo/token_helper) to generate the ID token. The script is only accessible if you are LF staff. The team has a TODO in order to include the helper script in a public repo or come up with a better solution for generating ID tokens for local testing.

If you have access to the token helper script, run the following command to get the ID token. Note that you will be prompted in your web browser to log in as one of the valid Authelia users. Use the kubernetes secret `authelia-users` as previously mentioned to determine the password for each user. Use the username and password for the user you want to authenticate with.

Expand Down
Loading
Loading