Skip to content

fix(ci): exclude self-contained sub-apps from MegaLinter linters#4892

Open
devantler wants to merge 5 commits into
mainfrom
claude/ci-megalinter-exclude-desktop-cgo
Open

fix(ci): exclude self-contained sub-apps from MegaLinter linters#4892
devantler wants to merge 5 commits into
mainfrom
claude/ci-megalinter-exclude-desktop-cgo

Conversation

@devantler
Copy link
Copy Markdown
Contributor

@devantler devantler commented May 26, 2026

🤖 Generated by the Daily AI Assistant

What this PR does

Excludes the self-contained sub-apps from MegaLinter, so the 🧹 Lint - mega-linter job's duplicate detection stops flagging code that lives in app-private toolchains:

  • jscpd — all 6 reported TypeScript clones were inside vsce/ (the self-contained VS Code extension). Added vsce/, web/ui/ and desktop/ to .jscpd.json's ignore list (jscpd is a "project" linter, so it reads .jscpd.json ignore — not MegaLinter's FILTER_REGEX_EXCLUDE). This drops jscpd from 7 clones to 1. ✅ verified in CI (run on 43306b57/04c61f02).
  • desktop cgo filter (original commit) — keeps desktop/.* in FILTER_REGEX_EXCLUDE so the per-file repo-wide linters skip the separate cgo module.

This is intentionally scoped to the clean config layer: the one change that monotonically reduces the lint failures with correct, low-risk config.

The lint gate masks real backlogs — three remaining blockers (this PR alone does NOT turn it green)

Investigation showed the lint job has been failing on three independent linters, two of which were masking real findings behind environmental failures:

  1. jscpd — 1 real in-tree Go clone. pkg/svc/tenant/argocd.go [400:413]pkg/fsutil/configmanager/talos/manager.go [228:241] (the YAML-files-in-a-directory loop; talos already factored its copy into forEachYAMLFile). With threshold: 0 this still fails after the sub-app exclusion. Clean fix = a shared fsutil helper used by both — but the two copies differ in file-reading (fsutil.ReadFileSafe vs os.ReadFile+//nolint:gosec), so unifying them is a security-sensitive refactor that deserves its own reviewed PR.
  2. zizmor — 401 masks a ~119-finding backlog. MegaLinter strips GITHUB_TOKEN, so zizmor can't reach the GitHub API and reports a single HTTP 401. Passing the token (ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES: [GITHUB_TOKEN]) lets it authenticate — but it then completes its audits and surfaces ~119 findings (incl. High-confidence github-app "dangerous use of GitHub App tokens" in cd.yaml). So the token fix makes zizmor functional, not passing; the revealed findings are a separate triage effort and were deliberately not bundled here (it would raise the error count, not reduce it).
  3. osv-scanner — cgo crash masks a dependency-vuln backlog (security). In the MegaLinter go image, osv-scanner scan source --recursive . crashes type-checking desktop/'s webview cgo (could not import C) and aborts before scanning. Running the same command in the standalone osv-scanner:2.3.8 image (no Go toolchain) completes and surfaces ~68 advisories on indirect deps (x/crypto 0.51→0.52, x/net 0.54→0.55, x/image 0.38→0.39, plus k8s.io/kubernetes no-fix meta-module false-positives). Fix path: make the scanner functional (--no-call-analysis=all, validate in the go image) and bump the vulnerable indirect deps and osv-ignore the k8s findings. Security + dependency work, not config.

Net: the gate needs a coordinated effort (Go-clone refactor + zizmor findings triage + osv dep/security work) to go green. This PR ships the one clean config win and maps the rest.

Copilot AI review requested due to automatic review settings May 26, 2026 12:16
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@devantler devantler marked this pull request as ready for review May 26, 2026 13:42
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

MegaLinter analysis: Error

❌ COPYPASTE / jscpd - 1 error
Clone found (go):
 - pkg/svc/tenant/argocd.go [400:61 - 413:37] (13 lines, 99 tokens)
   pkg/fsutil/configmanager/talos/manager.go [228:64 - 241:37]

┌────────────┬────────────────┬─────────────┬──────────────┬──────────────┬──────────────────┬───────────────────┐
│ Format     │ Files analyzed │ Total lines │ Total tokens │ Clones found │ Duplicated lines │ Duplicated tokens │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ toml       │ 6              │ 64          │ 277          │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ go         │ 588            │ 97394       │ 638699       │ 1            │ 13 (0.01%)       │ 99 (0.02%)        │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ markdown   │ 7              │ 300         │ 1212         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ css        │ 1              │ 24          │ 92           │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ smarty     │ 1              │ 63          │ 1039         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ typescript │ 1              │ 6           │ 78           │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ javascript │ 1              │ 147         │ 1421         │ 0            │ 0 (0%)           │ 0 (0%)            │
├────────────┼────────────────┼─────────────┼──────────────┼──────────────┼──────────────────┼───────────────────┤
│ Total:     │ 605            │ 97998       │ 642818       │ 1            │ 13 (0.01%)       │ 99 (0.02%)        │
└────────────┴────────────────┴─────────────┴──────────────┴──────────────┴──────────────────┴───────────────────┘
Found 1 clones.
HTML report saved to megalinter-reports/copy-paste/html/
ERROR: jscpd found too many duplicates (0.01%) over threshold (0%)
Error: ERROR: jscpd found too many duplicates (0.01%) over threshold (0%)
    at ThresholdReporter.report (/node-deps/node_modules/@jscpd/finder/dist/index.js:615:13)
    at /node-deps/node_modules/@jscpd/finder/dist/index.js:109:18
    at Array.forEach (<anonymous>)
    at /node-deps/node_modules/@jscpd/finder/dist/index.js:108:22
    at async /node-deps/node_modules/jscpd/dist/bin/jscpd.js:9:5
❌ REPOSITORY / osv-scanner - 1 error
Scanning dir .
Starting filesystem walk for root: /
Scanned docs/package-lock.json file and found 549 packages
Scanned desktop/go.mod file and found 401 packages
Scanned web/ui/package-lock.json file and found 187 packages
Scanned go.mod file and found 965 packages
Scanned vsce/package-lock.json file and found 592 packages
End status: 307 dirs visited, 2028 inodes visited, 5 Extract calls, 263.647654ms elapsed, 263.647845ms wall time
Filtered 1 local/unscannable package/s from the scan.
Failed to run code analysis (govulncheck) on 'desktop/go.mod' because govulncheck: loading packages: 
There are errors with the provided package patterns:

-: # github.com/webview/webview_go
# [pkg-config --cflags  -- gtk+-3.0 webkit2gtk-4.0]
Package gtk+-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk+-3.0.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk+-3.0' not found
Package 'webkit2gtk-4.0' not found
/go/pkg/mod/github.com/webview/webview_go@v0.0.0-20240831120633-6173450d4dd6/webview.go:26:8: could not import C (no metadata for C)
desktop/main.go:64:42: cannot use webview.HintNone (constant unknown with invalid type) as webview.Hint value in argument to view.SetSize

For details on package patterns, see https://pkg.go.dev/cmd/go#hdr-Package_lists_and_patterns.

(the Go toolchain is required)
❌ ACTION / zizmor - 1 error
INFO zizmor: 🌈 zizmor v1.25.0
fatal: no audit was performed
'artipacked' audit failed on file://.github/workflows/cd.yaml

Caused by:
    0: error in 'artipacked' audit
    1: couldn't list tags for actions/checkout
    2: request error while accessing GitHub API
    3: HTTP status client error (401 Unauthorized) for url (https://github.com/actions/checkout.git/git-upload-pack)


[ZizmorLinter] Zizmor failed to reach the GitHub API.
To allow zizmor to use GITHUB_TOKEN, add the following to your .mega-linter.yml:
ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES:
  - GITHUB_TOKEN

✅ Linters with no issues

actionlint, git_diff, hadolint, jsonlint, lychee, markdown-table-formatter, markdownlint, prettier, prettier, stylelint, syft, trivy-sbom, trufflehog, v8r, v8r, yamllint

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

The CodeQL default-setup analysis on this PR failed at 12:16:50Z with
"action could not be found at URI codeload.github.com/.../codeql-action"
(the 2026-05-26 GitHub Actions outage). The code_scanning ruleset rule
gates merge on a successful CodeQL analysis, so a fresh run is needed.
The Actions rerun API rejects default-setup analyses, so this empty
commit moves the head to trigger a new pull_request analysis.
@ksail-bot ksail-bot Bot enabled auto-merge May 26, 2026 15:19
@devantler
Copy link
Copy Markdown
Contributor Author

🤖 Generated by the Daily AI Assistant

Corrected root cause — this PR's FILTER_REGEX_EXCLUDE: desktop/.* does not unblock the merge. CodeQL was cleared by the 7a89c520 re-trigger, so the only remaining gate is the 🧹 Lint - mega-linter job in ✅ Validate Go Project. That job fails on three independent linters, and a file-list filter addresses none of them:

Descriptor Linter Errs Cause Fix
REPOSITORY osv-scanner v2.3.8 1 Megalinter runs osv-scanner scan source --recursive ., whose Go call-graph analysis type-checks the whole root module. desktop/ has no own go.mod, so it's part of …/ksail/v7 and gets loaded → could not import C on the cgo desktop/main.go. A whole-module source scan ignores FILTER_REGEX_EXCLUDE (that only filters file-based linters). REPOSITORY_OSV_SCANNER_ARGUMENTS: --no-call-analysis=all — keeps lockfile vuln scanning, drops the cgo build (validate locally).
ACTION zizmor v1.25.0 1 couldn't list tags for actions/checkoutHTTP 401: megalinter strips GITHUB_TOKEN, so zizmor's online audits (artipacked) can't reach the GitHub API. ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES: [GITHUB_TOKEN] — identical to the fix already merged in go-template#63.
COPYPASTE jscpd 7 7 clones vs a 0% threshold; 6 in vsce/ (self-contained TS extension), 1 in Go (pkg/svc/tenant/argocd.gopkg/fsutil/configmanager/talos/manager.go). Pre-existing — not introduced here. Policy call: exclude the self-contained TS sub-app(s) from repo-wide jscpd (mirrors the existing web/ui/ exclusion) + refactor or accept the one 13-line Go clone.

The same gate blocks the dependabot backlog (#4881#4890). Parts 1 + 2 are mechanical; part 3 is a maintainer-policy decision (refactor vs. exclude/threshold). I'll prepare the validated config fix via a local megalinter run on the next substantive pass. Flagging now so this PR isn't merged expecting the desktop/.* exclusion alone to clear the gate.

…pps from jscpd

MegaLinter's lint job fails on three independent linters; this resolves the two
config-fixable ones:

- zizmor: MegaLinter strips GITHUB_TOKEN from the linter env, so zizmor hits HTTP
  401 when resolving action tags. ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES lets it
  authenticate (same fix as go-template's .mega-linter.yml).
- jscpd: all 6 reported clones live inside vsce/ (the self-contained VS Code
  extension). Exclude vsce/, web/ui/ and desktop/ — the self-contained sub-apps
  already kept out of the repo-wide linters — from duplicate detection.

The remaining two lint failures need more than config and are tracked separately:
osv-scanner (a cgo crash in the MegaLinter image masks a dependency-vuln backlog)
and one in-tree Go clone (argocd.go <-> talos/manager.go) that needs a refactor.
@devantler devantler changed the title fix(ci): exclude cgo desktop/ module from MegaLinter repo-wide linters fix(ci): pass GITHUB_TOKEN to zizmor and exclude self-contained sub-apps from jscpd May 26, 2026
Drop the zizmor ACTION_ZIZMOR_UNSECURED_ENV_VARIABLES change added in the previous
commit. Passing GITHUB_TOKEN does fix the HTTP 401, but it lets zizmor authenticate
and complete its audits, which then surfaces a backlog of ~119 findings (incl. High-
confidence github-app App-token warnings) that the 401 had been masking — so it
raises the lint job's error count instead of reducing it, and that backlog is its own
triage effort, not part of this config PR.

This PR therefore keeps only the jscpd change: excluding the self-contained sub-apps
(vsce/, web/ui/, desktop/) from duplicate detection, which drops jscpd from 7 clones
to 1 (the real in-tree Go clone, tracked for a separate refactor).
Copilot AI review requested due to automatic review settings May 26, 2026 17:42
@devantler devantler changed the title fix(ci): pass GITHUB_TOKEN to zizmor and exclude self-contained sub-apps from jscpd fix(ci): exclude self-contained sub-apps from MegaLinter linters May 26, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread .mega-linter.yml
Comment on lines +26 to +30
# (webview C bindings, kept out of the static ksail binary); MegaLinter's containerized Go
# analysis cannot import "C" without the desktop C deps installed, so it fails with
# "could not import C" / "webview.HintNone unknown invalid type". Real CI builds and tests
# desktop/ via dedicated jobs, so exclude it from the repo-wide linters here too.
FILTER_REGEX_EXCLUDE: (megalinter-reports/.*|web/ui/.*|desktop/.*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🫴 Ready

Development

Successfully merging this pull request may close these issues.

2 participants