MetaAnalyzers\ReportDiagnosticAnalyzer.cs (4)
105ImmutableHashSet<INamedTypeSymbol> contextTypes = ImmutableHashSet.Create(compilationEndAnalysisContext, codeBlockAnalysisContext,
111protected abstract ReportDiagnosticCompilationAnalyzer GetAnalyzer(ImmutableHashSet<INamedTypeSymbol> contextTypes, INamedTypeSymbol diagnosticType, INamedTypeSymbol diagnosticDescriptorType, INamedTypeSymbol diagnosticAnalyzer, INamedTypeSymbol diagnosticAnalyzerAttribute);
115private readonly ImmutableHashSet<INamedTypeSymbol> _contextTypes;
121protected ReportDiagnosticCompilationAnalyzer(ImmutableHashSet<INamedTypeSymbol> contextTypes, INamedTypeSymbol diagnosticType, INamedTypeSymbol diagnosticDescriptorType, INamedTypeSymbol diagnosticAnalyzer, INamedTypeSymbol diagnosticAnalyzerAttribute)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
24internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
25ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
29private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
30private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
31private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
32private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
33private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
34private readonly ImmutableHashSet<object> _distinctReferencedConstants;
42ImmutableHashSet<OperationKind> distinctOperatorKinds,
43ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
44ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
45ImmutableHashSet<CaseKind> distinctCaseKinds,
46ImmutableHashSet<ISymbol> distinctReferencedSymbols,
47ImmutableHashSet<object> distinctReferencedConstants)
68ImmutableHashSet<OperationKind> distinctOperatorKinds,
69ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
70ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
71ImmutableHashSet<CaseKind> distinctCaseKinds,
72ImmutableHashSet<ISymbol> distinctReferencedSymbols,
73ImmutableHashSet<object> distinctReferencedConstants)
94ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
95ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
96ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
97ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
98ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
99ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
289distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
290distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
291distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
292distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
293distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
294distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
38internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
39ImmutableHashSet<INamedTypeSymbol> coupledTypes)
47internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
53internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
194ImmutableHashSet<INamedTypeSymbol>.Builder builder,
348private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
399internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
src\2e2796bccd1466f6\TaintedDataAnalysis.TaintedDataOperationVisitor.cs (10)
35private Dictionary<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)> TaintedSourcesBySink { get; }
47foreach (KeyValuePair<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)> kvp in this.TaintedSourcesBySink)
542if (!this.TaintedSourcesBySink.TryGetValue(sink, out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins) data))
586out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins) data))
645foreach ((MethodMatcher methodMatcher, ImmutableHashSet<(string source, string end)> sourceToEnds) in sanitizerInfo.SanitizingMethods)
701else if (sinkInfo.SinkMethodParameters.TryGetValue(method.MetadataName, out var sinkParameters)
src\66dd3055a1c91c38\PointsToAnalysis.PointsToDataFlowOperationVisitor.cs (17)
30private readonly PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> _escapedOperationLocationsBuilder;
31private readonly PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> _escapedReturnValueLocationsBuilder;
32private readonly PooledDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>.Builder> _escapedEntityLocationsBuilder;
44_escapedOperationLocationsBuilder = PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
45_escapedReturnValueLocationsBuilder = PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
46_escapedEntityLocationsBuilder = PooledDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
53public ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughOperationsMap()
56public ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughReturnValuesMap()
59public ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughEntitiesMap()
62private static ImmutableDictionary<T, ImmutableHashSet<AbstractLocation>> GetEscapedAbstractLocationsMapAndFreeBuilder<T>(
63PooledDictionary<T, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder)
70return ImmutableDictionary<T, ImmutableHashSet<AbstractLocation>>.Empty;
73var builder = ImmutableDictionary.CreateBuilder<T, ImmutableHashSet<AbstractLocation>>();
632private void HandleEscapingOperation(IOperation escapingOperation, IOperation escapedInstance, PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> builder)
651PooledDictionary<TKey, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder,
673PooledDictionary<TKey, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder,
703private void HandleEscapingLocations(PointsToAbstractValue pointsToValueOfEscapedInstance, ImmutableHashSet<AbstractLocation>.Builder builder)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
24internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
25ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
29private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
30private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
31private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
32private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
33private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
34private readonly ImmutableHashSet<object> _distinctReferencedConstants;
42ImmutableHashSet<OperationKind> distinctOperatorKinds,
43ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
44ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
45ImmutableHashSet<CaseKind> distinctCaseKinds,
46ImmutableHashSet<ISymbol> distinctReferencedSymbols,
47ImmutableHashSet<object> distinctReferencedConstants)
68ImmutableHashSet<OperationKind> distinctOperatorKinds,
69ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
70ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
71ImmutableHashSet<CaseKind> distinctCaseKinds,
72ImmutableHashSet<ISymbol> distinctReferencedSymbols,
73ImmutableHashSet<object> distinctReferencedConstants)
94ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
95ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
96ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
97ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
98ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
99ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
289distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
290distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
291distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
292distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
293distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
294distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
38internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
39ImmutableHashSet<INamedTypeSymbol> coupledTypes)
47internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
53internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
194ImmutableHashSet<INamedTypeSymbol>.Builder builder,
348private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
399internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\GlobalFlowStateAnalysis\GlobalFlowStateAnalysisValueSet.cs (16)
21ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Unset);
23ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Empty);
25ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Unknown);
28ImmutableHashSet<IAbstractAnalysisValue> analysisValues,
29ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents,
47ImmutableHashSet<IAbstractAnalysisValue> analysisValues,
48ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents,
56=> new(ImmutableHashSet.Create(analysisValue), ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, height: 0, GlobalFlowStateAnalysisValueSetKind.Known);
58public ImmutableHashSet<IAbstractAnalysisValue> AnalysisValues { get; }
59public ImmutableHashSet<GlobalFlowStateAnalysisValueSet> Parents { get; }
111var negatedAnalysisValues = ImmutableHashSet.Create(AnalysisValues.Single().GetNegatedValue());
140return GlobalFlowStateAnalysisValueSet.Create(ImmutableHashSet<IAbstractAnalysisValue>.Empty, parentsBuilder.ToImmutable(), height);
143static GlobalFlowStateAnalysisValueSet GetNegateValueFromParents(ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents)
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysisResult.cs (14)
14private readonly ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughOperationsMap;
15private readonly ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughReturnValuesMap;
16private readonly ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughEntitiesMap;
17private readonly ImmutableHashSet<AnalysisEntity> _trackedEntities;
18private readonly ImmutableHashSet<PointsToAbstractValue> _trackedPointsToValues;
22ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughOperationsMap,
23ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughReturnValuesMap,
24ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughEntitiesMap,
37public ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations(IOperation operation)
42public ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations(AnalysisEntity analysisEntity)
45private static ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations<TKey>(
47ImmutableDictionary<TKey, ImmutableHashSet<AbstractLocation>> map)
50if (map.TryGetValue(key, out var escapedLocations))
55return ImmutableHashSet<AbstractLocation>.Empty;
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\PooledHashSetExtensions.cs (72)
50?? ImmutableHashSet<string>.Empty,
53?.Select(o => new KeyValuePair<string, ImmutableHashSet<string>>(o.Method, o.Parameters.ToImmutableHashSet()))
55?? ImmutableDictionary<string, ImmutableHashSet<string>>.Empty);
67taintedProperties: ImmutableHashSet<string>.Empty,
68transferProperties: ImmutableHashSet<string>.Empty,
72ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
74ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
76ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
78ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
94taintedProperties: ImmutableHashSet<string>.Empty,
95transferProperties: ImmutableHashSet<string>.Empty,
99ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
101ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
103ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
105ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
123?? ImmutableHashSet<string>.Empty,
124transferProperties: ImmutableHashSet<string>.Empty,
126ImmutableHashSet<ParameterMatcher>.Empty,
129?.Select<string, (MethodMatcher, ImmutableHashSet<string>)>(o =>
132ImmutableHashSet<string>.Empty.Add(TaintedTargetValue.Return)
135?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
137ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
139ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
141ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
173?? ImmutableHashSet<string>.Empty,
175?? ImmutableHashSet<string>.Empty,
177ImmutableHashSet<ParameterMatcher>.Empty,
179ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
185?? ImmutableHashSet<(PointsToCheck, string)>.Empty
188?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
194?? ImmutableHashSet<(ValueContentCheck, string)>.Empty
197?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
205?? ImmutableHashSet<(string, string)>.Empty))
207?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
230?? ImmutableHashSet<string>.Empty,
231transferProperties: ImmutableHashSet<string>.Empty,
233ImmutableHashSet<ParameterMatcher>.Empty,
235ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
243?? ImmutableHashSet<(PointsToCheck, string)>.Empty
246?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
254?? ImmutableHashSet<(ValueContentCheck, string)>.Empty
257?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
259ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
280?.Select<string, (MethodMatcher, ImmutableHashSet<(string, string)>)>(o =>
283ImmutableHashSet<(string, string)>.Empty))
285?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
287?? ImmutableHashSet<string>.Empty);
310?? ImmutableHashSet<(string, string)>.Empty))
312?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
314?? ImmutableHashSet<string>.Empty);
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\SourceInfo.cs (22)
42ImmutableHashSet<string> taintedProperties,
43ImmutableHashSet<ParameterMatcher> taintedArguments,
44ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)> taintedMethods,
45ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)> taintedMethodsNeedsPointsToAnalysis,
46ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)> taintedMethodsNeedsValueContentAnalysis,
47ImmutableHashSet<string> transferProperties,
48ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)> transferMethods,
90public ImmutableHashSet<string> TransferProperties { get; }
95public ImmutableHashSet<string> TaintedProperties { get; }
101public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<string> TaintedTargets)> TaintedMethods { get; }
106public ImmutableHashSet<ParameterMatcher> TaintedArguments { get; }
129public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(PointsToCheck PointsToCheck, string TaintedTarget)>)> TaintedMethodsNeedsPointsToAnalysis { get; }
152public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(ValueContentCheck ValueContentCheck, string TaintedTarget)>)> TaintedMethodsNeedsValueContentAnalysis { get; }
171public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(string IfTaintedParameter, string ThenTaintedTarget)>)> TransferMethods { get; }
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataConfig.cs (28)
33private static ImmutableDictionary<SinkKind, ImmutableHashSet<SourceInfo>> s_sinkKindToSourceInfo
34= ImmutableDictionary.Create<SinkKind, ImmutableHashSet<SourceInfo>>();
39private static ImmutableDictionary<SinkKind, ImmutableHashSet<SanitizerInfo>> s_sinkKindToSanitizerInfo
40= ImmutableDictionary.Create<SinkKind, ImmutableHashSet<SanitizerInfo>>();
105PooledDictionary<ImmutableHashSet<SourceInfo>, Lazy<TaintedDataSymbolMap<SourceInfo>>>.GetInstance(out var sourcesToSymbolMap);
107PooledDictionary<ImmutableHashSet<SanitizerInfo>, Lazy<TaintedDataSymbolMap<SanitizerInfo>>>.GetInstance(out var sanitizersToSymbolMap);
111PooledDictionary<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)>.GetInstance(out var sourceSanitizersToSinks);
116ImmutableHashSet<SourceInfo> sources = GetSourceInfos(sinkKind);
127ImmutableHashSet<SanitizerInfo> sanitizers = GetSanitizerInfos(sinkKind);
138ImmutableHashSet<SinkInfo> sinks = GetSinkInfos(sinkKind);
139if (!sourceSanitizersToSinks.TryGetValue((sources, sanitizers), out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos) sinksPair))
149foreach (KeyValuePair<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)> kvp in sourceSanitizersToSinks)
151ImmutableHashSet<SinkInfo> sinks = kvp.Value.SinkInfos.ToImmutable();
205private static ImmutableHashSet<SourceInfo> GetSourceInfos(SinkKind sinkKind)
207if (s_sinkKindToSourceInfo.TryGetValue(sinkKind, out var sourceInfo))
252return ImmutableHashSet<SourceInfo>.Empty;
258private static ImmutableHashSet<SanitizerInfo> GetSanitizerInfos(SinkKind sinkKind)
260if (s_sinkKindToSanitizerInfo.TryGetValue(sinkKind, out var sanitizerInfo))
308return ImmutableHashSet<SanitizerInfo>.Empty;
314private static ImmutableHashSet<SinkInfo> GetSinkInfos(SinkKind sinkKind)
363return ImmutableHashSet<SinkInfo>.Empty;
src\roslyn\src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\SetAbstractDomain.cs (14)
11public class SetAbstractDomain<T> : AbstractDomain<ImmutableHashSet<T>>
17public override ImmutableHashSet<T> Bottom => ImmutableHashSet<T>.Empty;
19public override int Compare(ImmutableHashSet<T> oldValue, ImmutableHashSet<T> newValue, bool assertMonotonicity)
51public override ImmutableHashSet<T> Merge(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2) => MergeOrIntersect(value1, value2, merge: true);
53public ImmutableHashSet<T> Intersect(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2) => MergeOrIntersect(value1, value2, merge: false);
55private static ImmutableHashSet<T> MergeOrIntersect(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2, bool merge)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
src\roslyn\src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (1)
57nameof(ImmutableHashSet<>),
src\roslyn\src\Analyzers\Core\Analyzers\IDEDiagnosticIdToOptionMappingHelper.cs (9)
22private static readonly ConcurrentDictionary<string, ImmutableHashSet<IOption2>> s_diagnosticIdToOptionMap = new();
23private static readonly ConcurrentDictionary<string, ConcurrentDictionary<string, ImmutableHashSet<IOption2>>> s_diagnosticIdToLanguageSpecificOptionsMap = new();
25public static bool TryGetMappedOptions(string diagnosticId, string language, [NotNullWhen(true)] out ImmutableHashSet<IOption2>? options)
30public static ImmutableHashSet<string> KnownIDEDiagnosticIds
34public static void AddOptionMapping(string diagnosticId, ImmutableHashSet<IOption2> options)
66var map = s_diagnosticIdToLanguageSpecificOptionsMap.GetOrAdd(language, _ => new ConcurrentDictionary<string, ImmutableHashSet<IOption2>>());
79private static void AddOptionMapping(ConcurrentDictionary<string, ImmutableHashSet<IOption2>> map, string diagnosticId, ImmutableHashSet<IOption2> options)
83Debug.Assert(!map.TryGetValue(diagnosticId, out var existingOptions) || options.SetEquals(existingOptions));
src\40daf5e1cab76dff\PooledHashSetExtensions.cs (72)
49?? ImmutableHashSet<string>.Empty,
52?.Select(o => new KeyValuePair<string, ImmutableHashSet<string>>(o.Method, o.Parameters.ToImmutableHashSet()))
54?? ImmutableDictionary<string, ImmutableHashSet<string>>.Empty);
66taintedProperties: ImmutableHashSet<string>.Empty,
67transferProperties: ImmutableHashSet<string>.Empty,
71ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
73ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
75ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
77ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
93taintedProperties: ImmutableHashSet<string>.Empty,
94transferProperties: ImmutableHashSet<string>.Empty,
98ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
100ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
102ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
104ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
122?? ImmutableHashSet<string>.Empty,
123transferProperties: ImmutableHashSet<string>.Empty,
125ImmutableHashSet<ParameterMatcher>.Empty,
128?.Select<string, (MethodMatcher, ImmutableHashSet<string>)>(o =>
131ImmutableHashSet<string>.Empty.Add(TaintedTargetValue.Return)
134?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
136ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
138ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
140ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
172?? ImmutableHashSet<string>.Empty,
174?? ImmutableHashSet<string>.Empty,
176ImmutableHashSet<ParameterMatcher>.Empty,
178ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
184?? ImmutableHashSet<(PointsToCheck, string)>.Empty
187?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
193?? ImmutableHashSet<(ValueContentCheck, string)>.Empty
196?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
204?? ImmutableHashSet<(string, string)>.Empty))
206?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
229?? ImmutableHashSet<string>.Empty,
230transferProperties: ImmutableHashSet<string>.Empty,
232ImmutableHashSet<ParameterMatcher>.Empty,
234ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)>.Empty,
242?? ImmutableHashSet<(PointsToCheck, string)>.Empty
245?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)>.Empty,
253?? ImmutableHashSet<(ValueContentCheck, string)>.Empty
256?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)>.Empty,
258ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
279?.Select<string, (MethodMatcher, ImmutableHashSet<(string, string)>)>(o =>
282ImmutableHashSet<(string, string)>.Empty))
284?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
286?? ImmutableHashSet<string>.Empty);
309?? ImmutableHashSet<(string, string)>.Empty))
311?? ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)>.Empty,
313?? ImmutableHashSet<string>.Empty);
src\40daf5e1cab76dff\TaintedDataAnalysis.TaintedDataOperationVisitor.cs (12)
33private Dictionary<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)> TaintedSourcesBySink { get; }
39this.TaintedSourcesBySink = new Dictionary<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)>();
45foreach (KeyValuePair<SymbolAccess, (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins)> kvp in this.TaintedSourcesBySink)
540if (!this.TaintedSourcesBySink.TryGetValue(sink, out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins) data))
584out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SymbolAccess>.Builder SourceOrigins) data))
643foreach ((MethodMatcher methodMatcher, ImmutableHashSet<(string source, string end)> sourceToEnds) in sanitizerInfo.SanitizingMethods)
699else if (sinkInfo.SinkMethodParameters.TryGetValue(method.MetadataName, out var sinkParameters)
src\8ce1f4f68b646e6d\GlobalFlowStateAnalysisValueSet.cs (16)
19ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Unset);
21ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Empty);
23ImmutableHashSet<IAbstractAnalysisValue>.Empty, ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, 0, GlobalFlowStateAnalysisValueSetKind.Unknown);
26ImmutableHashSet<IAbstractAnalysisValue> analysisValues,
27ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents,
45ImmutableHashSet<IAbstractAnalysisValue> analysisValues,
46ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents,
54=> new(ImmutableHashSet.Create(analysisValue), ImmutableHashSet<GlobalFlowStateAnalysisValueSet>.Empty, height: 0, GlobalFlowStateAnalysisValueSetKind.Known);
56public ImmutableHashSet<IAbstractAnalysisValue> AnalysisValues { get; }
57public ImmutableHashSet<GlobalFlowStateAnalysisValueSet> Parents { get; }
109var negatedAnalysisValues = ImmutableHashSet.Create(AnalysisValues.Single().GetNegatedValue());
138return GlobalFlowStateAnalysisValueSet.Create(ImmutableHashSet<IAbstractAnalysisValue>.Empty, parentsBuilder.ToImmutable(), height);
141static GlobalFlowStateAnalysisValueSet GetNegateValueFromParents(ImmutableHashSet<GlobalFlowStateAnalysisValueSet> parents)
src\ffd9070534249528\PointsToAnalysis.PointsToDataFlowOperationVisitor.cs (17)
27private readonly PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> _escapedOperationLocationsBuilder;
28private readonly PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> _escapedReturnValueLocationsBuilder;
29private readonly PooledDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>.Builder> _escapedEntityLocationsBuilder;
41_escapedOperationLocationsBuilder = PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
42_escapedReturnValueLocationsBuilder = PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
43_escapedEntityLocationsBuilder = PooledDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>.Builder>.GetInstance();
50public ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughOperationsMap()
53public ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughReturnValuesMap()
56public ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> GetEscapedLocationsThroughEntitiesMap()
59private static ImmutableDictionary<T, ImmutableHashSet<AbstractLocation>> GetEscapedAbstractLocationsMapAndFreeBuilder<T>(
60PooledDictionary<T, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder)
67return ImmutableDictionary<T, ImmutableHashSet<AbstractLocation>>.Empty;
70var builder = ImmutableDictionary.CreateBuilder<T, ImmutableHashSet<AbstractLocation>>();
629private void HandleEscapingOperation(IOperation escapingOperation, IOperation escapedInstance, PooledDictionary<IOperation, ImmutableHashSet<AbstractLocation>.Builder> builder)
648PooledDictionary<TKey, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder,
670PooledDictionary<TKey, ImmutableHashSet<AbstractLocation>.Builder> escapedLocationsBuilder,
700private void HandleEscapingLocations(PointsToAbstractValue pointsToValueOfEscapedInstance, ImmutableHashSet<AbstractLocation>.Builder builder)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
26internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
27ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
31private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
32private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
33private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
34private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
35private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
36private readonly ImmutableHashSet<object> _distinctReferencedConstants;
44ImmutableHashSet<OperationKind> distinctOperatorKinds,
45ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
46ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
47ImmutableHashSet<CaseKind> distinctCaseKinds,
48ImmutableHashSet<ISymbol> distinctReferencedSymbols,
49ImmutableHashSet<object> distinctReferencedConstants)
70ImmutableHashSet<OperationKind> distinctOperatorKinds,
71ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
72ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
73ImmutableHashSet<CaseKind> distinctCaseKinds,
74ImmutableHashSet<ISymbol> distinctReferencedSymbols,
75ImmutableHashSet<object> distinctReferencedConstants)
96ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
97ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
98ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
99ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
100ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
101ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
291distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
292distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
293distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
294distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
295distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
296distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
40internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
41ImmutableHashSet<INamedTypeSymbol> coupledTypes)
49internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
55internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
196ImmutableHashSet<INamedTypeSymbol>.Builder builder,
350private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
401internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysisResult.cs (14)
13private readonly ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughOperationsMap;
14private readonly ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughReturnValuesMap;
15private readonly ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> _escapedLocationsThroughEntitiesMap;
16private readonly ImmutableHashSet<AnalysisEntity> _trackedEntities;
17private readonly ImmutableHashSet<PointsToAbstractValue> _trackedPointsToValues;
21ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughOperationsMap,
22ImmutableDictionary<IOperation, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughReturnValuesMap,
23ImmutableDictionary<AnalysisEntity, ImmutableHashSet<AbstractLocation>> escapedLocationsThroughEntitiesMap,
36public ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations(IOperation operation)
40public ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations(AnalysisEntity analysisEntity)
43private static ImmutableHashSet<AbstractLocation> GetEscapedAbstractLocations<TKey>(
45ImmutableDictionary<TKey, ImmutableHashSet<AbstractLocation>> map)
48if (map.TryGetValue(key, out var escapedLocations))
53return ImmutableHashSet<AbstractLocation>.Empty;
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\SourceInfo.cs (22)
41ImmutableHashSet<string> taintedProperties,
42ImmutableHashSet<ParameterMatcher> taintedArguments,
43ImmutableHashSet<(MethodMatcher, ImmutableHashSet<string>)> taintedMethods,
44ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(PointsToCheck, string)>)> taintedMethodsNeedsPointsToAnalysis,
45ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(ValueContentCheck, string)>)> taintedMethodsNeedsValueContentAnalysis,
46ImmutableHashSet<string> transferProperties,
47ImmutableHashSet<(MethodMatcher, ImmutableHashSet<(string, string)>)> transferMethods,
89public ImmutableHashSet<string> TransferProperties { get; }
94public ImmutableHashSet<string> TaintedProperties { get; }
100public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<string> TaintedTargets)> TaintedMethods { get; }
105public ImmutableHashSet<ParameterMatcher> TaintedArguments { get; }
128public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(PointsToCheck PointsToCheck, string TaintedTarget)>)> TaintedMethodsNeedsPointsToAnalysis { get; }
151public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(ValueContentCheck ValueContentCheck, string TaintedTarget)>)> TaintedMethodsNeedsValueContentAnalysis { get; }
170public ImmutableHashSet<(MethodMatcher MethodMatcher, ImmutableHashSet<(string IfTaintedParameter, string ThenTaintedTarget)>)> TransferMethods { get; }
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Analysis\TaintedDataAnalysis\TaintedDataConfig.cs (34)
32private static ImmutableDictionary<SinkKind, ImmutableHashSet<SourceInfo>> s_sinkKindToSourceInfo
33= ImmutableDictionary.Create<SinkKind, ImmutableHashSet<SourceInfo>>();
38private static ImmutableDictionary<SinkKind, ImmutableHashSet<SanitizerInfo>> s_sinkKindToSanitizerInfo
39= ImmutableDictionary.Create<SinkKind, ImmutableHashSet<SanitizerInfo>>();
103using PooledDictionary<ImmutableHashSet<SourceInfo>, Lazy<TaintedDataSymbolMap<SourceInfo>>> sourcesToSymbolMap =
104PooledDictionary<ImmutableHashSet<SourceInfo>, Lazy<TaintedDataSymbolMap<SourceInfo>>>.GetInstance();
105using PooledDictionary<ImmutableHashSet<SanitizerInfo>, Lazy<TaintedDataSymbolMap<SanitizerInfo>>> sanitizersToSymbolMap =
106PooledDictionary<ImmutableHashSet<SanitizerInfo>, Lazy<TaintedDataSymbolMap<SanitizerInfo>>>.GetInstance();
109using PooledDictionary<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)> sourceSanitizersToSinks =
110PooledDictionary<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)>.GetInstance();
115ImmutableHashSet<SourceInfo> sources = GetSourceInfos(sinkKind);
126ImmutableHashSet<SanitizerInfo> sanitizers = GetSanitizerInfos(sinkKind);
137ImmutableHashSet<SinkInfo> sinks = GetSinkInfos(sinkKind);
138if (!sourceSanitizersToSinks.TryGetValue((sources, sanitizers), out (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos) sinksPair))
148foreach (KeyValuePair<(ImmutableHashSet<SourceInfo> SourceInfos, ImmutableHashSet<SanitizerInfo> SanitizerInfos), (ImmutableHashSet<SinkKind>.Builder SinkKinds, ImmutableHashSet<SinkInfo>.Builder SinkInfos)> kvp in sourceSanitizersToSinks)
150ImmutableHashSet<SinkInfo> sinks = kvp.Value.SinkInfos.ToImmutable();
204private static ImmutableHashSet<SourceInfo> GetSourceInfos(SinkKind sinkKind)
206if (s_sinkKindToSourceInfo.TryGetValue(sinkKind, out var sourceInfo))
251return ImmutableHashSet<SourceInfo>.Empty;
257private static ImmutableHashSet<SanitizerInfo> GetSanitizerInfos(SinkKind sinkKind)
259if (s_sinkKindToSanitizerInfo.TryGetValue(sinkKind, out var sanitizerInfo))
307return ImmutableHashSet<SanitizerInfo>.Empty;
313private static ImmutableHashSet<SinkInfo> GetSinkInfos(SinkKind sinkKind)
362return ImmutableHashSet<SinkInfo>.Empty;
src\sdk\src\Microsoft.CodeAnalysis.NetAnalyzers\src\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\SetAbstractDomain.cs (14)
10public class SetAbstractDomain<T> : AbstractDomain<ImmutableHashSet<T>>
16public override ImmutableHashSet<T> Bottom => ImmutableHashSet<T>.Empty;
18public override int Compare(ImmutableHashSet<T> oldValue, ImmutableHashSet<T> newValue, bool assertMonotonicity)
50public override ImmutableHashSet<T> Merge(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2) => MergeOrIntersect(value1, value2, merge: true);
52public ImmutableHashSet<T> Intersect(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2) => MergeOrIntersect(value1, value2, merge: false);
54private static ImmutableHashSet<T> MergeOrIntersect(ImmutableHashSet<T> value1, ImmutableHashSet<T> value2, bool merge)
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\ComputationalComplexityMetrics.cs (36)
24internal static readonly ComputationalComplexityMetrics Default = new(0, 0, 0, 0, 0, ImmutableHashSet<OperationKind>.Empty,
25ImmutableHashSet<BinaryOperatorKind>.Empty, ImmutableHashSet<UnaryOperatorKind>.Empty, ImmutableHashSet<CaseKind>.Empty, ImmutableHashSet<ISymbol>.Empty, ImmutableHashSet<object>.Empty);
29private readonly ImmutableHashSet<OperationKind> _distinctOperatorKinds;
30private readonly ImmutableHashSet<BinaryOperatorKind> _distinctBinaryOperatorKinds;
31private readonly ImmutableHashSet<UnaryOperatorKind> _distinctUnaryOperatorKinds;
32private readonly ImmutableHashSet<CaseKind> _distinctCaseKinds;
33private readonly ImmutableHashSet<ISymbol> _distinctReferencedSymbols;
34private readonly ImmutableHashSet<object> _distinctReferencedConstants;
42ImmutableHashSet<OperationKind> distinctOperatorKinds,
43ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
44ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
45ImmutableHashSet<CaseKind> distinctCaseKinds,
46ImmutableHashSet<ISymbol> distinctReferencedSymbols,
47ImmutableHashSet<object> distinctReferencedConstants)
68ImmutableHashSet<OperationKind> distinctOperatorKinds,
69ImmutableHashSet<BinaryOperatorKind> distinctBinaryOperatorKinds,
70ImmutableHashSet<UnaryOperatorKind> distinctUnaryOperatorKinds,
71ImmutableHashSet<CaseKind> distinctCaseKinds,
72ImmutableHashSet<ISymbol> distinctReferencedSymbols,
73ImmutableHashSet<object> distinctReferencedConstants)
94ImmutableHashSet<OperationKind>.Builder? distinctOperatorKindsBuilder = null;
95ImmutableHashSet<BinaryOperatorKind>.Builder? distinctBinaryOperatorKindsBuilder = null;
96ImmutableHashSet<UnaryOperatorKind>.Builder? distinctUnaryOperatorKindsBuilder = null;
97ImmutableHashSet<CaseKind>.Builder? distinctCaseKindsBuilder = null;
98ImmutableHashSet<ISymbol>.Builder? distinctReferencedSymbolsBuilder = null;
99ImmutableHashSet<object>.Builder? distinctReferencedConstantsBuilder = null;
289distinctOperatorKindsBuilder != null ? distinctOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<OperationKind>.Empty,
290distinctBinaryOperatorKindsBuilder != null ? distinctBinaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<BinaryOperatorKind>.Empty,
291distinctUnaryOperatorKindsBuilder != null ? distinctUnaryOperatorKindsBuilder.ToImmutable() : ImmutableHashSet<UnaryOperatorKind>.Empty,
292distinctCaseKindsBuilder != null ? distinctCaseKindsBuilder.ToImmutable() : ImmutableHashSet<CaseKind>.Empty,
293distinctReferencedSymbolsBuilder != null ? distinctReferencedSymbolsBuilder.ToImmutable() : ImmutableHashSet<ISymbol>.Empty,
294distinctReferencedConstantsBuilder != null ? distinctReferencedConstantsBuilder.ToImmutable() : ImmutableHashSet<object>.Empty);
src\roslyn\src\RoslynAnalyzers\Utilities\Compiler\CodeMetrics\MetricsHelper.cs (7)
38internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
39ImmutableHashSet<INamedTypeSymbol> coupledTypes)
47internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
53internal static void AddCoupledNamedTypes(ImmutableHashSet<INamedTypeSymbol>.Builder builder, WellKnownTypeProvider wellKnownTypeProvider,
194ImmutableHashSet<INamedTypeSymbol>.Builder builder,
348private static void AddCoupledNamedTypesCore(ImmutableHashSet<INamedTypeSymbol>.Builder builder, ITypeSymbol typeOpt,
399internal static void RemoveContainingTypes(ISymbol symbol, ImmutableHashSet<INamedTypeSymbol>.Builder coupledTypesBuilder)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\IDictionaryExtensions.cs (7)
100public static bool MultiAdd<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value, IEqualityComparer<TValue>? comparer = null)
103if (dictionary.TryGetValue(key, out var set))
105var updated = set.Add(value);
158public static ImmutableDictionary<TKey, ImmutableHashSet<TValue>> MultiRemove<TKey, TValue>(this ImmutableDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)
161if (dictionary.TryGetValue(key, out var collection))
200public static void MultiRemove<TKey, TValue>(this IDictionary<TKey, ImmutableHashSet<TValue>> dictionary, TKey key, TValue value)