Skip to content

Update tool dependencies and fix new lint issues#36702

Merged
silverwind merged 9 commits into
go-gitea:mainfrom
silverwind:silverwind/update-tool-deps
Feb 26, 2026
Merged

Update tool dependencies and fix new lint issues#36702
silverwind merged 9 commits into
go-gitea:mainfrom
silverwind:silverwind/update-tool-deps

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented Feb 22, 2026

Summary

  • Update golangci-lint v2.9.0 → v2.10.1, misspell v0.7.0 → v0.8.0, actionlint v1.7.10 → v1.7.11
  • Fix 20 new QF1012 staticcheck findings by using fmt.Fprintf instead of WriteString(fmt.Sprintf(...))
  • Fix SA1019: replace deprecated ecdsa.PublicKey field access with PublicKey.Bytes() for JWK encoding, with SEC 1 validation and curve derived from signing algorithm
  • Add unit test for ToJWK() covering P-256, P-384, and P-521 curves, also verifying correct coordinate padding per RFC 7518
  • Remove dead staticcheck linter exclusion for "argument x is overwritten before first use"

Test plan

  • make lint-go passes with 0 issues
  • go test ./services/oauth2_provider/ -run TestECDSASigningKeyToJWK passes for all curves

🤖 Generated with Claude Code

Update golangci-lint v2.9.0 to v2.10.1, misspell v0.7.0 to v0.8.0,
actionlint v1.7.10 to v1.7.11. Fix new QF1012 staticcheck findings by
using fmt.Fprintf instead of WriteString(fmt.Sprintf(...)). Add nolint
for SA1019 on ecdsa.PublicKey.X/Y deprecated in Go 1.26.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 22, 2026
silverwind and others added 2 commits February 22, 2026 08:49
Extract EC coordinates from the uncompressed SEC 1 byte representation
(0x04 || X || Y) returned by PublicKey.Bytes() instead of directly
accessing the deprecated pubKey.X and pubKey.Y fields.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract EC coordinates from the uncompressed SEC 1 byte representation
(0x04 || X || Y) returned by PublicKey.Bytes(), and derive the curve
name from coordinate length, avoiding all deprecated ecdsa.PublicKey
fields (X, Y, Curve).

This also fixes a latent RFC 7518 compliance issue where big.Int.Bytes()
could produce shorter-than-expected coordinates by stripping leading
zeros (e.g. for P-521).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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

This PR updates repository tooling (lint-related dependencies) and applies code changes needed to satisfy new linter/staticcheck findings, including a crypto/JWK update for ECDSA keys used by the OAuth2/OIDC provider.

Changes:

  • Bump lint tool dependencies in the Makefile (golangci-lint, misspell, actionlint).
  • Replace WriteString(fmt.Sprintf(...)) patterns with fmt.Fprintf(...) across multiple string/buffer builders to address new linter findings.
  • Update ECDSA JWK encoding to use SEC 1 uncompressed point bytes (avoiding deprecated field access and preserving leading zeros), and add unit coverage for P-256/P-384/P-521.

Reviewed changes

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

Show a summary per file
File Description
services/webhook/wechatwork.go Use fmt.Fprintf to build commit text (lint fix).
services/webhook/telegram.go Use fmt.Fprintf for commit list formatting (lint fix).
services/webhook/slack.go Use fmt.Fprintf for attachment text (lint fix).
services/webhook/msteams.go Use fmt.Fprintf for commit text (lint fix).
services/webhook/matrix.go Use fmt.Fprintf when building Matrix HTML content (lint fix).
services/webhook/feishu.go Use fmt.Fprintf for header text (lint fix).
services/webhook/discord.go Use fmt.Fprintf for commit text (lint fix).
services/release/notes.go Use fmt.Fprintf when building release notes (lint fix).
services/oauth2_provider/jwtsigningkey.go Change ECDSA ToJWK() to derive coordinates from SEC 1 bytes and map curve name from coordinate length.
services/oauth2_provider/jwtsigningkey_test.go Add unit test verifying JWK output for P-256/P-384/P-521 (including fixed coordinate sizes).
services/gitdiff/gitdiff.go Use fmt.Fprintf for synthetic patch header generation (lint fix).
routers/web/repo/setting/lfs.go Use fmt.Fprintf while building LFS file HTML fragments (lint fix).
modules/git/foreachref/format.go Use fmt.Fprintf when composing git for-each-ref format flag (lint fix).
models/repo/repo.go Use fmt.Fprintf for repository size details string formatting (lint fix).
Makefile Bump lint tool dependency versions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread services/oauth2_provider/jwtsigningkey.go Outdated
Instead of inferring the curve name from coordinate length (which could
be ambiguous), derive it from the JWT signing algorithm. Also validate
that the SEC 1 point encoding has the 0x04 uncompressed prefix and the
expected total length.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

