Repository navigation
Security: stop the Connections widget printing the address it failed to reach - #18
Merged
Merged
Conversation
…to reach Three catch blocks wrote a caught error's message into a per-service error field. That field travels in a 200 response, where the api-error sanitiser never runs, so a failed fetch drew "connect ECONNREFUSED 172.17.0.2:8181" on the dashboard. The widget's own sentences go through ctx.fail now, which marks them as vouched, and the catches choose between that message and a phrase read from the error code. Nothing else changes: one dead service still leaves the others rendering, and the tile reads better for it. connections no longer needs its exemption from the plain-Error guard.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
out.error = e.code || e.message,out.error = e.messageando.error = e.message || String(e)inui/widgets/connections/data.jswith a localerrorText(e): the widget's own sentence when it wrote one, otherwise a phrase chosen from the error code (connection refused, host not found, timed out, connection lost, certificate rejected, unreachable). A caught message is never used.throw new Error(...)sentences toctx.fail(...)with a kind, which is what marks a message as vouched and lets the catch tell it apart from one Node threw.vpnViewandmapViewtakectxinstead of(config, fetchJSON).SsrfBlockedErrorkeeps its own message: it is a sentence this repo wrote, and the reason is the point of it.connectionsexemption from the plain-Errorguard added in Fix: report Books, Now Playing and Backup failures in the widget's own words #10, so that rule now covers every widget.e.message,e.stackorString(e)into a result's error field.Why it mattered: an error field inside a successful result is a legitimate pattern here, and one dead service should not fail the whole widget. But a 200 body never passes through
api-error.js, which exists precisely because an arbitrary error message names a host, a path or an upstream body. So the sanitisation the failure path gets was absent on this one.Testing
All green, coverage floor held. Added 1 guard test and updated
connections-url.test.js, whose fakectxnow providesfailandKINDlike the real one. Mutation-checked twice: restoringout.error = e.messageand reverting onectx.failto a plain throw each fail.Checklist