diff options
Diffstat (limited to 'src/mscorlib/src/System/Security/Util/StringExpressionSet.cs')
-rw-r--r-- | src/mscorlib/src/System/Security/Util/StringExpressionSet.cs | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs b/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs index 19937f5ae6..8a12235106 100644 --- a/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs +++ b/src/mscorlib/src/System/Security/Util/StringExpressionSet.cs @@ -12,6 +12,7 @@ namespace System.Security.Util { using System.Globalization; using System.Runtime.Versioning; using System.IO; + using System.Diagnostics; using System.Diagnostics.Contracts; [Serializable] @@ -26,12 +27,9 @@ namespace System.Security.Util { // 2. Ensuring that the partial trust code has permission to see full path data // 3. Not using this set for paths (eg EnvironmentStringExpressionSet) // - [SecurityCritical] protected ArrayList m_list; protected bool m_ignoreCase; - [SecurityCritical] protected String m_expressions; - [SecurityCritical] protected String[] m_expressionsArray; protected bool m_throwOnRelative; @@ -61,7 +59,6 @@ namespace System.Security.Util { { } - [System.Security.SecuritySafeCritical] // auto-generated public StringExpressionSet( bool ignoreCase, String str, bool throwOnRelative ) { m_list = null; @@ -78,7 +75,6 @@ namespace System.Security.Util { return new StringExpressionSet(); } - [SecuritySafeCritical] public virtual StringExpressionSet Copy() { // SafeCritical: just copying this value around, not leaking it @@ -118,11 +114,10 @@ namespace System.Security.Util { return StaticProcessSingleString(str); } - [System.Security.SecurityCritical] // auto-generated public void AddExpressions( String str ) { if (str == null) - throw new ArgumentNullException( "str" ); + throw new ArgumentNullException( nameof(str) ); Contract.EndContractBlock(); if (str.Length == 0) return; @@ -165,7 +160,7 @@ namespace System.Security.Util { { if (m_throwOnRelative) { - if (Path.IsRelative(temp)) + if (PathInternal.IsPartiallyQualified(temp)) { throw new ArgumentException( Environment.GetResourceString( "Argument_AbsolutePathRequired" ) ); } @@ -181,16 +176,14 @@ namespace System.Security.Util { Reduce(); } - [System.Security.SecurityCritical] // auto-generated public void AddExpressions( String[] str, bool checkForDuplicates, bool needFullPath ) { AddExpressions(CreateListFromExpressions(str, needFullPath), checkForDuplicates); } - [System.Security.SecurityCritical] // auto-generated public void AddExpressions( ArrayList exprArrayList, bool checkForDuplicates) { - Contract.Assert( m_throwOnRelative, "This should only be called when throw on relative is set" ); + Debug.Assert( m_throwOnRelative, "This should only be called when throw on relative is set" ); m_expressionsArray = null; m_expressions = null; @@ -205,19 +198,18 @@ namespace System.Security.Util { } - [System.Security.SecurityCritical] // auto-generated internal static ArrayList CreateListFromExpressions(String[] str, bool needFullPath) { if (str == null) { - throw new ArgumentNullException( "str" ); + throw new ArgumentNullException( nameof(str) ); } Contract.EndContractBlock(); ArrayList retArrayList = new ArrayList(); for (int index = 0; index < str.Length; ++index) { if (str[index] == null) - throw new ArgumentNullException( "str" ); + throw new ArgumentNullException( nameof(str) ); // Replace alternate directory separators String oneString = StaticProcessWholeString( str[index] ); @@ -249,7 +241,6 @@ namespace System.Security.Util { return retArrayList; } - [System.Security.SecurityCritical] // auto-generated protected void CheckList() { if (m_list == null && m_expressions != null) @@ -303,7 +294,6 @@ namespace System.Security.Util { } - [System.Security.SecurityCritical] // auto-generated protected void CreateList() { String[] expressionsArray = Split( m_expressions ); @@ -325,7 +315,7 @@ namespace System.Security.Util { { if (m_throwOnRelative) { - if (Path.IsRelative(temp)) + if (PathInternal.IsPartiallyQualified(temp)) { throw new ArgumentException( Environment.GetResourceString( "Argument_AbsolutePathRequired" ) ); } @@ -339,7 +329,6 @@ namespace System.Security.Util { } } - [SecuritySafeCritical] public bool IsEmpty() { // SafeCritical: we're just showing that the expressions are empty, the sensitive portion is their @@ -354,7 +343,6 @@ namespace System.Security.Util { } } - [System.Security.SecurityCritical] // auto-generated public bool IsSubsetOf( StringExpressionSet ses ) { if (this.IsEmpty()) @@ -376,7 +364,6 @@ namespace System.Security.Util { return true; } - [System.Security.SecurityCritical] // auto-generated public bool IsSubsetOfPathDiscovery( StringExpressionSet ses ) { if (this.IsEmpty()) @@ -399,7 +386,6 @@ namespace System.Security.Util { } - [System.Security.SecurityCritical] // auto-generated public StringExpressionSet Union( StringExpressionSet ses ) { // If either set is empty, the union represents a copy of the other. @@ -434,7 +420,6 @@ namespace System.Security.Util { } - [System.Security.SecurityCritical] // auto-generated public StringExpressionSet Intersect( StringExpressionSet ses ) { // If either set is empty, the intersection is empty @@ -477,7 +462,6 @@ namespace System.Security.Util { return intersectSet; } - [SecuritySafeCritical] protected void GenerateString() { // SafeCritical - moves critical data around, but doesn't expose it out @@ -522,7 +506,6 @@ namespace System.Security.Util { // expressions contain paths that were canonicalized and expanded from the input that would cause // information disclosure, so we instead only expose this out to trusted code that can ensure they // either don't leak the information or required full path information. - [SecurityCritical] public string UnsafeToString() { CheckList(); @@ -534,7 +517,6 @@ namespace System.Security.Util { return m_expressions; } - [SecurityCritical] public String[] UnsafeToStringArray() { if (m_expressionsArray == null && m_list != null) @@ -550,7 +532,6 @@ namespace System.Security.Util { // protected static helper functions //------------------------------- - [SecurityCritical] private bool StringSubsetStringExpression( String left, StringExpressionSet right, bool ignoreCase ) { for (int index = 0; index < right.m_list.Count; ++index) @@ -563,7 +544,6 @@ namespace System.Security.Util { return false; } - [SecurityCritical] private static bool StringSubsetStringExpressionPathDiscovery( String left, StringExpressionSet right, bool ignoreCase ) { for (int index = 0; index < right.m_list.Count; ++index) @@ -661,7 +641,6 @@ namespace System.Security.Util { // protected helper functions //------------------------------- - [SecuritySafeCritical] protected void AddSingleExpressionNoDuplicates( String expression ) { // SafeCritical: We're not exposing out the string sets, just allowing modification of them @@ -691,7 +670,6 @@ namespace System.Security.Util { this.m_list.Add( expression ); } - [System.Security.SecurityCritical] // auto-generated protected void Reduce() { CheckList(); @@ -726,23 +704,20 @@ namespace System.Security.Util { } } - [System.Security.SecurityCritical] // auto-generated [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] [SuppressUnmanagedCodeSecurity] internal static extern void GetLongPathName( String path, StringHandleOnStack retLongPath ); - [System.Security.SecurityCritical] // auto-generated internal static String CanonicalizePath( String path ) { return CanonicalizePath( path, true ); } - [System.Security.SecurityCritical] // auto-generated internal static string CanonicalizePath(string path, bool needFullPath) { if (needFullPath) { - string newPath = Path.GetFullPathInternal(path); + string newPath = Path.GetFullPath(path); if (path.EndsWith(m_directorySeparator + ".", StringComparison.Ordinal)) { if (newPath.EndsWith(m_directorySeparator)) |