コード例 #1
0
        public void RewriteUri_RewritesAllFiles(int fileCount)
        {
            Random          random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output);
            List <SarifLog> logs   = new List <SarifLog>();

            for (int i = 0; i < fileCount; i++)
            {
                logs.Add(RandomSarifLogGenerator.GenerateSarifLogWithRuns(random, random.Next(10)));
            }

            bool rebaseRelativeUris = false;
            IActionWrapper <SarifLog> RewriteUri = SarifLogProcessorFactory.GetActionStage(SarifLogAction.RebaseUri, new string[] { "SRCROOT", rebaseRelativeUris.ToString(), @"C:\src\" });

            IEnumerable <SarifLog> rewrittenLogs = RewriteUri.Act(logs.AsEnumerable());

            rewrittenLogs.Should().HaveCount(logs.Count);

            // We just check that the log rewriter hit each run.  We'll test the RewriteUriVisitor more comprehensively in its own test class.
            foreach (SarifLog rewrittenLog in rewrittenLogs)
            {
                if (rewrittenLog.Runs != null)
                {
                    foreach (Run run in rewrittenLog.Runs)
                    {
                        run.OriginalUriBaseIds.Should().ContainKey("SRCROOT");
                    }
                }
            }
        }
コード例 #2
0
        public SarifLogPipeline(List <SarifLogActionTuple> actions)
        {
            this.Actions = actions;

            _pipeline = new GenericActionPipeline <SarifLog>(Actions.Select(a => SarifLogProcessorFactory.GetActionStage(a.Action, a.Parameters)));
        }
コード例 #3
0
 public static IEnumerable <SarifLog> MakeUrisAbsolute(this IEnumerable <SarifLog> sarifLogs)
 {
     return(SarifLogProcessorFactory.GetActionStage(SarifLogAction.MakeUrisAbsolute).Act(sarifLogs));
 }
コード例 #4
0
 public static IEnumerable <SarifLog> RebaseUri(this IEnumerable <SarifLog> sarifLog, string basePathToken, bool rebaseRelativeUris, Uri uri)
 {
     return(SarifLogProcessorFactory.GetActionStage(SarifLogAction.RebaseUri, basePathToken, rebaseRelativeUris.ToString(), uri.AbsoluteUri).Act(sarifLog));
 }
コード例 #5
0
 public static SarifLog Merge(this IEnumerable <SarifLog> sarifLog)
 {
     return(((GenericFoldAction <SarifLog>)SarifLogProcessorFactory.GetActionStage(SarifLogAction.Merge)).Fold(sarifLog));
 }
コード例 #6
0
 public static IEnumerable <SarifLog> InsertOptionalData(this IEnumerable <SarifLog> sarifLogs, OptionallyEmittedData optionalData)
 {
     return(SarifLogProcessorFactory.GetActionStage(SarifLogAction.InsertOptionalData, optionalData.ToString()).Act(sarifLogs));
 }
コード例 #7
0
 public static SarifLog Merge(this IEnumerable <SarifLog> sarifLog, bool mergeEmptyLogs = true)
 {
     return(((GenericFoldAction <SarifLog>)SarifLogProcessorFactory.GetActionStage(SarifLogAction.Merge, mergeEmptyLogs.ToString())).Fold(sarifLog));
 }