-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix LocalizableString to work with internal ResourceType #111130
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
Conversation
|
Not sure if this should be in the common library. This opens this api up to read every private string property. When this was designed that would be a huge security issue. (Times have changed, but not sure this api should as well) |
|
@jeffhandley @eiriktsarpalis @ericstj @krwq do you know the history of the affected APIs? a concern is raised by @rhuijben in the comment #111130 (comment). |
It's not about the property to be public, it's only about the ResourceType, that might be only internal and not public. But since you need to have access to the type that is assigned to the ResourceType, I don't see that it might be a security issue. But I'm also not fully sure about this either. |
d52cf62 to
c5e7e6f
Compare
@tarekgh I just checked it and you are right, that the property needs to be |
Yes, I understand that. I was trying to figure out if checking the resource type in the code to be public was done intentionally for specific reason or it was just early check to avoid calling reflection. I don't know the history to tell. Generally, I do not see a significant issue if we allow using the internal types with the DisplayAttribute. It is kind of breaking change but not major breaking. Also, I am not seeing this is a security issue either. Users can still call reflection with the internal types to get the property value if they want. I'll not object to accepting this change if others do not have any concerns. @jeffhandley @eiriktsarpalis @ericstj @krwq @GrabYourPitchforks |
c5e7e6f to
f05b272
Compare
f05b272 to
594158b
Compare
594158b to
1437ec9
Compare
1437ec9 to
3ef97e9
Compare
Removed check for Resource Type to be public. Added test for DisplayAttribute to ensure it works with with internal Resource Type.
3ef97e9 to
8e7afff
Compare
|
@uo1 Why do you keep force-pushing the changes? Please avoid doing that so the reviewers don't have to repeat the review process. |
The pipelines keep failing with different errors that are not related to the changes in this PR. I just rebased the PR a few times to start the pipeline again, but it's still not successful. I will not rebase the PR anymore. Hopefully someone will take care if that problem. |
|
@uo1 that's not necessary to be green - look at the details of |
krwq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I agree with what we change here. My concerns are mainly with code generators:
- code with DisplayAttribute can be generated and now it will have access to internal stuff - it's much harder to reason about it if we allow this - is it always right to allow this?
- code generator or different assembly can consume this attribute and effectively access stuff which was not meant to be public if they go through data annotations APIs - IMO we should not risk exposing what was not meant to be visible
I also fully agree with #15794 (comment) - the workaround is simple enough and we're opening unknown territory here for very little benefit
jeffhandley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I introduced this type back in ~2009 as part of the WCF RIA Services product. I tried to remember why we put these "bad configuration" detections in place and here's what I recall...
For RIA Services, we were going to consume the resources and project them from an ASP.NET project into a Silverlight project where a lot of code was being generated. In the Silverlight client, we would not have private reflection available to us, and the types therefore needed to be public for the end-to-end scenario to work.
When the client code would fail because of the types not being public, it would lead to a difficult-to-diagnose crash in the Silverlight app, without any feedback to the developer. We shifted this detection into the attribute so that if the end-to-end would not work (in our app model), we would fail at a time during the developer flow that the error message would be visible in Visual Studio and the developer could be unblocked.
Since this is no longer about an environment of projecting the app from ASP.NET to Silverlight, I think it's OK to remove this detection. We cannot guarantee non-public resources will work in every app model, for for app models where it does work it's valuable to remove the block.
|
Thanks @uo1 for providing the change! |
Closes #110073
Removed check for Resource Type to be public.
Added test for DisplayAttribute to ensure it works with with internal Resource Type.