Skip to content

Commit d43fca0

Browse files
authored
Merge pull request #17 from linuxfoundation/chore/apply-megalinter-skill
chore: apply MegaLinter v10.1.0 standards
2 parents 8e0e207 + 27af7b8 commit d43fca0

7 files changed

Lines changed: 60 additions & 98 deletions

File tree

‎.cspell.json‎

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
{
22
"language": "en",
3-
"dictionaries": [
4-
"companies",
5-
"filetypes",
6-
"fullstack",
7-
"softwareTerms"
8-
],
3+
"dictionaries": ["companies", "filetypes", "fullstack", "softwareTerms"],
94
"words": [
105
"aquasecurity",
116
"artipacked",
@@ -20,49 +15,39 @@
2015
"credstore",
2116
"ehthumbs",
2217
"esac",
18+
"flagwords",
2319
"fprintln",
20+
"gjson",
2421
"goarch",
2522
"gobin",
2623
"gofmt",
2724
"golangci",
2825
"goos",
2926
"gopath",
30-
"kics",
27+
"gotoolchain",
28+
"jdoe",
29+
"kwallet",
3130
"ldflags",
31+
"lfid",
3232
"lfx",
3333
"lfxv",
3434
"linuxfoundation",
35+
"localappdata",
3536
"memprof",
3637
"mgechev",
3738
"mktemp",
3839
"mtimes",
3940
"nolint",
41+
"passwordstore",
4042
"pipefail",
4143
"rundll",
4244
"techdocs",
45+
"tidwall",
4346
"trimpath",
4447
"urfave",
4548
"zizmor"
4649
],
47-
"flagWords": [
48-
"abort: cancel, end, fail, halt, stop, terminate",
49-
"abortion: cancelation, ending, failure, halting, stopping, termination",
50-
"blackhat: attacker, malicious",
51-
"black-hat: attacker, malicious",
52-
"whitehat: ethical, security, researcher",
53-
"white-hat: ethical, security, researcher",
54-
"cripple: disable, degrade, impact",
55-
"crippled: disabled, degraded, impacted",
56-
"grandfathered: legacy, exempted, preauthorized",
57-
"master: controller, primary, main, leader, parent",
58-
"slave: agent, replica, secondary, follower, child",
59-
"tribe: squad, team, group",
60-
"sanity-check: test, verify, validate",
61-
"whitelist: allowlist",
62-
"white-list: allow-list",
63-
"blacklist: denylist",
64-
"black-list: deny-list"
65-
],
50+
"flagWords": [],
6651
"ignorePaths": [
6752
".cspell.json",
6853
"CODEOWNERS",
@@ -74,9 +59,7 @@
7459
"languageSettings": [
7560
{
7661
"languageId": "markdown",
77-
"ignoreRegExpList": [
78-
"/^\\s*```\\s*(mermaid)[\\s\\S]*?^\\s*```/gm"
79-
]
62+
"ignoreRegExpList": ["/^\\s*```\\s*(mermaid)[\\s\\S]*?^\\s*```/gm"]
8063
}
8164
]
8265
}

‎.github/workflows/mega-linter.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
id: ml
3636
# Use the Go flavor. Keep this version in sync with the
3737
# `megalinter` target in the Makefile.
38-
uses: oxsecurity/megalinter/flavors/go@ef3e84b8b836d76db562d0f3ed7da61e8fd538bc # v9.6.0
38+
uses: oxsecurity/megalinter/flavors/go@9949bad031045f366be2467e00e8371a7328a2e2 # v10.1.0
3939
env:
4040
# Only Actions-specific values (secrets, runner behavior) belong
4141
# here. Generic MegaLinter/repo config belongs in .mega-linter.yml
@@ -44,6 +44,9 @@ jobs:
4444
# All available variables are described in documentation
4545
# https://megalinter.io/latest/configuration/
4646
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
# Lets Go-based linters download the go.mod toolchain when it is
48+
# newer than the Go bundled in the MegaLinter image.
49+
GOTOOLCHAIN: auto
4750
# Allow GITHUB_TOKEN for working around rate limits (aquasecurity/trivy#7668).
4851
REPOSITORY_TRIVY_UNSECURED_ENV_VARIABLES: GITHUB_TOKEN
4952
# zizmor's "artipacked" audit needs the GitHub API (to verify

‎.mega-linter.yml‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,32 @@
22
# SPDX-License-Identifier: MIT
33
---
44
GITHUB_COMMENT_REPORTER: false
5+
# Excludes locally generated CLI binaries from repository scans.
6+
ADDITIONAL_EXCLUDED_DIRECTORIES:
7+
- bin
58
DISABLE_LINTERS:
6-
# Prefer Revive.
7-
- GO_GOLANGCI_LINT
89
# yamllint is sufficient for us.
910
- YAML_PRETTIER
1011
DISABLE_ERRORS_LINTERS:
11-
# Currently disabled upstream by MegaLinter itself (supply chain
12-
# compromise). Keep it non-blocking here so a future upstream restore
13-
# doesn't unexpectedly break the build before we've reviewed it.
14-
- REPOSITORY_KICS
1512
# There's no easy local feedback loop for spelling issues before
1613
# pushing, so keep them non-blocking to avoid unnecessary PR cycles
1714
# for words that just need adding to the dictionary.
1815
- SPELL_CSPELL
1916
YAML_YAMLLINT_CONFIG_FILE: .yamllint
2017
SPELL_CSPELL_ANALYZE_FILE_NAMES: false
18+
SPELL_CSPELL_PRE_COMMANDS:
19+
- command: >-
20+
cp .cspell.json /tmp/cspell.json.orig &&
21+
curl -sSf --connect-timeout 5 --max-time 15 https://raw.githubusercontent.com/linuxfoundation/lfx-public-workflows/737873e045a02df2f66b09d8061b98997cdf1880/cspell/flagwords.json.snippet -o /tmp/flagwords.json.snippet &&
22+
test "$(grep -c '^[[:space:]]*"flagWords"[[:space:]]*:[[:space:]]*\[\],[[:space:]]*$' .cspell.json)" -eq 1 &&
23+
sed -i -e '/^[[:space:]]*"flagWords"[[:space:]]*:[[:space:]]*\[\],[[:space:]]*$/{r /tmp/flagwords.json.snippet' -e 'd}' .cspell.json
24+
cwd: workspace
25+
continue_if_failed: false
26+
SPELL_CSPELL_POST_COMMANDS:
27+
- command: cp /tmp/cspell.json.orig .cspell.json
28+
cwd: workspace
29+
# Allows Grype to complete repository scans over Docker bind mounts.
30+
REPOSITORY_GRYPE_TIMEOUT_SECONDS: 600
2131
# Ignore YAML files with templating macros; these typically fail linting and/or
2232
# schema checking.
2333
FILTER_REGEX_EXCLUDE: '(templates/.*\.yml|templates/.*\.yaml)'

‎AGENTS.md‎

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -236,44 +236,8 @@ release binaries may be missing even though the GitHub Release exists.
236236
keep dependencies current. This upgrades module dependencies only, not the
237237
Go toolchain itself (`go.mod`'s `go` directive) -- see the toolchain policy
238238
below before touching that.
239-
4. **Go toolchain version**: Freely bump `go.mod`'s `go` directive to the
240-
latest available *patch* release (e.g. `1.X.Y` → `1.X.{Y+1}`) to pick up
241-
security fixes. Do **not** bump the *minor* version (e.g. `1.X.x` →
242-
`1.{X+1}.x`) unless the user explicitly asks for it, **and** you've
243-
validated it against the Go version MegaLinter itself bundles --
244-
MegaLinter runs several linters (e.g. `golangci-lint`) against its own
245-
bundled Go version, and a `go.mod` directive newer than that bundled
246-
version breaks those checks.
247-
248-
To find MegaLinter's bundled Go version:
249-
250-
```bash
251-
# 1. Find the MegaLinter flavor and pinned version tag used in CI.
252-
grep -A1 'oxsecurity/megalinter' .github/workflows/*.yml
253-
# e.g. "uses: oxsecurity/megalinter/flavors/<flavor>@<sha> # <tag>"
254-
255-
# 2. Fetch that flavor's Dockerfile and read its GO_ALPINE_VERSION (or
256-
# GO_IMAGE_VERSION) build arg.
257-
curl -s "https://raw.githubusercontent.com/oxsecurity/megalinter/<tag>/flavors/<flavor>/Dockerfile" \
258-
| grep -i 'GO_ALPINE_VERSION\|GO_IMAGE_VERSION'
259-
```
260-
261-
`go.mod`'s `go` directive must never exceed that bundled version. Staying
262-
one minor version behind it (rather than matching its minor *and* patch
263-
exactly) leaves room to always take the latest patch release for security
264-
fixes without ever being blocked by MegaLinter's own bundled patch version
265-
lagging behind a newly disclosed vulnerability.
266-
267-
There's no built-in `go` subcommand to look up the latest patch release
268-
for a given minor version -- query the official `go.dev/dl` JSON feed
269-
instead:
270-
271-
```bash
272-
# Find the latest patch release for the minor version pinned in go.mod.
273-
MINOR=$(grep '^go ' go.mod | awk '{print $2}' | cut -d. -f1,2)
274-
curl -s "https://go.dev/dl/?mode=json&include=all" \
275-
| jq -r --arg m "go${MINOR}." '.[].version | select(startswith($m))' \
276-
| sort -V | tail -1
277-
```
239+
4. **Go toolchain version**: Follow the `lfx-megalinter` skill's Go version
240+
policy. It sets `go.mod` to the latest patch of the previous stable Go
241+
minor and caps it at the minor bundled by the pinned MegaLinter release.
278242
5. **Code Quality**: Run `make check` before commits
279243
6. **Documentation**: Update README.md for user-facing changes

‎Makefile‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ BINARY_NAME=lfx
88
CMD_DIR=./cmd/lfx
99
BUILD_DIR=./bin
1010

11+
# Run MegaLinter locally via Docker (matches CI Go flavor at v10.1.0).
12+
# Keep this digest in sync with .github/workflows/mega-linter.yml.
13+
MEGALINTER_IMAGE := ghcr.io/oxsecurity/megalinter-go@sha256:42e091a4bcbe9141fe420c2520ed7addf75ae60a0c9d42e3df1278eef1c90a88 # v10.1.0
14+
1115
# Build flags. Version is not injected via -ldflags: `go build` already
1216
# embeds a pseudo-version (encoding the VCS revision, commit time, and
1317
# dirty state) into the binary's module version, which main.go reads via
@@ -104,11 +108,9 @@ install-tools:
104108
*) echo "Warning: $$gobin is not in your PATH; installed tools (golangci-lint, revive) won't be found. Add it to your PATH, e.g.: export PATH=\"$$PATH:$$gobin\"" ;; \
105109
esac
106110

107-
# Run MegaLinter locally via Docker (matches CI Go flavor at v9.6.0).
108-
# Keep this version in sync with .github/workflows/mega-linter.yml.
109111
megalinter:
110-
docker pull ghcr.io/oxsecurity/megalinter-go:v9.6.0
111-
docker run --rm --platform linux/amd64 -v '$(CURDIR):/tmp/lint:rw' ghcr.io/oxsecurity/megalinter-go:v9.6.0
112+
docker pull $(MEGALINTER_IMAGE)
113+
docker run --rm --platform linux/amd64 -e GOTOOLCHAIN=auto -v '$(CURDIR):/tmp/lint:rw' $(MEGALINTER_IMAGE)
112114

113115
# Show help
114116
help:

‎go.mod‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// SPDX-License-Identifier: MIT
33
module github.com/linuxfoundation/lfx-cli
44

5-
go 1.25.14
5+
go 1.26.9
66

77
require (
88
github.com/99designs/keyring v1.2.2
9-
github.com/tidwall/gjson v1.19.0
9+
github.com/tidwall/gjson v1.20.0
1010
github.com/urfave/cli-docs/v3 v3.1.0
11-
github.com/urfave/cli/v3 v3.13.0
12-
golang.org/x/oauth2 v0.36.0
11+
github.com/urfave/cli/v3 v3.14.0
12+
golang.org/x/oauth2 v0.37.0
1313
)
1414

1515
require (
@@ -22,7 +22,7 @@ require (
2222
github.com/mtibben/percent v0.2.1 // indirect
2323
github.com/russross/blackfriday/v2 v2.1.0 // indirect
2424
github.com/tidwall/match v1.2.0 // indirect
25-
github.com/tidwall/pretty v1.2.1 // indirect
26-
golang.org/x/sys v0.47.0 // indirect
27-
golang.org/x/term v0.45.0 // indirect
25+
github.com/tidwall/pretty v1.2.2 // indirect
26+
golang.org/x/sys v0.49.0 // indirect
27+
golang.org/x/term v0.47.0 // indirect
2828
)

‎go.sum‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
2525
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
2626
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
2727
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
28-
github.com/tidwall/gjson v1.19.0 h1:xwxm7n691Uf3u5OFjzngavjGTh55KX5q/9w9xHW88JU=
29-
github.com/tidwall/gjson v1.19.0/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
28+
github.com/tidwall/gjson v1.20.0 h1:+agJ3rEzKcCXKDKo0ml26UROcpcAlnZyjq+TjbY5Fto=
29+
github.com/tidwall/gjson v1.20.0/go.mod h1:V37/opeE/JbLUOfH0QTXiNez2l0RUjYUhpT4szFQAfc=
3030
github.com/tidwall/match v1.2.0 h1:0pt8FlkOwjN2fPt4bIl4BoNxb98gGHN2ObFEDkrfZnM=
3131
github.com/tidwall/match v1.2.0/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
32-
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
33-
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
32+
github.com/tidwall/pretty v1.2.2 h1:dz1jrRuE7or/74V490B4/GP1pZm5WKlt2bgCP5A83w8=
33+
github.com/tidwall/pretty v1.2.2/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
3434
github.com/urfave/cli-docs/v3 v3.1.0 h1:Sa5xm19IpE5gpm6tZzXdfjdFxn67PnEsE4dpXF7vsKw=
3535
github.com/urfave/cli-docs/v3 v3.1.0/go.mod h1:59d+5Hz1h6GSGJ10cvcEkbIe3j233t4XDqI72UIx7to=
36-
github.com/urfave/cli/v3 v3.13.0 h1:Dr6jqMfIyyFsRVn7Nz5mqLsMY+ZMpfh3a0aMs+umPVY=
37-
github.com/urfave/cli/v3 v3.13.0/go.mod h1:vXn6HxPNccJSzQr2QvwVncOKrgYGIHU0HY5h8B2nQj4=
36+
github.com/urfave/cli/v3 v3.14.0 h1:a8414NQlHJs0c/iBsulKLzlES0n/lEAskbL2LKpU4/s=
37+
github.com/urfave/cli/v3 v3.14.0/go.mod h1:vXn6HxPNccJSzQr2QvwVncOKrgYGIHU0HY5h8B2nQj4=
3838
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
3939
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
40-
golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs=
41-
golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q=
42-
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
43-
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
44-
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
45-
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
40+
golang.org/x/oauth2 v0.37.0 h1:JUlcxA8oAtauLfiH8FX2/FkAWHAdi0QtGCGc+hofE98=
41+
golang.org/x/oauth2 v0.37.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58=
42+
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
43+
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
44+
golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM=
45+
golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY=
4646
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
4747
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

0 commit comments

Comments
 (0)