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(Http): Only allow valid HTTP status code values via template #49882

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

provokateurin
Copy link
Member

Summary

To prevent anyone from using invalid HTTP status codes.
Ideally it would be possible to re-use the S and so on template parameters when extending the parent templates, but psalm doesn't seem to support that.

Checklist

@provokateurin provokateurin added this to the Nextcloud 31 milestone Dec 16, 2024
@provokateurin provokateurin changed the title fix(settings): Fix log file download return type fix(Http): Only allow valid HTTP status code values via template Dec 16, 2024
@provokateurin provokateurin force-pushed the fix/http/template-valid-status-codes branch from b7691e8 to 98b1635 Compare December 16, 2024 15:53
Comment on lines +47 to +50
"type": "string",
"enum": [
"attachment; filename=\"nextcloud.log\""
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should that be part of API definition 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I ignored it before, but with these changes psalm is very unhappy somehow.
IMO the proper fix would be to ignore this header completely in openapi-extractor.

Copy link
Member

Choose a reason for hiding this comment

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

Not sure, would at least be good for devices to know if a file name is given, etc?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, although on the other hand I don't know how much sense it makes to specify the value that will be returned. Just saying that a string is returned should be good enough, the clients need to parse that anyway.

@@ -7,16 +7,18 @@
*/
namespace OCP\AppFramework\Http;

use OCP\AppFramework\Http;
Copy link
Member

Choose a reason for hiding this comment

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

didnt this explode on some version of PHP because you can not import a class with the same name as a namespace?

Copy link
Member Author

Choose a reason for hiding this comment

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

I never heard of that problem before and CI is green, so I don't think it's a problem here?

@provokateurin provokateurin force-pushed the fix/http/template-valid-status-codes branch from 98b1635 to 7db694f Compare January 7, 2025 14:45
@provokateurin
Copy link
Member Author

/backport to stable30

@provokateurin
Copy link
Member Author

/backport to stable29

@provokateurin
Copy link
Member Author

/backport to stable28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants