Skip to content

feat: implement issue #638 — SonarCloud: JavaScript/TypeScript code quality - #639

Merged
don-petry merged 1 commit into
mainfrom
dev-lead/issue-638-20261020-2037
Oct 21, 2026
Merged

don-petry merged 1 commit into
mainfrom
dev-lead/issue-638-20261020-2037

Conversation

@don-petry

@don-petry don-petry commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

SonarCloud: JavaScript/TypeScript code quality

From the issue: 1 open SonarCloud finding(s) in combsmith/google-app-scripts, worst severity CRITICAL. Generated by the org SonarCloud Audit.

Risk

Low — 8 file(s) changed; no CI- or runtime-critical paths touched.

Test plan

Tests added/updated: src/gmail-to-drive-by-labels/tests/gas-utils.test.js. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the bats suite runs in CI.

Rollback

Revert this PR. No non-revertible side effects (no tags, migrations, or external state).

Monitoring

This PR's CI checks (Lint + bats) are the success/regression signal.

Closes #638

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Enhancements

    • Attachment content deduplication now uses SHA-256 fingerprints instead of MD5, improving hash strength while preserving the existing duplicate-detection workflow.
  • Documentation

    • Updated architecture, component, and processing documentation to reflect SHA-256 hashing.
  • Tests

    • Updated hashing tests and test utilities to validate SHA-256 results across supported file and blob inputs.

@don-petry
don-petry requested a review from a team as a code owner October 20, 2026 20:39
@don-petry don-petry added the auto-rebase:ready Opts a non-draft PR into auto-rebase without an approval (auto-rebase ready_label) label Oct 20, 2026
@chatgpt-codex-connector

This comment has been minimized.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

This comment has been minimized.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #639
No changes were committed, but the PR still can't be marked done: required check SonarCloud is still pending. The retry cron will re-attempt automatically. Next attempt after: 2026-10-20T21:10:44Z

@don-petry

Copy link
Copy Markdown
Collaborator Author

Note

@don-petry I reviewed this PR and no code changes were needed, but I can't mark it done yet: required check SonarCloud is still pending. I'll re-check automatically.
Next attempt after: 2026-10-20T21:10:44Z

@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 20:40
@sonarqubecloud

Copy link
Copy Markdown

@don-petry

Copy link
Copy Markdown
Collaborator Author

QA Lead — test-risk advisory

Risk tier: LOW. MD5 → SHA-256 doesn't change behaviour because no hash is stored: on every run, both the existing file's hash and the new file's hash are recomputed with the same algorithm. Dedup is not used for anything security-sensitive. The updated hex values in gas-utils.test.js are correct, known test vectors.

