public override int Run()

in src/BinSkim.Driver/AnalyzeCommand.cs [71:149]


        public override int Run(AnalyzeOptions analyzeOptions)
        {
            if (!Environment.GetCommandLineArgs().Any(arg => arg.Equals("--sarif-output-version")))
            {
                analyzeOptions.SarifOutputVersion = Sarif.SarifVersion.Current;
            }

            if (s_UnitTestOutputVersion != Sarif.SarifVersion.Unknown)
            {
                analyzeOptions.SarifOutputVersion = s_UnitTestOutputVersion;
            }

#pragma warning disable CS0618 // Type or member is obsolete
            if (analyzeOptions.Verbose)
#pragma warning restore CS0618 // Type or member is obsolete
            {
                analyzeOptions.Level = new List<FailureLevel> { FailureLevel.Error, FailureLevel.Warning, FailureLevel.Note };
                analyzeOptions.Kind = new List<ResultKind> { ResultKind.Fail, ResultKind.NotApplicable, ResultKind.Pass };
            }

#pragma warning disable CS0618 // Type or member is obsolete
            if (analyzeOptions.ComputeFileHashes)
#pragma warning restore CS0618
            {
                OptionallyEmittedData dataToInsert = analyzeOptions.DataToInsert.ToFlags();
                dataToInsert |= OptionallyEmittedData.Hashes;

                analyzeOptions.DataToInsert = Enum.GetValues(typeof(OptionallyEmittedData)).Cast<OptionallyEmittedData>()
                    .Where(oed => dataToInsert.HasFlag(oed)).ToList();
            }

            int result = 0;

            try
            {
                result = base.Run(analyzeOptions);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            try
            {
                if (CompilerDataLogger.TelemetryEnabled &&
                    !string.IsNullOrEmpty(analyzeOptions.OutputFilePath) &&
                    this.FileSystem.FileExists(analyzeOptions.OutputFilePath))
                {
                    SarifLog sarifLog = ReadSarifLog(this.FileSystem, analyzeOptions);

                    AnalysisSummary summary = AnalysisSummaryExtractor.ExtractAnalysisSummary(
                        sarifLog, analyzeOptions);
                    CompilerDataLogger.Summarize(summary);

                    IEnumerable<ExecutionException> exceptions = AnalysisSummaryExtractor.ExtractExceptionData(sarifLog);
                    foreach (ExecutionException ex in exceptions)
                    {
                        CompilerDataLogger.WriteException(ex, summary);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                CompilerDataLogger.Flush();
            }

            // In BinSkim, no rule is ever applicable to every target type. For example,
            // we have checks that are only relevant to either 32-bit or 64-bit binaries.
            // Because of this, the return code bit for RuleNotApplicableToTarget is not
            // interesting (it will always be set).

            return analyzeOptions.RichReturnCode
                ? (int)((uint)result & ~(uint)RuntimeConditions.RuleNotApplicableToTarget)
                : result;
        }