Repository navigation
Conversation
This patch is to resolve Issue hyperdxio#3390 - when running HyperDX against ClickHouse in FIPS mode the MD5 function isn't available, so viewing some logs fails, because MD5 is not FIPS-compliant. This patch was generated using Cursor, running Composer 2.5 Fast. All relevant tests still pass. Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: dfb4b59 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@hercynium is attempting to deploy a commit to the HyperDX Team on Vercel. A member of the Team first needs to authorize it. |
|
Hi @hercynium, thanks for the pull request! Before we review code from a first-time contributor, a maintainer vouches for them, and you're not on our list yet. There's nothing else to file and this PR stays open — a maintainer will look at it, usually within a day or two, and vouch for you right here if it's a genuine attempt at the problem. To make that quick, check the PR description has:
More detail in our contributing guide. |
PR Review
3 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 3 minor 1 posted as inline comment(s) on the changed lines. 2 listed below. Findings outside the changed lines2 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
[Medium impact] The PR appears safe to merge; no actionable issues remain. SummaryReplaces
Reviews (19) · Last reviewed commit: "test: drive row WHERE SHA256 cases from ..." · Reviewed by Greptile |
Deep Review✅ No critical issues found. This is a well-contained MD5→SHA256 swap for FIPS-mode ClickHouse compatibility. The hash truncation is correctly reworked to match ClickHouse Key correctness points verified during synthesis:
🔵 P3 nitpicks (2)
Reviewers (2 returned before synthesis): performance, previous-comments. Six further reviewers (correctness, adversarial, testing, maintainability, kieran-typescript, project-standards) were dispatched but had not returned at synthesis time; the findings above are drawn from direct diff analysis and the completed reviewers. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
|
TBH... I've kind of vibe-coded this and I don't like what I see since the initial commit. I'm going to go back and re-work some things manually. Difficulty is that I don't know TypeScript, but it doesn't seem all that different from other langs I do know. |
201f1e3 to
0eeb80a
Compare
…tUTF8
ClickHouse's leftUTF8(?, 1000) truncates by Unicode code points, but the
client-side SHA256 was using JS substring, which counts UTF-16 code units.
For strings containing non-BMP characters (e.g. emoji), this produced a
different hash than the database would compute, breaking row lookups.
Update both app and CLI row-where helpers to slice by code point with
Array.from(value).slice(0, 1000).join(''), and add tests for emoji strings.
Hoist the ClickHouse leftUTF8-matching helper so app and CLI row lookups stay in sync and cannot drift silently. Co-authored-by: Cursor <cursoragent@cursor.com>
Match the app row-WHERE builder so null JSON columns are not hashed as an empty string. Co-authored-by: Cursor <cursoragent@cursor.com>
| let prefix = ''; | ||
| let n = 0; | ||
| for (const ch of value) { | ||
| if (n++ === limit) break; |
There was a problem hiding this comment.
🔵 minor — New shared helper leftUtf8Prefix has no unit test of its own in common-utils
leftUtf8Prefix is exported for any caller but is only tested indirectly through the app and CLI row-WHERE hash snapshots. Add direct tests in common-utils __tests__ for: limit larger than the string, exact limit, surrogate pairs (e.g. '😀'.repeat(3) with limit 2 gives 2 emoji, not 1), and limit 0.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
I will add these tests if deemed necessary, but I feel this PR is already touching more than initially planned, all to satisfy the bot.
Cover the uniform null guard for a non-JSON column type alongside JSON. Co-authored-by: Cursor <cursoragent@cursor.com>
Use SHA256_TEST_CASES with it.each in app and CLI suites so ClickHouse golden hashes stay aligned and duplicated constants are removed. Co-authored-by: Cursor <cursoragent@cursor.com>
| whereKind: Sha256WhereKind, | ||
| hash: string, | ||
| ): string { | ||
| if (whereKind === 'json') { |
There was a problem hiding this comment.
🔵 minor — JSON test cases say they match ClickHouse, but they hash raw literals instead of what toString(<JSON column>) actually returns
The expected hashes come from SHA256('<literal>'), so the tests only show that crypto-js and ClickHouse hash the same bytes the same way. The real risk is a serialization mismatch. toString() on a JSON column emits compact JSON. Per the comment at packages/app/src/components/DBRowTable.tsx:1848, it also escapes / as \/. So {"key": "value"} (with a space) and the 'actual log line' (with an unescaped github.com/...) would not match a stored row. Fix: build the input the way DBRowTable does (JSON.stringify(obj).replace(/\//g, '\\/')), and take the expected hash from lower(hex(SHA256(toString(Body)))) on a row inserted into a JSON column. Otherwise, drop the 'matches ClickHouse' claim and the clickHouse field.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
There was a problem hiding this comment.
I'm pretty sure the tests are now more robust than they were before. This minor finding is fixable, but seems like it should go into another PR.
Summary
This patch is to resolve Issue #3390 - when running HyperDX against ClickHouse in FIPS mode the MD5 function isn't available, so viewing some logs fails, because MD5 is not FIPS-compliant.
All uses of MD5 were replaced with equivalent uses of SHA256. This includes in the tests and in comments.
This patch was generated using Cursor, running Composer 2.5 Fast. All relevant tests still pass.
Screenshots or video
NA - no UI changes.
How to reproduce
Starting point:
On
main:On this branch:
References