What I'd shore up (highest leverage first):

  • The deployed code.gs dedup path has no test coverage at all, and it looks broken. getFileHash in code.gs returns the raw computeDigest byte array, which is then compared with existingHash === newHash. Two separate arrays are never ===, so in real Apps Script the "duplicate skipped" branch should never fire. The bug was there before this PR. The suites miss it because they inject the hex-string getFileHash from gas-utils. Add a test that runs code.gs's own getFileHash on two identical blobs, or hex-encode the digest so both layers return the same thing.
  • The computeDigest mock in test-utils/setup.js ignores its algorithm argument. Passing undefined or a wrong enum would still pass. Assert that the algorithm is SHA_256 (or throw when it isn't) so this change is actually checked.
  • Add one negative test for the dedup flow (same size, different content → renamed copy) that goes through the real code.gs hash helper rather than the injected one.

Escalate? no. This PR is safe to merge. The ===-on-arrays dedup defect deserves its own follow-up issue.

Advisory only — I comment, I do not change code. Ground: BMAD Test Architecture
(bmad-tea v1.19.0). Opt out on this item with the qa-lead:hands-off label.

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-10-20T21:41:44Z.

@donpetry-bot

donpetry-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

@don-petry

Copy link
Copy Markdown
Collaborator Author

No description provided.

@don-petry
don-petry disabled auto-merge October 20, 2026 21:45
@don-petry

Copy link
Copy Markdown
Collaborator Author

The Codex code review encountered a process failure and did not generate findings. This is not a code issue — all CI checks (Node.js Tests, SonarCloud, CodeQL, etc.) are passing. The review can be retried by commenting @codex review if needed.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create an environment for this repo.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
The bot comment from `chatgpt-codex-connector[bot]` was a **non-actionable operational notice** — a code review process failure with no specific code findings. All CI checks (Node.js Tests, SonarCloud, CodeQL, coverage, etc.) are passing.
| Status | Details |
|--------|---------|
| **Bot** | chatgpt-codex-connector[bot] |
| **Issue type** | Code review process failure (not a code finding) |
| **Action taken** | Dispositioned original comment as `informational` |
| **Disposition marker** | `<!-- dev-lead:comment-disposition id=IC_kwDORFz9wc8AAAABd5FWTQ disposition=informational -->` |
| **Files changed** | None |
| **Reason** | The review failed to complete but generated no findings; all CI checks pass. The maintainer-comment gate will clear this notice. |
The PR is ready to merge — there are no code issues to address.

@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 21:46
@donpetry-bot

donpetry-bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

No description provided.

@don-petry
don-petry disabled auto-merge October 20, 2026 23:42
@don-petry

Copy link
Copy Markdown
Collaborator Author

CodeRabbit review complete with no actionable findings. The change correctly implements SHA-256 hashing to replace MD5, all tests pass, and pre-merge checks are clear.

@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
## Summary
**Bot:** coderabbitai[bot]
**Issues addressed:** 0 (no actionable findings)
**Disposition:** Posted `disposition=informational` on the CodeRabbit summary comment (node `IC_kwDORFz9wc8AAAABd5FkpQ`)
**Status:**
- CodeRabbit review: **No actionable comments** — clean review
- CI status: **All passing** (Node.js Tests, SonarCloud, CodeQL, etc.)
- Pre-merge checks: **All 5 passed** (description, title, linked issues, out-of-scope, docstring coverage)
The PR is ready — the CodeRabbit bot found no code quality issues, all tests pass, and the SHA-256 hashing change is correctly implemented to address SonarCloud finding S4790 (weak MD5 hash). The disposition clears the maintainer-comment gate.

@don-petry
don-petry enabled auto-merge (squash) October 20, 2026 23:43
@don-petry

Copy link
Copy Markdown
Collaborator Author

No description provided.

@don-petry
don-petry disabled auto-merge October 21, 2026 00:49
@don-petry

Copy link
Copy Markdown
Collaborator Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry
don-petry enabled auto-merge (squash) October 21, 2026 00:49

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review — APPROVED ✓

Risk: LOW
Reviewed commit: dfce684a59a1d28d42366da23e939428a2abe673
Review mode: triage-approved (single reviewer)

Summary

Changes the attachment-dedup fingerprint from MD5 to SHA-256 in src/gas-utils.js (Node crypto) and src/gmail-to-drive-by-labels/code.gs (Utilities.DigestAlgorithm.SHA_256). This clears SonarCloud rule javascript:S4790. The PR also updates the test mock, the test vectors, and the docs and comments. I agree with the triage verdict that this is low-risk. The hash is used only to compare two files' contents, not for security. No hash value is stored anywhere: both the existing file's hash and the new file's hash are recomputed on every run, so dedup behaves the same after the switch.

Linked issue analysis

Closes #638 (SonarCloud S4790, a weak hash algorithm in src/gas-utils.js). The fix replaces the algorithm instead of adding a NOSONAR suppression, which is what the issue's acceptance criteria ask for. The SonarCloud Quality Gate passed with 0 new issues. The issue is also set to close automatically once the audit counts zero findings, so Closes #638 is the right keyword.

Findings

No blocking findings.

  • Test vectors checked: I recomputed the new expected values locally and they match the standard SHA-256 digests of hello world, abc and test.
  • No leftover MD5 users: I searched the PR head and nothing else uses DigestAlgorithm.MD5 or md5, so taking MD5 out of the test-utils/setup.js mock breaks no other test. The only remaining mention is getMd5Checksum() in a proposal doc, which is unrelated.
  • Non-blocking, existed before this PR (raised by the QA-lead advisory): in code.gs, getFileHash returns the raw byte array from computeDigest, and the caller compares two of these with existingHash === newHash. Two separate arrays are never ===, so the deployed duplicate-skip branch probably never fires. This PR does not cause the bug and does not make it worse; it should get its own follow-up issue. The same goes for the computeDigest mock, which ignores its algorithm argument.
  • Secret scan: the run_secret_scanning MCP tool was not available in this run. The gitleaks check passed.

CI status

All checks are green: build-and-test, Node.js Tests, coverage, Playwright UI Tests, CodeQL (actions, javascript-typescript, python), SonarCloud and its Quality Gate, gitleaks, npm audit and AgentShield. The rest were skipped as not applicable. There are no unresolved review threads and no open questions from human reviewers. The Codex review failed to run (a process failure, already noted on the PR), and CodeRabbit reported nothing actionable.


Reviewed automatically by the PR-review agent (single-reviewer mode: opus 5.5 [opus 4.8, opus 4.7]). Reply if you need a human review.

@donpetry-bot

Copy link
Copy Markdown
Contributor

pr-review approved on PARTIAL advisory evidence: 2/5 required advisory bots reported before the gate's head-age-timeout fallback proceeded. Recorded for the miss-rate metric (#1596).

@don-petry
don-petry merged commit 580ab53 into main Oct 21, 2026
41 checks passed
@don-petry
don-petry deleted the dev-lead/issue-638-20261020-2037 branch October 21, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-rebase:ready Opts a non-draft PR into auto-rebase without an approval (auto-rebase ready_label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SonarCloud: JavaScript/TypeScript code quality

2 participants