Repository navigation
fix(client): security hardening - #482
Conversation
🟡 Risk Classification: MINORApproval route: AI Review + Human Approval Classification reasons
Operational gates
Files analysed: 5 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
This comment has been minimized.
This comment has been minimized.
Security hardening of the HTTP layer, with both HTTP clients, and improved error handling.
Helpers per HTTP client in the HTTP layer, more tests, and type declarations aligned.
45382ec to
4df3d97
Compare
🟡 Risk Classification: MINORApproval route: AI Review + Human Approval Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
HTTP layer response handling aligned across clients, with more tests.
🟡 Risk Classification: MINORApproval route: AI Review + Human Approval Classification reasons
Operational gates
Files analysed: 7 wall-e 2026.06.19-02 · policy |
🔬 Debug — why this classification?Each reason code emitted by the classifier, its source clause in the AI in SDLC Control Framework, and what it means.
Kinds:
See issue #3 for the proposal to formalise this map as Appendix A of the standards doc. wall-e 2026.06.19-02 · debug |
|



Summary
Security hardening of the HTTP layer, with both HTTP clients. Improved error handling: the errors of the HTTP layer are SDK error types.
Changes
src/services/http.js: security hardening; every request uses the SDK's own policy with both HTTP clients; errors thrown as SDK error types; connection errors keep the client's error ascause.src/services/errors.js:determineErrorreturns an SDK error unchanged; doc added.src/api/reports/reports.js: the report file download uses the SDK's own policy; doc types corrected.types/dist/api/reports/reports.d.ts:getReportFilereturnsPromise<Buffer>, as documented.types/dist/services/errors.d.ts:causedeclared onApiError.test/http/responsePolicy.js(new),test/errors/determineError-unit.js(new): tests for both HTTP clients against local HTTP servers, and for the error mapping.Design notes:
getReportFile, as the existingcsvandformDataflags; it cannot be set from theCheckoutoptions. It follows a single response, to an https location, or to a plain-http one only when both the API base and the location are on a loopback host, so local tests can use plain HTTP servers; any other response of that request is an error. Of the request headers, onlyUser-AgentandAcceptare sent to that location: an allowlist, applied with axios to the request headers and again to the application's default headers merged into them; the application's axiosparamsdefault is not added to that location.transportdefault. A custom adapter function or interceptor, and a replaced globalfetch, are application code and are used as configured.access_tokenandtoken_type(RFC 6749, section 5.1); otherwise the request that needed it gives anAuthenticationErrorwith the status only and is not sent. The check is made where the token is used, soaccess.requeststill returns the parsed token response as before; a 2xx body the client cannot parse, or that axios refuses under the application's parsing defaults, is anAuthenticationErrorwith the status only.determineErrorreturns SDK errors unchanged, so the error type thrown by the HTTP layer reaches the caller; the status mapping is not duplicated.causeholds the client's error name, message and code only.API Reference
None.
Breaking changes
Type declarations:
getReportFilereturnsPromise<Buffer>instead ofPromise<Object>(the value it already returned), andApiErrordeclares an optionalcause. Both are source-compatible.Behaviour changes, released as a minor version:
ApiErrorwhen there is no specific one). The report file download keeps working, with the SDK's own policy. It cannot be kept compatible: handling these responses in the SDK is the security hardening itself. Migration: where such a response was expected, checkhttp_codeof the error, orbody.statusof anAuthenticationError.access_tokenandtoken_type, gives anAuthenticationErrorwithbody.statusand is not sent. Before, it was sent with an unusable authorization. Needed so no request is sent with an unusable authorization and no error repeats the token response. Migration: checkbody.statusof theAuthenticationError.access.requestgives anAuthenticationErrorwithbody.statusfor a 2xx body that is not JSON, instead of a parse error; with axios, a 2xx body that axios refuses under the application's parsing defaults gives the same error instead of anApiErrorwith the body. Any body the client parses is returned as before. Needed so the error is an SDK error that does not repeat the token response.transportdefault. It cannot be kept compatible: the policy above holds only with the built-in transport.User-AgentandAcceptrequest headers to the file location; other configured headers are sent to the API only. Needed so the file location receives no header meant for the API.createAccessToken, an internal function not exported from the package entry point, throws SDK error types instead of plain objects orError. Needed so the errors of the HTTP layer are SDK errors.TypeErrornow return the SDK error of their status. Kept as an SDK error type because the errors of the HTTP layer must be SDK errors.causeproperty; their type,http_codeand body are unchanged, except that the body no longer repeats input the HTTP client rejects. Needed so no error repeats that input.determineError, called directly with an SDK error, returns it unchanged instead of a newApiError. Needed so the error types above reach the caller.Tests
Existing tests pass
Serialization tests cover every new or changed property (no request or response type changed)
README updated if documented usage changed (documented usage unchanged)
test/http/responsePolicy.js(new): every request method (GET, POST, PUT, PATCH, DELETE) with both HTTP clients against local HTTP servers: the requests each server receives, the error type and body, the report file download and the headers its file request sends, token responses that cannot be used (both clients,access.requestincluded), the application's axios defaults (transport, strict JSON parsing andparamsincluded), error statuses, connection errors and the input the HTTP clients reject.test/errors/determineError-unit.js(new): SDK errors unchanged and the status mapping as before.The policy and error tests fail on the default branch; the tests of behaviour already in place pass on both.
Related
None.