private static void SetDriverPropertiesFromFileVersionInfo(ToolComponent driver, FileVersionInfo fileVersion) { if (!string.IsNullOrEmpty(fileVersion.Comments)) { driver.SetProperty("Comments", fileVersion.Comments); } }
protected virtual void Init(ToolComponent driver, IEnumerable <ToolComponent> extensions, IDictionary <string, SerializedPropertyInfo> properties) { if (driver != null) { Driver = new ToolComponent(driver); } if (extensions != null) { var destination_0 = new List <ToolComponent>(); foreach (var value_0 in extensions) { if (value_0 == null) { destination_0.Add(null); } else { destination_0.Add(new ToolComponent(value_0)); } } Extensions = destination_0; } if (properties != null) { Properties = new Dictionary <string, SerializedPropertyInfo>(properties); } }
/// <summary> /// Initializes a new instance of the <see cref="ToolComponent" /> class from the specified instance. /// </summary> /// <param name="other"> /// The instance from which the new instance is to be initialized. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="other" /> is null. /// </exception> public ToolComponent(ToolComponent other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } Init(other.Guid, other.Name, other.Organization, other.Product, other.ProductSuite, other.ShortDescription, other.FullDescription, other.FullName, other.Version, other.SemanticVersion, other.DottedQuadFileVersion, other.ReleaseDateUtc, other.DownloadUri, other.InformationUri, other.GlobalMessageStrings, other.Notifications, other.Rules, other.Taxa, other.Locations, other.Language, other.Contents, other.IsComprehensive, other.LocalizedDataSemanticVersion, other.MinimumRequiredLocalizedDataSemanticVersion, other.AssociatedComponent, other.TranslationMetadata, other.SupportedTaxonomies, other.Properties); }
/// <summary> /// Look up the ReportingDescriptor for this Result. /// </summary> /// <param name="run">Run instance containing this Result</param> /// <returns>ReportingDescriptor for Result Rule, if available</returns> public ReportingDescriptor GetRule(Run run = null) { // Follows SARIF Spec 3.52.3 (reportingDescriptor lookup) // Ensure run argument or Result.Run was set if (run == null) { EnsureRunProvided(); run = this.Run; } if (run != null) { // Find the 'ToolComponent' for this Result (Run.Tool.Driver if absent) ToolComponent component = run.GetToolComponentFromReference(this.Rule?.ToolComponent); IList <ReportingDescriptor> rules = component?.Rules; // Look up by this.RuleIndex, if present if (this.RuleIndex >= 0) { return(GetRuleByIndex(rules, this.RuleIndex)); } // Look up by this.Rule.Index, if present if (this.Rule?.Index >= 0) { return(GetRuleByIndex(rules, this.Rule.Index)); } // Look up by this.Rule.Guid, if present if (!string.IsNullOrEmpty(this.Rule?.Guid) && rules != null) { ReportingDescriptor rule = component.GetRuleByGuid(this.Rule.Guid); if (rule != null) { return(rule); } } // Look up by this.RuleId or this.Rule.Id, if present string ruleId = this.RuleId ?? this.Rule?.Id; if (ruleId != null && rules != null) { ReportingDescriptor rule = component.GetRuleById(ruleId); if (rule != null) { return(rule); } } } // Otherwise, metadata is not available and RuleId is the only available property return(new ReportingDescriptor() { Id = this.RuleId ?? this.Rule?.Id }); }
/// <summary> /// Initializes a new instance of the <see cref="ToolComponent" /> class from the specified instance. /// </summary> /// <param name="other"> /// The instance from which the new instance is to be initialized. /// </param> /// <exception cref="ArgumentNullException"> /// Thrown if <paramref name="other" /> is null. /// </exception> public ToolComponent(ToolComponent other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } Init(other.Guid, other.Name, other.Organization, other.Product, other.ShortDescription, other.FullDescription, other.FullName, other.Version, other.SemanticVersion, other.DottedQuadFileVersion, other.DownloadUri, other.GlobalMessageStrings, other.NotificationDescriptors, other.RuleDescriptors, other.ArtifactIndices, other.Properties); }
/// <summary> /// Look up the ReportingDescriptor for this Result. /// </summary> /// <param name="run">Run instance containing this Result</param> /// <returns>ReportingDescriptor for Result Rule, if available</returns> public ReportingDescriptor GetRule(Run run = null) { // Follows SARIF Spec 3.52.3 (reportingDescriptor lookup) // Ensure run argument or Result.Run was set if (run == null) { EnsureRunProvided(); run = this.Run; } if (run != null) { // Find the 'ToolComponent' for this Result (Run.Tool.Driver if absent) ToolComponent component = run.GetToolComponentFromReference(this.Rule?.ToolComponent); IList <ReportingDescriptor> rules = component?.Rules; // Look up by this.RuleIndex, if present if (this.RuleIndex >= 0) { return(GetRuleByIndex(rules, this.RuleIndex)); } // Look up by this.RuleDescriptor.Index, if present if (this.Rule?.Index >= 0) { return(GetRuleByIndex(rules, this.Rule.Index)); } // Look up by this.RuleDescriptor, Guid, if present if (!String.IsNullOrEmpty(this.Rule?.Guid)) { if (rules != null) { foreach (ReportingDescriptor rule in rules) { if (rule.Guid == this.Rule.Guid) { return(rule); } } throw new ArgumentException($"ReportingDescriptorReference referred to Guid {this.Rule.Guid}, which was not found in toolComponent.Rules."); } } } // Otherwise, metadata is not available and RuleId is the only available property return(new ReportingDescriptor() { Id = this.RuleId ?? this.Rule?.Id }); }
private static IDictionary <string, SerializedPropertyInfo> CreatePropertiesFromFileVersionInfo(FileVersionInfo fileVersion) { var toolComponent = new ToolComponent(); if (!string.IsNullOrEmpty(fileVersion.Comments)) { toolComponent.SetProperty("Comments", fileVersion.Comments); } if (!string.IsNullOrEmpty(fileVersion.CompanyName)) { toolComponent.SetProperty("CompanyName", fileVersion.CompanyName); } if (!string.IsNullOrEmpty(fileVersion.ProductName)) { toolComponent.SetProperty("ProductName", fileVersion.ProductName); } return(toolComponent.Properties); }
public virtual ToolComponent VisitToolComponent(ToolComponent node) { if (node != null) { node.ShortDescription = VisitNullChecked(node.ShortDescription); node.FullDescription = VisitNullChecked(node.FullDescription); if (node.GlobalMessageStrings != null) { var keys = node.GlobalMessageStrings.Keys.ToArray(); foreach (var key in keys) { var value = node.GlobalMessageStrings[key]; if (value != null) { node.GlobalMessageStrings[key] = VisitNullChecked(value); } } } if (node.NotificationDescriptors != null) { for (int index_0 = 0; index_0 < node.NotificationDescriptors.Count; ++index_0) { node.NotificationDescriptors[index_0] = VisitNullChecked(node.NotificationDescriptors[index_0]); } } if (node.RuleDescriptors != null) { for (int index_0 = 0; index_0 < node.RuleDescriptors.Count; ++index_0) { node.RuleDescriptors[index_0] = VisitNullChecked(node.RuleDescriptors[index_0]); } } } return(node); }
public bool ValueEquals(ToolComponent other) => ValueComparer.Equals(this, other);
protected virtual void Init(Uri schema, SarifVersion version, string guid, string runGuid, Conversion conversion, IEnumerable <Graph> graphs, PropertyBag externalizedProperties, IEnumerable <Artifact> artifacts, IEnumerable <Invocation> invocations, IEnumerable <LogicalLocation> logicalLocations, IEnumerable <ThreadFlowLocation> threadFlowLocations, IEnumerable <Result> results, IEnumerable <ToolComponent> taxonomies, ToolComponent driver, IEnumerable <ToolComponent> extensions, IEnumerable <ToolComponent> policies, IEnumerable <ToolComponent> translations, IEnumerable <Address> addresses, IEnumerable <WebRequest> webRequests, IEnumerable <WebResponse> webResponses, IDictionary <string, SerializedPropertyInfo> properties) { if (schema != null) { Schema = new Uri(schema.OriginalString, schema.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative); } Version = version; Guid = guid; RunGuid = runGuid; if (conversion != null) { Conversion = new Conversion(conversion); } if (graphs != null) { var destination_0 = new List <Graph>(); foreach (var value_0 in graphs) { if (value_0 == null) { destination_0.Add(null); } else { destination_0.Add(new Graph(value_0)); } } Graphs = destination_0; } if (externalizedProperties != null) { ExternalizedProperties = new PropertyBag(externalizedProperties); } if (artifacts != null) { var destination_1 = new List <Artifact>(); foreach (var value_1 in artifacts) { if (value_1 == null) { destination_1.Add(null); } else { destination_1.Add(new Artifact(value_1)); } } Artifacts = destination_1; } if (invocations != null) { var destination_2 = new List <Invocation>(); foreach (var value_2 in invocations) { if (value_2 == null) { destination_2.Add(null); } else { destination_2.Add(new Invocation(value_2)); } } Invocations = destination_2; } if (logicalLocations != null) { var destination_3 = new List <LogicalLocation>(); foreach (var value_3 in logicalLocations) { if (value_3 == null) { destination_3.Add(null); } else { destination_3.Add(new LogicalLocation(value_3)); } } LogicalLocations = destination_3; } if (threadFlowLocations != null) { var destination_4 = new List <ThreadFlowLocation>(); foreach (var value_4 in threadFlowLocations) { if (value_4 == null) { destination_4.Add(null); } else { destination_4.Add(new ThreadFlowLocation(value_4)); } } ThreadFlowLocations = destination_4; } if (results != null) { var destination_5 = new List <Result>(); foreach (var value_5 in results) { if (value_5 == null) { destination_5.Add(null); } else { destination_5.Add(new Result(value_5)); } } Results = destination_5; } if (taxonomies != null) { var destination_6 = new List <ToolComponent>(); foreach (var value_6 in taxonomies) { if (value_6 == null) { destination_6.Add(null); } else { destination_6.Add(new ToolComponent(value_6)); } } Taxonomies = destination_6; } if (driver != null) { Driver = new ToolComponent(driver); } if (extensions != null) { var destination_7 = new List <ToolComponent>(); foreach (var value_7 in extensions) { if (value_7 == null) { destination_7.Add(null); } else { destination_7.Add(new ToolComponent(value_7)); } } Extensions = destination_7; } if (policies != null) { var destination_8 = new List <ToolComponent>(); foreach (var value_8 in policies) { if (value_8 == null) { destination_8.Add(null); } else { destination_8.Add(new ToolComponent(value_8)); } } Policies = destination_8; } if (translations != null) { var destination_9 = new List <ToolComponent>(); foreach (var value_9 in translations) { if (value_9 == null) { destination_9.Add(null); } else { destination_9.Add(new ToolComponent(value_9)); } } Translations = destination_9; } if (addresses != null) { var destination_10 = new List <Address>(); foreach (var value_10 in addresses) { if (value_10 == null) { destination_10.Add(null); } else { destination_10.Add(new Address(value_10)); } } Addresses = destination_10; } if (webRequests != null) { var destination_11 = new List <WebRequest>(); foreach (var value_11 in webRequests) { if (value_11 == null) { destination_11.Add(null); } else { destination_11.Add(new WebRequest(value_11)); } } WebRequests = destination_11; } if (webResponses != null) { var destination_12 = new List <WebResponse>(); foreach (var value_12 in webResponses) { if (value_12 == null) { destination_12.Add(null); } else { destination_12.Add(new WebResponse(value_12)); } } WebResponses = destination_12; } if (properties != null) { Properties = new Dictionary <string, SerializedPropertyInfo>(properties); } }
/// <summary> /// Initializes a new instance of the <see cref="ExternalProperties" /> class from the supplied values. /// </summary> /// <param name="schema"> /// An initialization value for the <see cref="P:Schema" /> property. /// </param> /// <param name="version"> /// An initialization value for the <see cref="P:Version" /> property. /// </param> /// <param name="guid"> /// An initialization value for the <see cref="P:Guid" /> property. /// </param> /// <param name="runGuid"> /// An initialization value for the <see cref="P:RunGuid" /> property. /// </param> /// <param name="conversion"> /// An initialization value for the <see cref="P:Conversion" /> property. /// </param> /// <param name="graphs"> /// An initialization value for the <see cref="P:Graphs" /> property. /// </param> /// <param name="externalizedProperties"> /// An initialization value for the <see cref="P:ExternalizedProperties" /> property. /// </param> /// <param name="artifacts"> /// An initialization value for the <see cref="P:Artifacts" /> property. /// </param> /// <param name="invocations"> /// An initialization value for the <see cref="P:Invocations" /> property. /// </param> /// <param name="logicalLocations"> /// An initialization value for the <see cref="P:LogicalLocations" /> property. /// </param> /// <param name="threadFlowLocations"> /// An initialization value for the <see cref="P:ThreadFlowLocations" /> property. /// </param> /// <param name="results"> /// An initialization value for the <see cref="P:Results" /> property. /// </param> /// <param name="taxonomies"> /// An initialization value for the <see cref="P:Taxonomies" /> property. /// </param> /// <param name="driver"> /// An initialization value for the <see cref="P:Driver" /> property. /// </param> /// <param name="extensions"> /// An initialization value for the <see cref="P:Extensions" /> property. /// </param> /// <param name="policies"> /// An initialization value for the <see cref="P:Policies" /> property. /// </param> /// <param name="translations"> /// An initialization value for the <see cref="P:Translations" /> property. /// </param> /// <param name="addresses"> /// An initialization value for the <see cref="P:Addresses" /> property. /// </param> /// <param name="webRequests"> /// An initialization value for the <see cref="P:WebRequests" /> property. /// </param> /// <param name="webResponses"> /// An initialization value for the <see cref="P:WebResponses" /> property. /// </param> /// <param name="properties"> /// An initialization value for the <see cref="P:Properties" /> property. /// </param> public ExternalProperties(Uri schema, SarifVersion version, string guid, string runGuid, Conversion conversion, IEnumerable <Graph> graphs, PropertyBag externalizedProperties, IEnumerable <Artifact> artifacts, IEnumerable <Invocation> invocations, IEnumerable <LogicalLocation> logicalLocations, IEnumerable <ThreadFlowLocation> threadFlowLocations, IEnumerable <Result> results, IEnumerable <ToolComponent> taxonomies, ToolComponent driver, IEnumerable <ToolComponent> extensions, IEnumerable <ToolComponent> policies, IEnumerable <ToolComponent> translations, IEnumerable <Address> addresses, IEnumerable <WebRequest> webRequests, IEnumerable <WebResponse> webResponses, IDictionary <string, SerializedPropertyInfo> properties) { Init(schema, version, guid, runGuid, conversion, graphs, externalizedProperties, artifacts, invocations, logicalLocations, threadFlowLocations, results, taxonomies, driver, extensions, policies, translations, addresses, webRequests, webResponses, properties); }
private void Init(Uri schema, SarifVersion version, string guid, string runGuid, Conversion conversion, object graphs, PropertyBag externalizedProperties, IEnumerable <Artifact> artifacts, IEnumerable <Invocation> invocations, IEnumerable <LogicalLocation> logicalLocations, IEnumerable <ThreadFlowLocation> threadFlowLocations, IEnumerable <Result> results, IEnumerable <ReportingDescriptor> taxonomies, ToolComponent driver, IEnumerable <ToolComponent> extensions, IDictionary <string, SerializedPropertyInfo> properties) { if (schema != null) { Schema = new Uri(schema.OriginalString, schema.IsAbsoluteUri ? UriKind.Absolute : UriKind.Relative); } Version = version; Guid = guid; RunGuid = runGuid; if (conversion != null) { Conversion = new Conversion(conversion); } Graphs = graphs; if (externalizedProperties != null) { ExternalizedProperties = new PropertyBag(externalizedProperties); } if (artifacts != null) { var destination_0 = new List <Artifact>(); foreach (var value_0 in artifacts) { if (value_0 == null) { destination_0.Add(null); } else { destination_0.Add(new Artifact(value_0)); } } Artifacts = destination_0; } if (invocations != null) { var destination_1 = new List <Invocation>(); foreach (var value_1 in invocations) { if (value_1 == null) { destination_1.Add(null); } else { destination_1.Add(new Invocation(value_1)); } } Invocations = destination_1; } if (logicalLocations != null) { var destination_2 = new List <LogicalLocation>(); foreach (var value_2 in logicalLocations) { if (value_2 == null) { destination_2.Add(null); } else { destination_2.Add(new LogicalLocation(value_2)); } } LogicalLocations = destination_2; } if (threadFlowLocations != null) { var destination_3 = new List <ThreadFlowLocation>(); foreach (var value_3 in threadFlowLocations) { if (value_3 == null) { destination_3.Add(null); } else { destination_3.Add(new ThreadFlowLocation(value_3)); } } ThreadFlowLocations = destination_3; } if (results != null) { var destination_4 = new List <Result>(); foreach (var value_4 in results) { if (value_4 == null) { destination_4.Add(null); } else { destination_4.Add(new Result(value_4)); } } Results = destination_4; } if (taxonomies != null) { var destination_5 = new List <ReportingDescriptor>(); foreach (var value_5 in taxonomies) { if (value_5 == null) { destination_5.Add(null); } else { destination_5.Add(new ReportingDescriptor(value_5)); } } Taxonomies = destination_5; } if (driver != null) { Driver = new ToolComponent(driver); } if (extensions != null) { var destination_6 = new List <ToolComponent>(); foreach (var value_6 in extensions) { if (value_6 == null) { destination_6.Add(null); } else { destination_6.Add(new ToolComponent(value_6)); } } Extensions = destination_6; } if (properties != null) { Properties = new Dictionary <string, SerializedPropertyInfo>(properties); } }
/// <summary> /// Initializes a new instance of the <see cref="ExternalProperties" /> class from the supplied values. /// </summary> /// <param name="schema"> /// An initialization value for the <see cref="P:Schema" /> property. /// </param> /// <param name="version"> /// An initialization value for the <see cref="P:Version" /> property. /// </param> /// <param name="guid"> /// An initialization value for the <see cref="P:Guid" /> property. /// </param> /// <param name="runGuid"> /// An initialization value for the <see cref="P:RunGuid" /> property. /// </param> /// <param name="conversion"> /// An initialization value for the <see cref="P:Conversion" /> property. /// </param> /// <param name="graphs"> /// An initialization value for the <see cref="P:Graphs" /> property. /// </param> /// <param name="externalizedProperties"> /// An initialization value for the <see cref="P:ExternalizedProperties" /> property. /// </param> /// <param name="artifacts"> /// An initialization value for the <see cref="P:Artifacts" /> property. /// </param> /// <param name="invocations"> /// An initialization value for the <see cref="P:Invocations" /> property. /// </param> /// <param name="logicalLocations"> /// An initialization value for the <see cref="P:LogicalLocations" /> property. /// </param> /// <param name="threadFlowLocations"> /// An initialization value for the <see cref="P:ThreadFlowLocations" /> property. /// </param> /// <param name="results"> /// An initialization value for the <see cref="P:Results" /> property. /// </param> /// <param name="taxonomies"> /// An initialization value for the <see cref="P:Taxonomies" /> property. /// </param> /// <param name="driver"> /// An initialization value for the <see cref="P:Driver" /> property. /// </param> /// <param name="extensions"> /// An initialization value for the <see cref="P:Extensions" /> property. /// </param> /// <param name="properties"> /// An initialization value for the <see cref="P:Properties" /> property. /// </param> public ExternalProperties(Uri schema, SarifVersion version, string guid, string runGuid, Conversion conversion, object graphs, PropertyBag externalizedProperties, IEnumerable <Artifact> artifacts, IEnumerable <Invocation> invocations, IEnumerable <LogicalLocation> logicalLocations, IEnumerable <ThreadFlowLocation> threadFlowLocations, IEnumerable <Result> results, IEnumerable <ReportingDescriptor> taxonomies, ToolComponent driver, IEnumerable <ToolComponent> extensions, IDictionary <string, SerializedPropertyInfo> properties) { Init(schema, version, guid, runGuid, conversion, graphs, externalizedProperties, artifacts, invocations, logicalLocations, threadFlowLocations, results, taxonomies, driver, extensions, properties); }
/// <summary> /// Initializes a new instance of the <see cref="Tool" /> class from the supplied values. /// </summary> /// <param name="driver"> /// An initialization value for the <see cref="P:Driver" /> property. /// </param> /// <param name="extensions"> /// An initialization value for the <see cref="P:Extensions" /> property. /// </param> /// <param name="properties"> /// An initialization value for the <see cref="P:Properties" /> property. /// </param> public Tool(ToolComponent driver, IEnumerable <ToolComponent> extensions, IDictionary <string, SerializedPropertyInfo> properties) { Init(driver, extensions, properties); }