Beispiel #1
0
        // TODO: Make the core baselining algorithm support BaselineFilteringMode.ToIncludedArtifacts
        private static SarifLog Baseline(SarifLog baselineLog, SarifLog currentLog)
        {
            // Baseline the complete log
            ISarifLogMatcher matcher   = ResultMatchingBaselinerFactory.GetDefaultResultMatchingBaseliner();
            SarifLog         outputLog = matcher.Match(new[] { baselineLog }, new[] { currentLog }).First();

            // Is this an incremental scan?
            BaselineFilteringMode filteringMode = currentLog.GetBaselineFilteringMode();

            // Mark all Results which are NOT in the new run as 'Unchanged'
            if (filteringMode == BaselineFilteringMode.ToIncludedArtifacts)
            {
                HashSet <string> includedArtifacts = new HashSet <string>(currentLog.AllResultArtifactUris().Select(uri => uri.OriginalString));

                foreach (Result result in outputLog.EnumerateResults())
                {
                    if (!ContainsUriInSet(result, includedArtifacts))
                    {
                        result.BaselineState = BaselineState.Unchanged;
                    }
                }
            }

            // Ensure the Baseline is sorted for fast future baselining
            SortForBaselining(outputLog);

            return(outputLog);
        }
Beispiel #2
0
 public static void SetBaselineFilteringMode(this SarifLog log, BaselineFilteringMode mode)
 {
     if (log == null)
     {
         throw new ArgumentNullException("log");
     }
     log.SetProperty <string>(SarifLogExtensions.BaselineFilteringPropertyName, mode.ToString());
 }