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

Resolves #881 Invalid Cve Schemas Posts and Puts now return a 400 status code and corresponding errors #945

Merged
merged 2 commits into from
Dec 9, 2022

Conversation

jdaigneau5
Copy link
Collaborator

Closes #881

Summary

Invalid language codes in POST/PUT /api/cve/:id/cna would cause a 500 error. This was because the language code didn't validate against the Cve schema, causing an invalid schema error that threw a 500. This was changed to throw a 400 error and return corresponding schema validation errors.

Important Changes

cve.js

  • Updated validateCveRecord() to return an object with corresponding schema validation errors

cve.controller.js

  • Updated submitCna() and updateCna() to throw 400 errors instead of 500 errors when the Cve schema is invalid.

Testing

Sample JSON for testing

{"cnaContainer" : {
"descriptions" : [ { "lang" : "eng", "value" : "One more CVE Services test CVE Record post." } ],
"affected" : [ { "versions" : [ { "version" : "1.1.0", "status" : "affected" } ],
"product" : "CVE Services product number two", "vendor" : "MITRE" } ],
"references" : [ { "url" : "http://mitre.org" } ],
"providerMetadata" : { "orgId" : "466e066c-d384-4b8a-8b15-067d9c22c5af",
"shortName" : "mitre",
"dateUpdated" : "2022-04-28T21:30:13.057Z"
}
}}

… that caused validation to fail. Also returns a 400 error instead of 500
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.

Invalid language code causes Internal Server Error
2 participants