fix(serialization): Remove legacy BinaryFormatter support
SonarQube Analysis / sonarqube (pull_request) Successful in 4m42s
SonarQube Analysis / sonarqube (pull_request) Successful in 4m42s
The `[Serializable]` attribute and corresponding `[OnDeserialized]` methods have been removed from various breakdown classes. This eliminates reliance on `BinaryFormatter`, which is a deprecated and insecure serialization mechanism in modern .NET. This change also resolves SonarQube rule S5766 warnings by removing the context in which they apply, leading to cleaner and more secure code.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using Strata.SqlTools.SqlBreakdown.Classes;
|
||||
using Strata.SqlTools.SqlBreakdown.Expressions;
|
||||
@@ -14,7 +13,6 @@ namespace Strata.SqlTools.Breakdowns.SqlServer;
|
||||
/// <summary>
|
||||
/// Represents a SELECT query breakdown with all clauses (SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY).
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
#pragma warning disable S2325 // Methods and properties that don't access instance data should be static - False positive: These members access instance fields
|
||||
public class QueryBreakdown : SqlBreakdownBase, IQueryBreakdown
|
||||
{
|
||||
@@ -108,28 +106,6 @@ public class QueryBreakdown : SqlBreakdownBase, IQueryBreakdown
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Re-establishes invariants after deserialization, since deserialization bypasses the
|
||||
/// constructors that normally initialize the parameter, WITH-clause, and clause backing
|
||||
/// fields (SonarQube rule S5766).
|
||||
/// </summary>
|
||||
/// <param name="context">The streaming context for the deserialization operation.</param>
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
RevalidateBreakdownState();
|
||||
|
||||
_parameterList ??= new List<IQueryParam>();
|
||||
_withClauses ??= new List<IWithClause>();
|
||||
_selectClause ??= new SqlExpressionClause(splitOnComma: true);
|
||||
_fromClause ??= new SqlClause();
|
||||
_whereClause ??= new SqlExpressionClause(splitOnComma: false);
|
||||
_groupByClause ??= new SqlExpressionClause(splitOnComma: true);
|
||||
_havingClause ??= new SqlExpressionClause(splitOnComma: false);
|
||||
_orderByClause ??= new SqlExpressionClause(splitOnComma: true);
|
||||
_clausesCacheDirty = true;
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user