Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sanitize utils and sanitize all response code and messages #358

Merged
merged 12 commits into from
Mar 15, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Mar 15, 2023

Following up #357, this PR fixes all setters of statusCode and statusMessage with two new sanetizeStatusCode and sanetizeStatusMessage utils

@pi0 pi0 requested a review from danielroe March 15, 2023 17:32
src/error.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Mar 15, 2023

Codecov Report

Merging #358 (a2676d0) into main (2594e54) will decrease coverage by 0.04%.
The diff coverage is 70.58%.

❗ Current head a2676d0 differs from pull request most recent head 9c60b9e. Consider uploading reports for the commit 9c60b9e to get more accurate results

@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   74.60%   74.57%   -0.04%     
==========================================
  Files          25       26       +1     
  Lines        2359     2407      +48     
  Branches      370      380      +10     
==========================================
+ Hits         1760     1795      +35     
- Misses        599      612      +13     
Impacted Files Coverage Δ
src/event/event.ts 44.18% <16.66%> (-1.60%) ⬇️
src/error.ts 75.60% <61.90%> (-0.23%) ⬇️
src/utils/sanitize.ts 73.91% <73.91%> (ø)
src/utils/response.ts 62.38% <90.90%> (+0.34%) ⬆️
src/utils/index.ts 100.00% <100.00%> (ø)
src/utils/proxy.ts 82.35% <100.00%> (+0.38%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

src/error.ts Outdated Show resolved Hide resolved
src/utils/sanetize.ts Outdated Show resolved Hide resolved
@pi0 pi0 requested a review from danielroe March 15, 2023 17:44
@danielroe danielroe changed the title fix: sanetize utils and sanetize all response code and messages fix: sanitize utils and sanitize all response code and messages Mar 15, 2023
src/error.ts Outdated Show resolved Hide resolved
Co-authored-by: Daniel Roe <daniel@roe.dev>
src/error.ts Outdated Show resolved Hide resolved
pi0 and others added 3 commits March 15, 2023 23:14
Co-authored-by: Daniel Roe <daniel@roe.dev>
Comment on lines +101 to +108
// TODO: Always sanitize status message in the next major releases
const originalMessage = err.statusMessage;
const sanitizedMessage = sanitizeStatusMessage(err.statusMessage);
if (sanitizedMessage !== originalMessage) {
console.warn(
"[h3] Please prefer using `message` for longer error messages instead of `statusMessage`. In the future `statusMessage` will be sanitized by default."
);
}
Copy link
Member

Choose a reason for hiding this comment

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

this looks great to me 👌

@pi0 pi0 merged commit e885dc1 into main Mar 15, 2023
@pi0 pi0 deleted the feat/sanetize-utils branch March 15, 2023 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants