public virtual VersionControlDetails VisitVersionControlDetails(VersionControlDetails node)
        {
            if (node != null)
            {
            }

            return(node);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VersionControlDetails" /> class from the specified instance.
        /// </summary>
        /// <param name="other">
        /// The instance from which the new instance is to be initialized.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="other" /> is null.
        /// </exception>
        public VersionControlDetails(VersionControlDetails other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Init(other.Uri, other.RevisionId, other.Branch, other.Tag, other.Timestamp, other.Properties);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="VersionControlDetails" /> class from the specified instance.
        /// </summary>
        /// <param name="other">
        /// The instance from which the new instance is to be initialized.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if <paramref name="other" /> is null.
        /// </exception>
        public VersionControlDetails(VersionControlDetails other)
        {
            if (other == null)
            {
                throw new ArgumentNullException(nameof(other));
            }

            Init(other.RepositoryUri, other.RevisionId, other.Branch, other.RevisionTag, other.AsOfTimeUtc, other.MappedTo, other.Properties);
        }
        public virtual VersionControlDetails VisitVersionControlDetails(VersionControlDetails node)
        {
            if (node != null)
            {
                node.MappedTo = VisitNullChecked(node.MappedTo);
            }

            return(node);
        }
Exemple #5
0
        public void SarifLogger_WritesRunProperties()
        {
            string propertyName         = "numberValue";
            double propertyValue        = 3.14;
            string logicalId            = nameof(logicalId) + ":" + Guid.NewGuid().ToString();
            string baselineInstanceGuid = nameof(baselineInstanceGuid) + ":" + Guid.NewGuid().ToString();
            string runInstanceGuid      = Guid.NewGuid().ToString();
            string automationLogicalId  = nameof(automationLogicalId) + ":" + Guid.NewGuid().ToString();
            string runInstanceId        = automationLogicalId + "/" + runInstanceGuid;
            string architecture         = nameof(architecture) + ":" + "x86";
            var    conversion           = new Conversion()
            {
                Tool = DefaultTool
            };
            var utcNow                = DateTime.UtcNow;
            var versionControlUri     = new Uri("https://www.github.com/contoso/contoso");
            var versionControlDetails = new VersionControlDetails()
            {
                RepositoryUri = versionControlUri, AsOfTimeUtc = DateTime.UtcNow
            };
            string originalUriBaseIdKey   = "testBase";
            Uri    originalUriBaseIdValue = new Uri("https://sourceserver.contoso.com");
            var    originalUriBaseIds     = new Dictionary <string, ArtifactLocation>()
            {
                { originalUriBaseIdKey, new ArtifactLocation {
                      Uri = originalUriBaseIdValue
                  } }
            };
            string        defaultEncoding = "UTF7";
            List <string> redactionTokens = new List <string> {
                "[MY_REDACTION_TOKEN]"
            };


            var sb = new StringBuilder();

            var run = new Run();

            using (var textWriter = new StringWriter(sb))
            {
                run.SetProperty(propertyName, propertyValue);

                run.AutomationDetails = new RunAutomationDetails
                {
                    Id   = runInstanceId,
                    Guid = runInstanceGuid,
                };

                run.BaselineGuid             = baselineInstanceGuid;
                run.Conversion               = conversion;
                run.VersionControlProvenance = new[] { versionControlDetails };
                run.OriginalUriBaseIds       = originalUriBaseIds;
                run.DefaultEncoding          = defaultEncoding;
                run.RedactionTokens          = redactionTokens;

                using (var sarifLogger = new SarifLogger(
                           textWriter,
                           run: run,
                           invocationPropertiesToLog: null))
                {
                }
            }

            string output   = sb.ToString();
            var    sarifLog = JsonConvert.DeserializeObject <SarifLog>(output);

            run = sarifLog.Runs[0];

            run.GetProperty <double>(propertyName).Should().Be(propertyValue);
            run.AutomationDetails.Guid.Should().Be(runInstanceGuid);
            run.BaselineGuid.Should().Be(baselineInstanceGuid);
            run.AutomationDetails.Id.Should().Be(runInstanceId);
            run.Conversion.Tool.Should().BeEquivalentTo(DefaultTool);
            run.VersionControlProvenance[0].RepositoryUri.Should().BeEquivalentTo(versionControlUri);
            run.OriginalUriBaseIds[originalUriBaseIdKey].Uri.Should().Be(originalUriBaseIdValue);
            run.DefaultEncoding.Should().Be(defaultEncoding);
            run.RedactionTokens[0].Should().Be(redactionTokens[0]);
        }
Exemple #6
0
        public void SarifLogger_WritesRunProperties()
        {
            string propertyName         = "numberValue";
            double propertyValue        = 3.14;
            string logicalId            = nameof(logicalId) + ":" + Guid.NewGuid().ToString();
            string baselineInstanceGuid = nameof(baselineInstanceGuid) + ":" + Guid.NewGuid().ToString();
            string automationLogicalId  = nameof(automationLogicalId) + ":" + Guid.NewGuid().ToString();
            string architecture         = nameof(architecture) + ":" + "x86";
            var    conversion           = new Conversion()
            {
                Tool = DefaultTool
            };
            var utcNow                = DateTime.UtcNow;
            var versionControlUri     = new Uri("https://www.github.com/contoso/contoso");
            var versionControlDetails = new VersionControlDetails()
            {
                Uri = versionControlUri, Timestamp = DateTime.UtcNow
            };
            string originalUriBaseIdKey   = "testBase";
            Uri    originalUriBaseIdValue = new Uri("https://sourceserver.contoso.com");
            var    originalUriBaseIds     = new Dictionary <string, Uri>()
            {
                { originalUriBaseIdKey, originalUriBaseIdValue }
            };
            string defaultFileEncoding = "UTF7";
            string richMessageMimeType = "sarif-markdown";
            string redactionToken      = "[MY_REDACTION_TOKEN]";

            var sb = new StringBuilder();

            var run = new Run();

            using (var textWriter = new StringWriter(sb))
            {
                run.SetProperty(propertyName, propertyValue);

                run.LogicalId                = logicalId;
                run.BaselineInstanceGuid     = baselineInstanceGuid;
                run.AutomationLogicalId      = automationLogicalId;
                run.Architecture             = architecture;
                run.Conversion               = conversion;
                run.VersionControlProvenance = new[] { versionControlDetails };
                run.OriginalUriBaseIds       = originalUriBaseIds;
                run.DefaultFileEncoding      = defaultFileEncoding;
                run.RichMessageMimeType      = richMessageMimeType;
                run.RedactionToken           = redactionToken;

                using (var sarifLogger = new SarifLogger(
                           textWriter,
                           run: run,
                           invocationPropertiesToLog: null))
                {
                }
            }

            string output   = sb.ToString();
            var    sarifLog = JsonConvert.DeserializeObject <SarifLog>(output);

            run = sarifLog.Runs[0];

            run.GetProperty <double>(propertyName).Should().Be(propertyValue);
            run.LogicalId.Should().Be(logicalId);
            run.BaselineInstanceGuid.Should().Be(baselineInstanceGuid);
            run.AutomationLogicalId.Should().Be(automationLogicalId);
            run.Architecture.Should().Be(architecture);
            run.Conversion.Tool.Should().BeEquivalentTo(DefaultTool);
            //run.VersionControlProvenance[0].Timestamp.Should().BeEquivalentTo(utcNow);
            run.VersionControlProvenance[0].Uri.Should().BeEquivalentTo(versionControlUri);
            run.OriginalUriBaseIds[originalUriBaseIdKey].Should().Be(originalUriBaseIdValue);
            run.DefaultFileEncoding.Should().Be(defaultFileEncoding);
            run.RichMessageMimeType.Should().Be(richMessageMimeType);
            run.RedactionToken.Should().Be(redactionToken);
        }
Exemple #7
0
 public bool ValueEquals(VersionControlDetails other) => ValueComparer.Equals(this, other);