public void AnalyzingTarget(IAnalysisContext context) { foreach (IAnalysisLogger logger in Loggers) { logger.AnalyzingTarget(context); } }
public void Log(ResultKind messageKind, IAnalysisContext context, string message) { foreach (IResultLogger logger in Loggers) { logger.Log(messageKind, context, message); } }
public static string BuildMessage(IAnalysisContext context, string messageFormat, params string[] arguments) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (arguments == null) { throw new ArgumentNullException(nameof(arguments)); } // By convention, the first argument is always the target name, // which we retrieve from the context Debug.Assert(File.Exists(context.TargetUri.LocalPath)); string targetName = context.TargetUri.GetFileName(); string[] fullArguments = new string[arguments != null ? arguments.Length + 1 : 1]; fullArguments[0] = targetName; if (fullArguments.Length > 1) { arguments.CopyTo(fullArguments, 1); } return String.Format(CultureInfo.InvariantCulture, messageFormat, fullArguments); }
public void Log(ResultKind messageKind, IAnalysisContext context, string message) { switch (messageKind) { // These result types are optionally emitted case ResultKind.Pass: case ResultKind.Note: case ResultKind.NotApplicable: { if (Verbose) { Console.WriteLine(GetMessageText(context, message, messageKind)); } break; } // These result types are alwayss emitted case ResultKind.Error: case ResultKind.Warning: case ResultKind.InternalError: case ResultKind.ConfigurationError: { Console.WriteLine(GetMessageText(context, message, messageKind)); break; } default: { throw new InvalidOperationException(); } } }
public void Log(ResultKind messageKind, IAnalysisContext context, string message) { switch (messageKind) { case ResultKind.Pass: { PassTargets.Add(context.TargetUri.LocalPath); break; } case ResultKind.Error: { FailTargets.Add(context.TargetUri.LocalPath); break; } case ResultKind.NotApplicable: { NotApplicableTargets.Add(context.TargetUri.LocalPath); break; } case ResultKind.Note: case ResultKind.InternalError: case ResultKind.ConfigurationError: { throw new NotImplementedException(); } default: { throw new InvalidOperationException(); } } }
public void Log(ResultKind messageKind, IAnalysisContext context, string message) { switch (messageKind) { case ResultKind.Pass: { break; } case ResultKind.Error: { break; } case ResultKind.Warning: { break; } case ResultKind.NotApplicable: { if (context.Rule.Id == NoteDescriptors.InvalidTarget.Id) { _invalidTargetsCount++; } break; } case ResultKind.Note: { if (context.Rule.Id == NoteDescriptors.AnalyzingTarget.Id) { _targetsCount++; } break; } case ResultKind.InternalError: { break; } case ResultKind.ConfigurationError: { break; } default: { throw new InvalidOperationException(); } } }
public static void LogMissingFile(IAnalysisContext context, string fileName) { context.Rule = Errors.InvalidConfiguration; // A required file specified on the command line could not be found:'{0}'. context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.ConfigurationError, context, null, nameof(SdkResources.ERR0997_MissingFile), fileName)); context.RuntimeErrors |= RuntimeConditions.MissingFile; }
public static RuntimeConditions LogUnhandledEngineException(IAnalysisContext context, Exception ex) { context.Rule = Errors.AnalysisHalted; // An unhandled exception was raised during analysis: {0} context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.InternalError, context, null, nameof(SdkResources.ERR0999_UnhandledEngineException), ex.ToString())); return(RuntimeConditions.ExceptionInEngine); }
public static void LogExceptionLoadingTarget(IAnalysisContext context) { context.Rule = Errors.InvalidConfiguration; // An exception was raised attempting to load analysis target '{0}'. Exception information: // {1} context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.ConfigurationError, context, null, nameof(SdkResources.ERR0997_ExceptionLoadingAnalysisTarget), context.TargetLoadException.ToString())); context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingTargetFile; }
public static void LogExceptionLoadingPlugIn(string plugInFilePath, IAnalysisContext context, Exception ex) { context.Rule = Errors.InvalidConfiguration; context.TargetUri = new Uri(plugInFilePath); // An exception was raised attempting to load plug-in '{0}'. Exception information: // {1} context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.ConfigurationError, context, null, nameof(SdkResources.ERR0997_ExceptionLoadingPlugIn), ex.ToString())); context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingAnalysisPlugIn; }
public static void LogExceptionAccessingFile(IAnalysisContext context, string fileName, Exception ex) { context.Rule = Errors.InvalidConfiguration; // An exception was raised accessing a file specified on the command-line: '{0}'. Exception information: // {1} context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.ConfigurationError, context, null, nameof(SdkResources.ERR0997_ExceptionAccessingFile), fileName, ex.ToString())); context.RuntimeErrors |= RuntimeConditions.ExceptionAccessingFile; }
public static void LogExceptionCreatingLogFile(IAnalysisContext context, string fileName, Exception ex) { context.Rule = Errors.InvalidConfiguration; // An exception was raised attempting to create output file: '{0}'. Exception information: // {1} context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.ConfigurationError, context, null, nameof(SdkResources.ERR0997_ExceptionCreatingLogFile), fileName, ex.ToString())); context.RuntimeErrors |= RuntimeConditions.ExceptionCreatingLogfile; }
public void AnalyzingTarget(IAnalysisContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (Verbose) { Console.WriteLine(string.Format(CultureInfo.CurrentCulture, SdkResources.MSG001_AnalyzingTarget, context.TargetUri.GetFileName())); } }
public static void LogExceptionLoadingPdb(IAnalysisContext context, string exceptionMessage) { string ruleName = context.Rule.Name; context.Rule = Errors.InvalidConfiguration; // '{0}' was not evaluated for check '{1}' as an exception occurred loading its pdb: '{2}' context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.ConfigurationError, context, null, nameof(SdkResources.ERR0997_ExceptionLoadingPdb), ruleName, exceptionMessage)); context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingPdb; }
public void Log(ResultLevel messageKind, IAnalysisContext context, Region region, string ruleMessageId, params string[] arguments) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.Rule != null) { Rules[context.Rule.Id] = context.Rule; } ruleMessageId = RuleUtilities.NormalizeRuleMessageId(ruleMessageId, context.Rule.Id); LogJsonIssue(messageKind, context.TargetUri.LocalPath, region, context.Rule.Id, ruleMessageId, arguments); }
public void Log(FailureLevel level, IAnalysisContext context, Region region, string ruleMessageId, params string[] arguments) { if (context == null) { throw new ArgumentNullException(nameof(context)); } int ruleIndex = -1; if (context.Rule != null) { ruleIndex = LogRule(context.Rule); } ruleMessageId = RuleUtilities.NormalizeRuleMessageId(ruleMessageId, context.Rule.Id); LogJsonIssue(level, context.TargetUri.LocalPath, region, context.Rule.Id, ruleIndex, ruleMessageId, arguments); }
public void AnalyzingTarget(IAnalysisContext context) { // This code doesn't call through a common helper, such as // provided by the SDK Notes class, because we are in a specific // logger. If we called through a helper, we'd re-enter // through all aggregated loggers. // Analyzing target '{0}'... if (context == null) { throw new ArgumentNullException(nameof(context)); } string message = string.Format(CultureInfo.InvariantCulture, SdkResources.MSG001_AnalyzingTarget, context.TargetUri.GetFileName()); LogToolNotification( new Notification { Locations = new List <Location>() { new Location { PhysicalLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = context.TargetUri } } } }, Descriptor = new ReportingDescriptorReference { Id = Notes.Msg001AnalyzingTarget }, Message = new Message { Text = message }, Level = FailureLevel.None, TimeUtc = DateTime.UtcNow, }); }
public static void LogMissingreportingConfiguration(IAnalysisContext context, string reasonForNotAnalyzing) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Assembly assembly = Assembly.GetEntryAssembly(); assembly = assembly ?? Assembly.GetExecutingAssembly(); string exeName = Path.GetFileName(assembly.Location); // Check '{0}' was disabled while analyzing '{1}' because the analysis // was not configured with required policy ({2}). To resolve this, // configure and provide a policy file on the {3} command-line using // the --policy argument (recommended), or pass '--config default' // to invoke built-in settings. Invoke the {3} 'exportConfig' command // to produce an initial configuration file that can be edited, if // necessary, and passed back into the tool. string message = string.Format(CultureInfo.InvariantCulture, SdkResources.ERR997_MissingReportingConfiguration, context.Rule.Name, context.TargetUri.GetFileName(), reasonForNotAnalyzing, exeName); context.Logger.LogConfigurationNotification( new Notification { PhysicalLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = context.TargetUri }, }, Id = ERR997_MissingReportingConfiguration, RuleId = context.Rule.Id, Level = FailureLevel.Error, Message = new Message { Text = message } }); context.RuntimeErrors |= RuntimeConditions.RuleMissingRequiredConfiguration; }
public static void LogNotApplicableToSpecifiedTarget(IAnalysisContext context, string reasonForNotAnalyzing) { string ruleId = context.Rule.Id; string ruleName = context.Rule.Name; context.Rule = Notes.InvalidTarget; // '{0}' was not evaluated for check '{1}:{2}' as the analysis // is not relevant based on observed metadata: {3}. context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.NotApplicable, context, null, nameof(SdkResources.MSG1002_InvalidMetadata), ruleId, ruleName, reasonForNotAnalyzing)); context.RuntimeErrors |= RuntimeConditions.RuleNotApplicableToTarget; }
public static void LogOutputFileAlreadyExists(IAnalysisContext context, string outputFilePath) { if (context == null) { throw new ArgumentNullException(nameof(context)); } context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_OutputFileAlreadyExists, FailureLevel.Error, exception: null, persistExceptionStack: false, outputFilePath)); context.RuntimeErrors |= RuntimeConditions.OutputFileAlreadyExists; }
public static string BuildMessage(IAnalysisContext context, string messageFormatString, params string[] arguments) { // By convention, the first argument is always the target name, // which we retrieve from the context Debug.Assert(File.Exists(context.TargetUri.LocalPath)); string targetName = Path.GetFileName(context.TargetUri.LocalPath); string[] fullArguments = new string[arguments != null ? arguments.Length + 1 : 1]; fullArguments[0] = targetName; if (fullArguments.Length > 1) { arguments.CopyTo(fullArguments, 1); } return(String.Format(CultureInfo.InvariantCulture, messageFormatString, fullArguments)); }
public static RuntimeConditions LogUnhandledEngineException(IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // An unhandled exception was raised during analysis. context.Logger.LogToolNotification( CreateNotification( context.TargetUri, ERR999UnhandledEngineException, NotificationLevel.Error, exception, true)); return(RuntimeConditions.ExceptionInEngine); }
public static void LogNoRulesLoaded(IAnalysisContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // No analysis rules could be instantiated. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_NoRulesLoaded, NotificationLevel.Error, null, false)); context.RuntimeErrors |= RuntimeConditions.NoRulesLoaded; }
public static void LogAllRulesExplicitlyDisabled(IAnalysisContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // All rules were explicitly disabled so there is no work to do. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_AllRulesExplicitlyDisabled, FailureLevel.Error, null, false)); context.RuntimeErrors |= RuntimeConditions.NoRulesLoaded; }
public static void LogNoValidAnalysisTargets(IAnalysisContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // No valid analysis targets were specified. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_NoValidAnalysisTargets, NotificationLevel.Error, null, false)); context.RuntimeErrors |= RuntimeConditions.NoValidAnalysisTargets; }
public void AnalyzingTarget(IAnalysisContext context) { this.currentFileHash = context.Hashes.Sha256; if (HashToResultsMap.ContainsKey(currentFileHash)) { // We already have results cached for this file. This means that we shouldn't collect // any data in calls to Log. These calls are the driver framework 'replaying' the // cached results via the aggregated logger instance cacheLoggingData = false; } else { cacheLoggingData = true; HashToNotificationsMap[currentFileHash] = new List <Notification>(); HashToResultsMap[currentFileHash] = new List <Tuple <ReportingDescriptor, Result> >(); } }
public static void LogExceptionAccessingFile(IAnalysisContext context, string fileName, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Could not access a file specified on the command-line: '{0}'. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_ExceptionAccessingFile, NotificationLevel.Error, exception, false, fileName)); context.RuntimeErrors |= RuntimeConditions.ExceptionAccessingFile; }
public static void LogMissingFile(IAnalysisContext context, string fileName) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // A required file specified on the command line could not be found: '{0}'. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_MissingFile, NotificationLevel.Error, null, false, fileName)); context.RuntimeErrors |= RuntimeConditions.MissingFile; }
public static void LogInvalidInvocationPropertyName(IAnalysisContext context, string propertyName) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // '{0}' is not a property of the Invocation object. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_InvalidInvocationPropertyName, NotificationLevel.Error, null, false, propertyName)); context.RuntimeErrors |= RuntimeConditions.InvalidCommandLineOption; }
public static Result BuildResult(ResultKind messageKind, IAnalysisContext context, Region region, string formatId, params string[] arguments) { string[] messageArguments = arguments; formatId = RuleUtilities.NormalizeFormatId(context.Rule.Id, formatId); string targetPath = context.TargetUri?.LocalPath; Result result = new Result(); result.RuleId = context.Rule.Id; if (!string.IsNullOrEmpty(targetPath)) { // In the event of an analysis target, we always provide // the local path to this item as the 0th argument messageArguments = new string[arguments.Length + 1]; messageArguments[0] = Path.GetFileName(targetPath); arguments.CopyTo(messageArguments, 1); } result.FormattedRuleMessage = new FormattedRuleMessage() { FormatId = formatId, Arguments = messageArguments }; result.Kind = messageKind; if (targetPath != null) { result.Locations = new HashSet <Location> { new Sarif.Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri(targetPath), Region = region } } }; } return(result); }
public static void LogExceptionLoadingPlugin(string pluginFilePath, IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Could not load plug-in '{0}'. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_ExceptionLoadingPlugIn, NotificationLevel.Error, exception, false, pluginFilePath)); context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingAnalysisPlugin; }
public static void LogExceptionLoadingTarget(IAnalysisContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Could not load analysis target '{0}'. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_ExceptionLoadingAnalysisTarget, NotificationLevel.Error, context.TargetLoadException, false, context.TargetUri.GetFileName())); context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingTargetFile; }
public static void LogExceptionCreatingLogFile(IAnalysisContext context, string fileName, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // Could not create output file: '{0}' context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_ExceptionCreatingLogFile, NotificationLevel.Error, exception, false, fileName)); context.RuntimeErrors |= RuntimeConditions.ExceptionCreatingLogFile; }
public static Result BuildResult(ResultLevel level, IAnalysisContext context, Region region, string formatId, params string[] arguments) { //validating parameters if (context == null) { throw new ArgumentNullException(nameof(context)); } if (arguments == null) { throw new ArgumentNullException(nameof(arguments)); } formatId = RuleUtilities.NormalizeFormatId(context.Rule.Id, formatId); Result result = new Result { RuleId = context.Rule.Id, FormattedRuleMessage = new FormattedRuleMessage() { FormatId = formatId, Arguments = arguments }, Level = level }; string targetPath = context.TargetUri?.LocalPath; if (targetPath != null) { result.Locations = new List<Location> { new Sarif.Location { AnalysisTarget = new PhysicalLocation { Uri = new Uri(targetPath), Region = region } }}; } return result; }
public static void LogUnsupportedPlatformForRule(IAnalysisContext context, string ruleId, SupportedPlatform supportedOS, SupportedPlatform currentOS) { // Rule '{0}' was disabled as it cannot run on the current platform '{1}'. It can only run on '{2}'. if (context == null) { throw new ArgumentNullException(nameof(context)); } string message = string.Format(CultureInfo.InvariantCulture, SdkResources.WRN998_NotSupportedPlatform, ruleId, currentOS, supportedOS); context.Logger.LogConfigurationNotification( new Notification { Locations = new List <Location> { new Location { PhysicalLocation = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = context.TargetUri } } } }, Descriptor = new ReportingDescriptorReference { Id = Wrn998_UnsupportedPlatform }, Message = new Message { Text = message }, Level = FailureLevel.Warning, }); context.RuntimeErrors |= RuntimeConditions.RuleCannotRunOnPlatform; }
public static void LogNoRulesLoaded(IAnalysisContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // No analysis rules could be instantiated. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_NoRulesLoaded, ruleId: null, FailureLevel.Error, exception: null, persistExceptionStack: false, messageFormat: null)); context.RuntimeErrors |= RuntimeConditions.NoRulesLoaded; }
public static void LogNotApplicableToSpecifiedTarget(IAnalysisContext context, string reasonForNotAnalyzing) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Debug.Assert(context.TargetUri != null); // '{0}' was not evaluated for check '{1}' because the analysis // is not relevant for the following reason: {2}. context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultKind.NotApplicable, context, null, nameof(SdkResources.NotApplicable_InvalidMetadata), context.TargetUri.GetFileName(), context.Rule.Name, reasonForNotAnalyzing)); context.RuntimeErrors |= RuntimeConditions.RuleNotApplicableToTarget; }
public static void LogNotApplicableToSpecifiedTarget(IAnalysisContext context, string reasonForNotAnalyzing) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Debug.Assert(context.TargetUri != null); // '{0}' was not evaluated for check '{1}' as the analysis // is not relevant based on observed metadata: {2}. context.Logger.Log(context.Rule, RuleUtilities.BuildResult(ResultLevel.NotApplicable, context, null, nameof(SdkResources.NotApplicable_InvalidMetadata), context.TargetUri.GetFileName(), context.Rule.Name, reasonForNotAnalyzing)); context.RuntimeErrors |= RuntimeConditions.RuleNotApplicableToTarget; }
public static void LogExceptionInvalidTarget(IAnalysisContext context) { // '{0}' was not analyzed as it does not appear to be a valid file type for analysis. if (context == null) { throw new ArgumentNullException(nameof(context)); } string message = string.Format(CultureInfo.InvariantCulture, SdkResources.WRN997_InvalidTarget, context.TargetUri.GetFileName()); context.Logger.LogConfigurationNotification( new Notification { PhysicalLocation = new PhysicalLocation { Uri = context.TargetUri }, Id = Wrn997InvalidTarget, Message = message, Level = NotificationLevel.Note, }); context.RuntimeErrors |= RuntimeConditions.TargetNotValidToAnalyze; }
public void Log(ResultLevel messageKind, IAnalysisContext context, Region region, string formatId, params string[] arguments) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.Rule != null) { Rules[context.Rule.Id] = context.Rule; } formatId = RuleUtilities.NormalizeFormatId(context.Rule.Id, formatId); LogJsonIssue(messageKind, context.TargetUri.LocalPath, region, context.Rule.Id, formatId, arguments); }
public static void LogMissingRuleConfiguration(IAnalysisContext context, string reasonForNotAnalyzing) { if (context == null) { throw new ArgumentNullException(nameof(context)); } Assembly assembly = Assembly.GetEntryAssembly(); assembly = assembly ?? Assembly.GetExecutingAssembly(); string exeName = Path.GetFileName(assembly.Location); // Check '{0}' was disabled while analyzing '{1}' because the analysis // was not configured with required policy ({2}). To resolve this, // configure and provide a policy file on the {3} command-line using // the --policy argument (recommended), or pass '--config default' // to invoke built-in settings. Invoke the {3} 'exportConfig' command // to produce an initial configuration file that can be edited, if // necessary, and passed back into the tool. string message = string.Format(CultureInfo.InvariantCulture, SdkResources.ERR997_MissingRuleConfiguration, context.Rule.Name, context.TargetUri.GetFileName(), reasonForNotAnalyzing, exeName); context.Logger.LogConfigurationNotification( new Notification { PhysicalLocation = new PhysicalLocation { Uri = context.TargetUri }, Id = ERR997_MissingRuleConfiguration, RuleId = context.Rule.Id, Level = NotificationLevel.Error, Message = message }); context.RuntimeErrors |= RuntimeConditions.RuleMissingRequiredConfiguration; }
public static void LogExceptionInstantiatingSkimmers( IAnalysisContext context, IEnumerable<Assembly> skimmerAssemblies, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } string plugins = string.Join(", ", skimmerAssemblies.Select(sa => '"' + Path.GetFileName(sa.Location) + '"')); // Could not instantiate skimmers from the following plugins: {0} context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_ExceptionInstantiatingSkimmers, NotificationLevel.Error, exception, false, plugins)); context.RuntimeErrors |= RuntimeConditions.ExceptionInstantiatingSkimmers; }
public static RuntimeConditions LogUnhandledEngineException(IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // An unhandled exception was raised during analysis. context.Logger.LogToolNotification( CreateNotification( context.TargetUri, ERR999UnhandledEngineException, NotificationLevel.Error, exception, true)); return RuntimeConditions.ExceptionInEngine; }
protected CommonCodeProcessor(IAnalysisContext context, MessageList messages = null, bool throwErrors = false) { m_Context = context; m_Messages = messages ?? (context!=null? context.Messages : null); m_ThrowErrors = throwErrors; }
public static void LogUnhandledExceptionInitializingRule(IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // An unhandled exception was encountered initializing check '{0}', which // has been disabled for the remainder of the analysis. context.Logger.LogToolNotification( CreateNotification( context.TargetUri, ERR998_ExceptionInInitialize, context.Rule.Id, NotificationLevel.Error, exception, true, context.Rule.Name)); context.RuntimeErrors |= RuntimeConditions.ExceptionInSkimmerInitialize; }
public override ILexer MakeLexer(IAnalysisContext context, SourceCodeRef srcRef, ISourceText source, MessageList messages = null, bool throwErrors = false) { return new LaconfigLexer(context, srcRef, source, messages, throwErrors); }
public void AnalyzingTarget(IAnalysisContext context) { // This code doesn't call through a common helper, such as // provided by the SDK Notes class, because we are in a specific // logger. If we called through a helper, we'd re-enter // through all aggregated loggers. // Analyzing target '{0}'... if (context == null) { throw new ArgumentNullException(nameof(context)); } string message = string.Format(CultureInfo.InvariantCulture, SdkResources.MSG001_AnalyzingTarget, context.TargetUri.GetFileName()); LogToolNotification( new Notification { PhysicalLocation = new PhysicalLocation { Uri = context.TargetUri }, Id = Notes.Msg001AnalyzingTarget, Message = message, Level = NotificationLevel.Note, Time = DateTime.UtcNow, }); }
public static RuntimeConditions LogUnhandledRuleExceptionAnalyzingTarget( HashSet<string> disabledSkimmers, IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // An unhandled exception was encountered analyzing '{0}' for check '{1}', // which has been disabled for the remainder of the analysis.The // exception may have resulted from a problem related to parsing // image metadata and not specific to the rule, however. context.Logger.LogToolNotification( CreateNotification( context.TargetUri, ERR998_ExceptionInAnalyze, context.Rule.Id, NotificationLevel.Error, exception, true, context.TargetUri.GetFileName(), context.Rule.Name)); if (disabledSkimmers != null) { disabledSkimmers.Add(context.Rule.Id); } return RuntimeConditions.ExceptionInSkimmerAnalyze; }
public static void LogUnhandledRuleExceptionAssessingTargetApplicability( HashSet<string> disabledSkimmers, IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // An unhandled exception was raised attempting to determine whether '{0}' // is a valid analysis target for check '{1}' (which has been disabled // for the remainder of the analysis). The exception may have resulted // from a problem related to parsing image metadata and not specific to // the rule, however. context.Logger.LogToolNotification( CreateNotification( context.TargetUri, ERR998_ExceptionInCanAnalyze, context.Rule.Id, NotificationLevel.Error, exception, true, context.TargetUri.GetFileName(), context.Rule.Name)); if (disabledSkimmers != null) { disabledSkimmers.Add(context.Rule.Id); } context.RuntimeErrors |= RuntimeConditions.ExceptionRaisedInSkimmerCanAnalyze; }
public static void LogExceptionLoadingPdb(IAnalysisContext context, Exception exception) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // '{0}' was not evaluated for check '{1}' because its PDB could not be loaded. context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR997_ExceptionLoadingPdb, context.Rule.Id, NotificationLevel.Error, exception, false, context.TargetUri.GetFileName(), context.Rule.Name)); context.RuntimeErrors |= RuntimeConditions.ExceptionLoadingPdb; }
public static void LogTargetParseError(IAnalysisContext context, Region region, string message) { if (context == null) { throw new ArgumentNullException(nameof(context)); } // {0}({1}): error {2}: {3} context.Logger.LogConfigurationNotification( CreateNotification( context.TargetUri, ERR1000_ParseError, NotificationLevel.Error, null, false, context.TargetUri.LocalPath, region.FormatForVisualStudio(), ERR1000_ParseError, message)); context.RuntimeErrors |= RuntimeConditions.TargetParseError; }
protected SourceRefCommonCodeProcessor(IAnalysisContext context, SourceCodeRef srcRef, MessageList messages = null, bool throwErrors = false) : base(context, messages, throwErrors) { m_SourceCodeReference = srcRef; }