fix(security): Resolve SonarQube security hotspots
SonarQube Analysis / sonarqube (pull_request) Successful in 3m9s
SonarQube Analysis / sonarqube (pull_request) Successful in 3m9s
Introduce a default regex match timeout across the library to prevent potential ReDoS attacks (SonarQube rule S6444). Implement `[OnDeserialized]` methods to re-establish object invariants and validate state after deserialization, addressing SonarQube rule S5766.
This commit is contained in:
@@ -48,6 +48,18 @@ public abstract class SqlBreakdownBase : ISqlBreakdown
|
||||
/// </summary>
|
||||
public bool IsUsingFinishClause => FinishClauses.Count > 0;
|
||||
|
||||
/// <summary>
|
||||
/// Re-establishes the invariants normally guaranteed by the constructors after the object
|
||||
/// is reconstructed by deserialization. Deserialization bypasses constructors, so the
|
||||
/// collection state must be re-validated to avoid a partially-initialized object
|
||||
/// (SonarQube rule S5766).
|
||||
/// </summary>
|
||||
protected void RevalidateBreakdownState()
|
||||
{
|
||||
SetupClauses ??= new List<string>();
|
||||
FinishClauses ??= new ArrayList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the SQL breakdown as a string. Must be implemented by derived classes.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user