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

Remove System.Security.Permissions from S.C.CM. #80347

Closed
wants to merge 4 commits into from

Conversation

AraHaan
Copy link
Member

@AraHaan AraHaan commented Jan 8, 2023

This removes System.Security.Permissions from S.C.CM for non-.NET Framework targets. For .NET Framework targets nothing changes. This is because CAS is only implemented in .NET Framework and as such should only be used in .NET Framework to remove the chance that in .NET Core/5+ and .NET Standard that System.Drawing.Common is loaded outside of a windows environment which since .NET 6 is made to throw PNSE everywhere which is not desired for people using cross platform dependencies that just so happens to depend on S.C.CM.

Contributes to #64592

Note: I consider changes in the internal namespace to be an implementation detail and any possibly breaking change being an acceptable change as it is marked internal in the name meaning that users outside of this repository should not be using it and if they are the namespace should imply that it can have breaking changes at any time. With that excluded in my mind from public ABI, I have determined this change (part of #64592) is trivial. For S.DS the change to remove S.S.P is non-trivial as it breaks public ABI and so needs to go through api-review (and approval) for that breaking change to land in .NET 8.

After that, I do not see much of any codebases in dotnet/runtime using S.S.P anymore (outside of the .NET Framework targets for them).

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Jan 8, 2023
@ghost
Copy link

ghost commented Jan 8, 2023

Tagging subscribers to this area: @dotnet/area-system-configuration
See info in area-owners.md if you want to be subscribed.

Issue Details

This removes System.Security.Permissions from S.C.CM for non-.NET Framework targets. For .NET Framework targets nothing changes. This is because CAS is only implemented in .NET Framework and as such should only be used in .NET Framework to remove the chance that in .NET Core/5+ and .NET Standard that System.Drawing.Common is loaded outside of a windows environment which since .NET 6 is made to throw PNSE everywhere which is not desired for people using cross platform dependencies that just so happens to depend on S.C.CM.

Contributes to #64592

Note: I consider changes in the internal namespace to be an implementation detail and any possibly breaking change being an acceptable change as it is marked internal in the name meaning that users outside of this repository should not be using it and if they are the namespace should imply that it can have breaking changes at any time. With that excluded in my mind from public ABI, I have determined this change (part of #64592) is trivial. For S.DS the change to remove S.S.P is non-trivial as it breaks public ABI and so needs to go through api-review (and approval) for that breaking change to land in .NET 8.

After that, I do not see much of any codebases in dotnet/runtime using S.S.P anymore (outside of the .NET Framework targets for them).

Author: AraHaan
Assignees: -
Labels:

area-System.Configuration, new-api-needs-documentation, community-contribution

Milestone: -

This removes System.Security.Permissions from S.C.CM for non-.NET Framework targets. For .NET Framework targets nothing changes. This is because CAS is only implemented in .NET Framework and as such should only be used in .NET Framework to remove the chance that in .NET Core/5+ and .NET Standard that System.Drawing.Common is loaded outside of a windows environment which since .NET 6 is made to throw PNSE everywhere which is not desired for people using cross platform dependencies that just so happens to depend on S.C.CM.

Fixes dotnet#64592
@AraHaan AraHaan force-pushed the remove-s.s.p-from-s.c.cm branch from 68d3758 to 2c58013 Compare January 8, 2023 18:18
@AraHaan AraHaan force-pushed the remove-s.s.p-from-s.c.cm branch from f440613 to 8b304b9 Compare January 9, 2023 00:34
@AraHaan
Copy link
Member Author

AraHaan commented Jan 10, 2023

The suppressions I added seems to not be working for some reason.

@steveharter steveharter added the breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. label Jan 11, 2023
@ghost ghost added the needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet label Jan 11, 2023
@ghost
Copy link

ghost commented Jan 11, 2023

Added needs-breaking-change-doc-created label because this PR has the breaking-change label.

When you commit this breaking change:

  1. Create and link to this PR and the issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.
  2. Ask a committer to mail the .NET Breaking Change Notification DL.

Tagging @dotnet/compat for awareness of the breaking change.

@danmoseley
Copy link
Member

@ericstj do you expect we'll be able to take a change of this sort? I have some interest in the issue (but not pushing on it)

Comment on lines -1386 to -1388
#pragma warning disable SYSLIB0003
public virtual void GetRestrictedPermissions(System.Configuration.Internal.IInternalConfigRecord configRecord, out System.Security.PermissionSet permissionSet, out bool isHostReady) { throw null; }
#pragma warning restore SYSLIB0003
Copy link
Member

Choose a reason for hiding this comment

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

This removes the API from both .NETCoreApp assemblies and the netstandard2.0 assembly. Is the .NETStandard change intentional?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we were exploring the intentional breaking change here. It was discussed as an option here: #64592 (comment)

@ericstj ericstj requested a review from steveharter February 7, 2023 18:51
@@ -231,12 +231,12 @@ public virtual void RefreshConfigPaths()

public virtual IDisposable Impersonate() => new DummyDisposable();

#pragma warning disable SYSLIB0003 // Obsolete: CAS
#if NETFRAMEWORK // Obsolete: CAS (.NET Framework only)
Copy link
Member

Choose a reason for hiding this comment

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

This source file should not be included for .NETFramework at all. .NETFramework should just be type-forwards. Same goes for all the src files. Just delete the implementation. Keep the test ifdef though.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah ok

@ericstj
Copy link
Member

ericstj commented Feb 8, 2023

@ericstj do you expect we'll be able to take a change of this sort? I have some interest in the issue (but not pushing on it)

I think we might, but it depends on usage. We don't typically remove API like this, since it's a binary breaking change, but this might be a case where the benefit is worth the risk (assuming we've measured the risk appropriately).

Usually when we break things, we like to have a mitigation to fix someone who's broken and cannot recompile - I don't see how we can have that here so that's a higher risk. That said, we feel it may still be acceptable since the code that's being removed is very unlikely to be called since it hasn't done anything for years, using it would have already hit an obsolete warning, it's in an Internal namespace, and the architecture of DelegatingConfigHost was specifically designed to avoid folks having to refer to interface members they didn't need to change:

// A public implementation of IInternalConfigHost that simply
// delegates all members of the IInternalConfigHost interface to
// another instance of a host. All interface members are marked virtual
// so that a derived class can override just the ones needed to
// implement that specific host, while all others are delegated to
// another implementation such as InternalConfigHost.
//
// The advantages of this arrangement are:
// * The IInternalConfigHost interface can be extended without
// requiring other hosts to be updated.
// * This class that we are making public has no implementation
// of its own that can be exploited. All the hosts with meaningful
// implementation can remain internal.
// * It allows straightforward chaining of host functionality,
// see UpdateConfigHost as an example.

All these qualifications make me feel like you won't find a ton of precedent here, @danmoseley, so if that's what you're interested in I don't expect we'll establish it.

In any case I think we should make this change early and document it as breaking. We can give folks a chance to give us feedback.

I'm supportive of this being polished and documented and going out in an early preview to .NET 8.0, assuming we have agreement from @dotnet/area-system-configuration.

@danmoseley
Copy link
Member

All these qualifications make me feel like you won't find a ton of precedent here, @danmoseley, so if that's what you're interested in I don't expect we'll establish it.

I don't have an opinion on breakingness/precedent, just that it's come up a internally as being an impediment to picking up MSRC's as you know.

@steveharter
Copy link
Member

@AraHaan closing this PR since replaced by #82259.

Thanks for your contribution here. It forced a deeper dive into this problem where we found that the S.S.P assembly does not actually reference S.C.CM since the PermissionSet class is in corelib, not S.C.CM (at least for non-netstandard) and allows the new PR to address the issue in a less-breaking way.

@steveharter steveharter closed this Mar 1, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Configuration breaking-change Issue or PR that represents a breaking API or functional change over a prerelease. community-contribution Indicates that the PR has been added by a community member needs-breaking-change-doc-created Breaking changes need an issue opened with https://github.com/dotnet/docs/issues/new?template=dotnet new-api-needs-documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants