Skip to content

security(appraisal-api): require JSON content type on appraisal requests - #580

Open
umpireboulianne-design wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
umpireboulianne-design:fix/issue-537
Open

umpireboulianne-design wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
umpireboulianne-design:fix/issue-537

Conversation

@umpireboulianne-design

Copy link
Copy Markdown

Summary

  • Add isJsonContentType(), checkAppraisalContentType(), and APPRAISAL_UNSUPPORTED_MEDIA_TYPE in services/appraisal-api/src/body-limit.ts and enforce Content-Type: application/json (accepting optional UTF-8 charset parameters such as application/json; charset=utf-8 case-insensitively) on POST /appraise in services/appraisal-api/src/server.ts.
  • Return a stable 415 Unsupported Media Type JSON response ({ "error": "unsupported_media_type", "expected": "application/json" }) before reading the body or issuing a 402 quote when Content-Type is missing or non-JSON.
  • Add unit and HTTP server tests in services/appraisal-api/src/body-limit.test.ts and update services/appraisal-api/README.md.

Supply-chain review

  • No package scripts or dependencies changed. If changed, explain why below.
  • No .vscode/, workflow, or other editor/config file changes. If changed, list them below.
  • No lockfile changes. If changed, explain the update below.
  • No binary or font asset changes. If changed, list and justify them below.
  • I confirm no automatic task (such as preinstall/postinstall) was added.
  • I confirm no hidden executable payload (encoded blob, obfuscated command, or unexpected binary) was added.
  • Any changed executable or binary was reviewed by a maintainer.

Testing

  • node --import tsx/esm --test services/appraisal-api/src/body-limit.test.ts services/appraisal-api/src/appraisal.test.ts services/appraisal-api/src/appraisal-fixtures.test.ts services/appraisal-api/src/config.test.ts

Closes #537
Fixes #537

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.

security(high/easy): require JSON content type on appraisal requests

1 participant