protected override void Analyze(ReportingDescriptorReference reportingDescriptorReference, string reportingDescriptorReferencePointer) { Tool tool = Context.CurrentRun.Tool; // Does this reporting descriptor reference refer to a reporting descriptor defined by // the driver or by one of the extensions? ToolComponent toolComponent; string toolComponentPathSegment; int?toolComponentIndex = reportingDescriptorReference.ToolComponent?.Index; if (toolComponentIndex >= 0) { // This reporting descriptor reference refers to an extension, but does that // extension exist? toolComponent = tool.Extensions?.Count > toolComponentIndex.Value ? tool.Extensions[toolComponentIndex.Value] : null; toolComponentPathSegment = $"{SarifPropertyName.Extensions}[{toolComponentIndex}]"; } else { toolComponent = tool.Driver; toolComponentPathSegment = SarifPropertyName.Driver; } // Does this reporting descriptor reference refer to a rule, a notification, or a taxon? string arrayPropertyName; IList <ReportingDescriptor> reportingDescriptors; switch (Context.CurrentReportingDescriptorKind) { case SarifValidationContext.ReportingDescriptorKind.Rule: arrayPropertyName = SarifPropertyName.Rules; reportingDescriptors = toolComponent?.Rules; break; case SarifValidationContext.ReportingDescriptorKind.Notification: arrayPropertyName = SarifPropertyName.Notifications; reportingDescriptors = toolComponent?.Notifications; break; case SarifValidationContext.ReportingDescriptorKind.Taxon: arrayPropertyName = SarifPropertyName.Taxa; reportingDescriptors = toolComponent?.Taxa; break; default: throw new InvalidOperationException("Unexpected call to Analyze(ReportingDescriptorReference)"); } ValidateArrayIndex( reportingDescriptorReference.Index, reportingDescriptors, reportingDescriptorReferencePointer, "reportingDescriptorReference", SarifPropertyName.Index, $"runs[{Context.CurrentRunIndex}].tool.{toolComponentPathSegment}.{arrayPropertyName}"); }
private void Visit(ReportingDescriptorReference reportingDescriptorReference, string reportingDescriptorReferencePointer) { Analyze(reportingDescriptorReference, reportingDescriptorReferencePointer); if (reportingDescriptorReference.ToolComponent != null) { Visit(reportingDescriptorReference.ToolComponent, reportingDescriptorReferencePointer.AtProperty(SarifPropertyName.ToolComponent)); } }
protected virtual void Analyze(ReportingDescriptorReference reportingDescriptorReference, string reportingDescriptorReferencePointer) { }