René's URL Explorer Experiment


Title: [Feature]: Required Access to resource's OpenAPI attributes whose validation is failing · Issue #609 · python-openapi/openapi-core · GitHub

Open Graph Title: [Feature]: Required Access to resource's OpenAPI attributes whose validation is failing · Issue #609 · python-openapi/openapi-core

X Title: [Feature]: Required Access to resource's OpenAPI attributes whose validation is failing · Issue #609 · python-openapi/openapi-core

Description: Suggested Behavior Hello, I am currently using OpenAPI-core with my Flask app and I am customizing validation error responses as per following comment. The issue I am facing is that there are some fields in request which holds sensitive ...

Open Graph Description: Suggested Behavior Hello, I am currently using OpenAPI-core with my Flask app and I am customizing validation error responses as per following comment. The issue I am facing is that there are some ...

X Description: Suggested Behavior Hello, I am currently using OpenAPI-core with my Flask app and I am customizing validation error responses as per following comment. The issue I am facing is that there are some ...

Opengraph URL: https://github.com/python-openapi/openapi-core/issues/609

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Feature]: Required Access to resource's OpenAPI attributes whose validation is failing","articleBody":"### Suggested Behavior\r\n\r\nHello, I am currently using OpenAPI-core with my Flask app and I am customizing validation error responses as per [following comment](https://github.com/python-openapi/openapi-core/issues/564#issuecomment-1527092823).\r\n\r\nThe issue I am facing is that there are some fields in request which holds sensitive information, e.g credentials, Auth-tokens.\r\nWhen the validation fails on these fields we get an error string which includes value of these sensitive fields.\r\n\r\nE.g consider following response, \r\n```\r\n{\r\n    \"errors\": [\r\n        {\r\n            \"class\": \"\u003cclass 'openapi_core.validation.schemas.exceptions.InvalidSchemaValue'\u003e\",\r\n            \"status\": 400,\r\n            \"title\": \"Value {'flag': 'MyPassword1234'} not valid for schema of type object: (\u003cValidationError: \\\"'MyPassword1234' is too short\\\"\u003e,)\"\r\n        }\r\n    ]\r\n}\r\n```\r\nAs we can see in above example, the password of user is exposed as part of response.\r\nI do want to add validation for these fields however I don't want the values of these fields to be send as a response.\r\n\r\nFor that I checked whether there is a flag in OpenAPI which marks a field as sensitive and found [this issue](https://github.com/OAI/OpenAPI-Specification/issues/2190#issuecomment-609011614) which suggested using`x-pii: true` field in the yaml\r\n\r\nAlso I used `FlaskOpenAPIErrorsHandler` to fetch the error object and see if we get details of the flags which are set for the field where the validation failed.\r\n\r\nFollowing is my Flask code\r\n```python3\r\n#!/usr/bin/python3\r\n\"\"\"Test server.\"\"\"\r\n\r\nfrom flask import Flask, request, jsonify\r\nfrom openapi_core.contrib.flask.decorators import FlaskOpenAPIViewDecorator, FlaskOpenAPIErrorsHandler\r\nfrom openapi_core import Spec\r\n\r\n# Custom Error Handler block\r\nclass ErrorHandler(FlaskOpenAPIErrorsHandler):\r\n    \"\"\"\"Custom Error Handler\"\"\"\r\n    def handle(self, errors:list):\r\n        return jsonify({\r\n            \"causedBy\" : [self.handle_error(error) for error in errors]\r\n        }), self.OPENAPI_ERROR_STATUS.get(errors[0].__class__, 400)\r\n\r\n    def handle_error(self, error):\r\n        \"\"\"\r\n        Converts error object into error string message\r\n\r\n        :param error: Error object which stores exception message\r\n        :type error: Exception object\r\n        :return: Error message string corresponding to error object\r\n        :rtype: str\r\n        \"\"\"\r\n        if error.__cause__ is not None:\r\n            error = error.__cause__\r\n        # TODO: If the field in error object has x-pii: true, return a generic string which does not include it's value\r\n        if not (hasattr(error, \"value\") and hasattr(error, \"type\") and hasattr(error, \"schema_errors\")):\r\n            return str(error)\r\n        return f\"Value(s) {error.value} not valid for schema of type {error.type} errors: {', '.join([err.message for err in error.schema_errors])}\"\r\n\r\n\r\nSPEC = \"test.yaml\"\r\nobj = ErrorHandler()\r\nopenapi = FlaskOpenAPIViewDecorator.from_spec(Spec.from_file_path(SPEC), openapi_errors_handler=obj)\r\n\r\napp = Flask(__name__)\r\n\r\n@app.route(\"/test\", methods=[\"POST\"])\r\n@openapi\r\ndef read_permission():\r\n    \"\"\"Test function\"\"\"\r\n    return jsonify({\r\n                    \"flag stri_normal_json\": request.json.get(\"flag\", 1)\r\n                })\r\n\r\nif __name__ == \"__main__\":\r\n    app.run(host=\"0.0.0.0\", port=345, debug=True)\r\n```\r\n\r\nAnd following is the Yaml file\r\n\r\n```yaml\r\nopenapi: '3.0.2'\r\ninfo:\r\n  title: Test Title\r\n  version: '1.0'\r\nservers:\r\n  - url: http://localhost:345/\r\npaths:\r\n  /test:\r\n    post:\r\n      requestBody:\r\n        content:\r\n          application/json:\r\n            schema:\r\n              type: object\r\n              required:\r\n                - flag\r\n              properties:\r\n                flag:\r\n                  x-pii: true\r\n                  type: string\r\n                  pattern: \"^[\\\\w.-]*$\"\r\n                  minLength: 6\r\n                  maxLength: 20\r\n      responses:\r\n        200:\r\n          description: Sample response\r\n          content:\r\n            application/json:\r\n              schema:\r\n                type: object\r\n                properties:\r\n                  flag stri_json:\r\n                    type: string\r\n                    minLength: 6\r\n                    maxLength: 20\r\n```\r\nPlease check the TODO comment inside handle_error method.\r\n\r\nIf the validation of field `flag` fails and if we have access to attributes of `flag` yaml properties e.g below properties\r\n```\r\n                flag:\r\n                  x-pii: true\r\n                  type: string\r\n                  pattern: \"^[\\\\w.-]*$\"\r\n                  minLength: 6\r\n                  maxLength: 20\r\n```\r\n\r\nThen we would be able to have better customization and control over the response message.\r\n\r\n### Why is this needed?\r\n\r\nMany times we need to have better control over the response generated on the failure of validation.\r\nCurrent error messages generated by openapi-core exposes the field contents as part of response which makes openapi-core useless if there are sensitive fields in request body which needs to be validated.1\r\n\r\n\r\nHaving access to OpenAPI attributes of any field would be very helpful in generating custom response messages and would help us to perform validation on fields with sensitive data and also not expose the sensitive information to the response.\r\n\r\n\r\n\r\n### References\r\n\r\nhttps://github.com/OAI/OpenAPI-Specification/issues/2190\r\n\r\n### Would you like to implement a feature?\r\n\r\nYes","author":{"url":"https://github.com/rohan-97","@type":"Person","name":"rohan-97"},"datePublished":"2023-06-23T09:44:00.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/609/openapi-core/issues/609"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:21ad9f15-9354-9841-e5a8-55e876a79f72
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8360:16621D:C32CAA:112825C:6978B89B
html-safe-nonce5fba0368eb7c6f68505b8b7cdfe816e5ff0b0f406e63463041f454b15850b238
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MzYwOjE2NjIxRDpDMzJDQUE6MTEyODI1Qzo2OTc4Qjg5QiIsInZpc2l0b3JfaWQiOiIyNTYwNDgwMzk0OTE4NTQxNDY4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacb6a37db091359c49055e80a53ecb3dc4fafe6cd914d75cdb074cafe95beced3d
hovercard-subject-tagissue:1771152040
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-openapi/openapi-core/609/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c98bc9527efb41cc6536e6f840cb533d4f3bdcc2a5322a3596e3896f7c4842fe/python-openapi/openapi-core/issues/609
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c98bc9527efb41cc6536e6f840cb533d4f3bdcc2a5322a3596e3896f7c4842fe/python-openapi/openapi-core/issues/609
og:image:altSuggested Behavior Hello, I am currently using OpenAPI-core with my Flask app and I am customizing validation error responses as per following comment. The issue I am facing is that there are some ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerohan-97
hostnamegithub.com
expected-hostnamegithub.com
None2981c597c945c1d90ac6fa355ce7929b2f413dfe7872ca5c435ee53a24a1de50
turbo-cache-controlno-preview
go-importgithub.com/python-openapi/openapi-core git https://github.com/python-openapi/openapi-core.git
octolytics-dimension-user_id126442889
octolytics-dimension-user_loginpython-openapi
octolytics-dimension-repository_id104200746
octolytics-dimension-repository_nwopython-openapi/openapi-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id104200746
octolytics-dimension-repository_network_root_nwopython-openapi/openapi-core
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef8aa86d87c47054170094daaf9699b27a28a8448
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-openapi/openapi-core/issues/609#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-openapi%2Fopenapi-core%2Fissues%2F609
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-openapi%2Fopenapi-core%2Fissues%2F609
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-openapi%2Fopenapi-core
Reloadhttps://github.com/python-openapi/openapi-core/issues/609
Reloadhttps://github.com/python-openapi/openapi-core/issues/609
Reloadhttps://github.com/python-openapi/openapi-core/issues/609
python-openapi https://github.com/python-openapi
openapi-corehttps://github.com/python-openapi/openapi-core
Please reload this pagehttps://github.com/python-openapi/openapi-core/issues/609
Notifications https://github.com/login?return_to=%2Fpython-openapi%2Fopenapi-core
Fork 136 https://github.com/login?return_to=%2Fpython-openapi%2Fopenapi-core
Star 356 https://github.com/login?return_to=%2Fpython-openapi%2Fopenapi-core
Code https://github.com/python-openapi/openapi-core
Issues 74 https://github.com/python-openapi/openapi-core/issues
Pull requests 14 https://github.com/python-openapi/openapi-core/pulls
Discussions https://github.com/python-openapi/openapi-core/discussions
Actions https://github.com/python-openapi/openapi-core/actions
Projects 0 https://github.com/python-openapi/openapi-core/projects
Security 0 https://github.com/python-openapi/openapi-core/security
Insights https://github.com/python-openapi/openapi-core/pulse
Code https://github.com/python-openapi/openapi-core
Issues https://github.com/python-openapi/openapi-core/issues
Pull requests https://github.com/python-openapi/openapi-core/pulls
Discussions https://github.com/python-openapi/openapi-core/discussions
Actions https://github.com/python-openapi/openapi-core/actions
Projects https://github.com/python-openapi/openapi-core/projects
Security https://github.com/python-openapi/openapi-core/security
Insights https://github.com/python-openapi/openapi-core/pulse
New issuehttps://github.com/login?return_to=https://github.com/python-openapi/openapi-core/issues/609
New issuehttps://github.com/login?return_to=https://github.com/python-openapi/openapi-core/issues/609
[Feature]: Required Access to resource's OpenAPI attributes whose validation is failinghttps://github.com/python-openapi/openapi-core/issues/609#top
kind/enhancementhttps://github.com/python-openapi/openapi-core/issues?q=state%3Aopen%20label%3A%22kind%2Fenhancement%22
https://github.com/rohan-97
https://github.com/rohan-97
rohan-97https://github.com/rohan-97
on Jun 23, 2023https://github.com/python-openapi/openapi-core/issues/609#issue-1771152040
following commenthttps://github.com/python-openapi/openapi-core/issues/564#issuecomment-1527092823
this issuehttps://github.com/OAI/OpenAPI-Specification/issues/2190#issuecomment-609011614
OAI/OpenAPI-Specification#2190https://github.com/OAI/OpenAPI-Specification/issues/2190
kind/enhancementhttps://github.com/python-openapi/openapi-core/issues?q=state%3Aopen%20label%3A%22kind%2Fenhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.