test(crypto): cover RS256 JWT signing for PKCS8 and PKCS1 keys - #725
Conversation
|
Note Gittensory Gate skippedPR closed before full evaluation. No late first comment was created.
💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
gittensory · advisory review Reviewed 1 changed file(s) — two independent AI reviewers. Changed files: Suggested action: 🛠️ Request changes. (reviewers split: request changes / merge) Address the suggestions below before merging. Reviewer A · Suggestions
Worth double-checking
Reviewer B · Suggestions
Worth double-checking
|
e3cf039 to
ccbe2ba
Compare
JSONbored
left a comment
There was a problem hiding this comment.
PR #725 — test(crypto): cover RS256 JWT signing for PKCS8 and PKCS1 keys
Author: jaso0n0818 | CI: ❌ validate FAIL | Status: Concerns
ACTION: REQUEST CHANGES
Highlights:
- Genuinely useful security-sensitive coverage for signRs256Jwt (GitHub App JWT) across PKCS#8 and legacy PKCS#1-with-escaped-newlines — a real gap.
- Clean conventional title, clear what/why, exact validation command listed.
Change requests / reasons:
- Latent bug: test uses crypto.subtle.generateKey but only imports generateKeyPairSync from node:crypto — global crypto not imported → ReferenceError where there's no crypto global. Use import { webcrypto as crypto } from "node:crypto".
- CI validate failing
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #725 +/- ##
=======================================
Coverage 96.69% 96.69%
=======================================
Files 94 94
Lines 13845 13845
Branches 5050 5050
=======================================
Hits 13388 13388
Misses 88 88
Partials 369 369 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JSONbored
left a comment
There was a problem hiding this comment.
PR #725 — test(crypto): cover RS256 JWT signing for PKCS8 and PKCS1 keys
Verdict: MERGE
Resolves issue: N/A (test-only, no linked issue)
CI: All green (test 1/2, lint, workers, codecov). Gittensory Context neutral.
Highlights:
- Meaningful, not padding: exercises both real branches of importPkcs8PrivateKey — direct PKCS#8 import and the legacy PKCS#1 path through the hand-rolled wrapPkcs1RsaPrivateKey DER-wrapper — with \n-escaped-newline normalization. Genuinely under-tested security-sensitive code (previously only via github-app mocks).
- Asserts the signing contract, not just "didn't throw": 3-part token, base64url signature with no +/= chars, header/payload decode to expected alg/iss. crypto.subtle is fine under vitest node env (confirmed by green shards).
Concerns / required changes:
- Optional only: tests verify token structure but don't cryptographically round-trip-verify the signature against the public key (would prove the PKCS#1 DER-wrapping is byte-correct). Not required — importKey would reject a malformed pkcs8.
Completeness vs issue: No linked issue; as test-only coverage it is correct, meaningful, and in-scope (src/utils/crypto.ts). No product behavior change.
Summary
Adds unit coverage for
signRs256Jwtinsrc/utils/crypto.ts, including PKCS#8 PEM keys and legacy PKCS#1 RSA PEM keys with escaped newlines.Why
GitHub App JWT signing is security-sensitive; the helper had no direct regression tests outside indirect
github-appmocks.Validation
No product behavior changes; tests only.