Posted by @silverwind's AI assistant (Claude)

Did an in-depth validation of the ToJWK() changes:

  • ecdsa.PublicKey.Bytes() is guaranteed to return uncompressed SEC 1 format (0x04 || X || Y) — Go's implementation internally uses FillBytes which always produces fixed-length zero-padded coordinates. There is no compressed point code path.
  • The 0x04 prefix and length checks are defensive sanity checks that shouldn't trigger for well-formed keys but are good practice.
  • The old code using big.Int.Bytes() had a latent bug: it strips leading zero bytes, so ~1/256 of the time a coordinate would be one byte short, violating RFC 7518's requirement that coordinates "MUST be the full size of a coordinate for the curve." This is the same class of bug as keycloak/keycloak#14933. The new code fixes this.
  • Coordinate lengths are correct: P-256=32, P-384=48, P-521=66 (ceil(bitSize/8)).
  • base64.RawURLEncoding produces unpadded base64url, matching the JOSE/RFC 7518 specification.
  • Curve is now derived from the JWT signing algorithm (ES256/ES384/ES512) instead of being inferred from coordinate length, avoiding potential ambiguity.

Comment thread services/oauth2_provider/jwtsigningkey.go Outdated
silverwind and others added 2 commits February 22, 2026 12:04
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread services/oauth2_provider/jwtsigningkey.go
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 22, 2026
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 26, 2026
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 26, 2026
@silverwind silverwind enabled auto-merge (squash) February 26, 2026 18:35
@silverwind silverwind merged commit f7f55a3 into go-gitea:main Feb 26, 2026
26 checks passed
@silverwind silverwind deleted the silverwind/update-tool-deps branch February 26, 2026 19:13
@GiteaBot GiteaBot added this to the 1.26.0 milestone Feb 26, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 26, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 27, 2026
* giteaofficial/main:
  Filter out untracked files from spellchecking (go-gitea#36756)
  Fix CSS stacking context issue in actions log (go-gitea#36749)
  Fix milestone/project text overflow in issue sidebar (go-gitea#36741)
  Update tool dependencies and fix new lint issues (go-gitea#36702)
  Instance-wide (global) info banner and maintenance mode (go-gitea#36571)
  Add created_by filter to SearchIssues (go-gitea#36670)
  Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714)
silverwind added a commit to silverwind/gitea that referenced this pull request Feb 27, 2026
* origin/main:
  Move Fomantic dropdown CSS to custom module (go-gitea#36530)
  Use "Enable Gravatar" but not "Disable" (go-gitea#36771)
  feat: add branch_count to repository API (go-gitea#35351) (go-gitea#36743)
  Deprecate RenderWithErr (go-gitea#36769)
  Lazy-load some Vue components, fix heatmap chunk loading on every page (go-gitea#36719)
  Filter out untracked files from spellchecking (go-gitea#36756)
  Fix CSS stacking context issue in actions log (go-gitea#36749)
  Fix milestone/project text overflow in issue sidebar (go-gitea#36741)
  Update tool dependencies and fix new lint issues (go-gitea#36702)
  Instance-wide (global) info banner and maintenance mode (go-gitea#36571)
  Add created_by filter to SearchIssues (go-gitea#36670)
  Inline and lazy-load EasyMDE CSS, fix border colors (go-gitea#36714)

# Conflicts:
#	templates/repo/issue/view_content/pull_merge_box.tmpl
#	web_src/js/features/repo-issue-pull.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. topic/code-linting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants