Skip to content

Commit

Permalink
Only use fxcop in netfw
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Caruso committed Jul 22, 2024
1 parent 49a3a95 commit 271e55e
Show file tree
Hide file tree
Showing 55 changed files with 98 additions and 181 deletions.
7 changes: 7 additions & 0 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="$(MicrosoftSourceLinkGitHubVersion)" PrivateAssets="All"/>
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ internal JsonClaimSet CreateClaimSet(ReadOnlySpan<char> strSpan, int startIndex,
/// <returns>Encoded token string without signature or authentication tag.</returns>
public override string ToString()
{
return EncodedToken.Substring(0, EncodedToken.LastIndexOf("."));
return EncodedToken.Substring(0, EncodedToken.LastIndexOf('.'));
}

/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public partial class JsonWebTokenHandler : TokenHandler
/// <summary>
/// Default value for the flag that determines whether or not the InboundClaimTypeMap is used.
/// </summary>
public static bool DefaultMapInboundClaims = false;
public static bool DefaultMapInboundClaims;

/// <summary>
/// Gets the Base64Url encoded string representation of the following JWT header:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ internal static string SafeLogJwtToken(object obj)
if (!(obj is string token))
return obj.GetType().ToString();

int lastDot = token.LastIndexOf(".");
int lastDot = token.LastIndexOf('.');

// no dots, not a JWT, we do not know how to sanitize so we return UnrecognizedEncodedToken
if (lastDot == -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Tokens\Microsoft.IdentityModel.Tokens.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ private IdentityModelEventSource()
/// <summary>
/// Flag which indicates whether or not PII is shown in logs. False by default.
/// </summary>
public static bool ShowPII { get; set; } = false;
public static bool ShowPII { get; set; }

/// <summary>
/// Flag which indicates whether or not complete <see cref="SecurityArtifact"/> is shown in logs when <see cref="ShowPII"/> is set to true. False by default.
/// </summary>
public static bool LogCompleteSecurityArtifact { get; set; } = false;
public static bool LogCompleteSecurityArtifact { get; set; }

/// <summary>
/// String that is used in place of any arguments to log messages if the 'ShowPII' flag is set to false.
Expand All @@ -53,7 +53,7 @@ private IdentityModelEventSource()
/// <summary>
/// Indicates whether or the log message header (contains library version, date/time, and PII debugging information) has been written.
/// </summary>
public static bool HeaderWritten { get; set; } = false;
public static bool HeaderWritten { get; set; }

/// <summary>
/// The log message that indicates the current library version.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.IdentityModel.Logging/LogHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class LogHelper
/// <summary>
/// Indicates whether the log message header (contains library version, date/time, and PII debugging information) has been written.
/// </summary>
private static bool _isHeaderWritten = false;
private static bool _isHeaderWritten;

/// <summary>
/// The log message that is shown when PII is off.
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.IdentityModel.Logging/LoggerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public LoggerContext(Guid activityId)
/// Gets or sets a boolean controlling if logs are written into the context.
/// Useful when debugging.
/// </summary>
public bool CaptureLogs { get; set; } = false;
public bool CaptureLogs { get; set; }

/// <summary>
/// Gets or sets a string that helps with setting breakpoints when debugging.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,11 @@
<Compile Include="..\Common\TrimmingAttributes.cs" LinkBase="Common"
Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System.Net.Http" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Abstractions\Microsoft.IdentityModel.Abstractions.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Abstractions\Microsoft.IdentityModel.Abstractions.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Protocols\Microsoft.IdentityModel.Protocols.csproj" />
<ProjectReference Include="..\System.IdentityModel.Tokens.Jwt\System.IdentityModel.Tokens.Jwt.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Microsoft.IdentityModel.JsonWebTokens\Microsoft.IdentityModel.JsonWebTokens.csproj" />
<ProjectReference Include="..\..\src\Microsoft.IdentityModel.Protocols\Microsoft.IdentityModel.Protocols.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ public class SignedHttpRequestCreationParameters
/// Gets or sets a value indicating whether the <see cref="SignedHttpRequestClaimTypes.Q"/> claim should be created and added or not.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3</remarks>
public bool CreateQ { get; set; } = false;
public bool CreateQ { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the <see cref="SignedHttpRequestClaimTypes.H"/> claim should be created and added or not.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3</remarks>
public bool CreateH { get; set; } = false;
public bool CreateH { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the <see cref="SignedHttpRequestClaimTypes.B"/> claim should be created and added or not.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3</remarks>
public bool CreateB { get; set; } = false;
public bool CreateB { get; set; }

/// <summary>
/// Default value for the <see cref="TimeAdjustment"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ internal virtual void AddQClaim(ref Utf8JsonWriter writer, SignedHttpRequestDesc
foreach (var queryParam in sanitizedQueryParams)
{
if (!firstQueryParam)
stringBuffer.Append("&");
stringBuffer.Append('&');

stringBuffer.Append(queryParam.Key).Append('=').Append(queryParam.Value);
firstQueryParam = false;
Expand Down Expand Up @@ -876,7 +876,7 @@ internal virtual void ValidateQClaim(JsonWebToken signedHttpRequest, SignedHttpR
else
{
if (!firstQueryParam)
stringBuffer.Append("&");
stringBuffer.Append('&');

stringBuffer.Append((string)queryParamName).Append('=').Append(queryParamsValue);
firstQueryParam = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class SignedHttpRequestValidationParameters
/// If you set this property to true, you must set values in <see cref="AllowedDomainsForJkuRetrieval"/>.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/rfc7800#section-3.5</remarks>
public bool AllowResolvingPopKeyFromJku { get; set; } = false;
public bool AllowResolvingPopKeyFromJku { get; set; }

/// <summary>
/// Gets or sets a list of allowed domains for 'jku' claim retrieval.
Expand Down Expand Up @@ -245,26 +245,26 @@ public TokenHandler TokenHandler
/// Gets or sets a value indicating whether the <see cref="SignedHttpRequestClaimTypes.Q"/> claim should be validated or not.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3</remarks>
public bool ValidateQ { get; set; } = false;
public bool ValidateQ { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the <see cref="SignedHttpRequestClaimTypes.H"/> claim should be validated or not.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3</remarks>
public bool ValidateH { get; set; } = false;
public bool ValidateH { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the <see cref="SignedHttpRequestClaimTypes.B"/> claim should be validated or not.
/// </summary>
/// <remarks>https://datatracker.ietf.org/doc/html/draft-ietf-oauth-signed-http-request-03#section-3</remarks>
public bool ValidateB { get; set; } = false;
public bool ValidateB { get; set; }

/// <summary>
/// Gets or sets a value indicating whether claims in <see cref="ClaimsToValidateWhenPresent"/> should be validated if present.
/// </summary>
/// <remarks>
/// Allows for validation of a claim if present, even if the validation option for the claim is set to <c>false</c>.
/// </remarks>
public bool ValidatePresentClaims { get; set; } = false;
public bool ValidatePresentClaims { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Protocols\Microsoft.IdentityModel.Protocols.csproj" />
<ProjectReference Include="..\Microsoft.IdentityModel.Tokens.Saml\Microsoft.IdentityModel.Tokens.Saml.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal class KeyValueAccumulator
{
public IDictionary<string, IList<string>> Result { get; } = new Dictionary<string, IList<string>>();

public bool HasValues { get; set; } = false;
public bool HasValues { get; set; }

public void Append(string key, string value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Tokens\Microsoft.IdentityModel.Tokens.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Security.Claims;
using System.Security.Cryptography;
using Microsoft.IdentityModel.JsonWebTokens;
Expand Down Expand Up @@ -103,9 +104,9 @@ public class TestTokenCreator
new Claim(JwtRegisteredClaimNames.GivenName, "Bob", ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Iss, _defaultTestIssuer, ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Aud, _defaultTestAudience, ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Iat, EpochTime.GetIntDate(_defaultIssuedAtNotBefore).ToString(), ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Nbf, EpochTime.GetIntDate(_defaultIssuedAtNotBefore).ToString(), ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Exp, EpochTime.GetIntDate(_defaultExpirationTime).ToString(), ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Iat, EpochTime.GetIntDate(_defaultIssuedAtNotBefore).ToString(CultureInfo.InvariantCulture), ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Nbf, EpochTime.GetIntDate(_defaultIssuedAtNotBefore).ToString(CultureInfo.InvariantCulture), ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
new Claim(JwtRegisteredClaimNames.Exp, EpochTime.GetIntDate(_defaultExpirationTime).ToString(CultureInfo.InvariantCulture), ClaimValueTypes.String, _defaultTestIssuer, _defaultTestIssuer),
};

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Microsoft.IdentityModel.Tokens\Microsoft.IdentityModel.Tokens.csproj" />
<ProjectReference Include="..\Microsoft.IdentityModel.Xml\Microsoft.IdentityModel.Xml.csproj" />
Expand Down
6 changes: 3 additions & 3 deletions src/Microsoft.IdentityModel.Tokens/AsymmetricAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ namespace Microsoft.IdentityModel.Tokens
internal class AsymmetricAdapter : IDisposable
{
#if DESKTOP
private bool _useRSAOeapPadding = false;
private bool _useRSAOeapPadding;
#endif
private bool _disposeCryptoOperators = false;
private bool _disposed = false;
private bool _disposeCryptoOperators;
private bool _disposed;
private DecryptDelegate _decryptFunction = DecryptFunctionNotFound;
private EncryptDelegate _encryptFunction = EncryptFunctionNotFound;
private SignDelegate _signFunction = SignFunctionNotFound;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class BaseConfigurationManager
private TimeSpan _refreshInterval = DefaultRefreshInterval;
private TimeSpan _lastKnownGoodLifetime = DefaultLastKnownGoodConfigurationLifetime;
private BaseConfiguration _lastKnownGoodConfiguration;
private DateTime? _lastKnownGoodConfigFirstUse = null;
private DateTime? _lastKnownGoodConfigFirstUse;

internal EventBasedLRUCache<BaseConfiguration, DateTime> _lastKnownGoodConfigurationCache;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Microsoft.IdentityModel.Tokens
public class RsaKeyWrapProvider : KeyWrapProvider
{
private Lazy<AsymmetricAdapter> _asymmetricAdapter;
private bool _disposed = false;
private bool _disposed;
private bool _willUnwrap;

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.IdentityModel.Tokens/EventBasedLRUCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ internal class EventBasedLRUCache<TKey, TValue>
private readonly bool _removeExpiredValues;
private readonly int _removeExpiredValuesIntervalInSeconds;
// for testing purpose only to verify the task count
private int _taskCount = 0;
private int _taskCount;
private DateTime _timeForNextExpiredValuesRemoval;
private DateTime _timeForNextCompaction;

Expand All @@ -77,7 +77,7 @@ internal class EventBasedLRUCache<TKey, TValue>
private int _processCompactedValuesState = ActionNotQueued;

// set to true when the AppDomain is to be unloaded or the default AppDomain process is ready to exit
private bool _shouldStopImmediately = false;
private bool _shouldStopImmediately;

internal ItemExpired OnItemExpired { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Microsoft.IdentityModel.Tokens
public class InMemoryCryptoProviderCache: CryptoProviderCache, IDisposable
{
internal CryptoProviderCacheOptions _cryptoProviderCacheOptions;
private bool _disposed = false;
private bool _disposed;
private readonly EventBasedLRUCache<string, SignatureProvider> _signingSignatureProviders;
private readonly EventBasedLRUCache<string, SignatureProvider> _verifyingSignatureProviders;

Expand Down
Loading

0 comments on commit 271e55e

Please sign in to comment.