Example #1
0
        IEnumerable <ITagSpan <AlertTag> > ITagger <AlertTag> .GetTags(NormalizedSnapshotSpanCollection spans)
        {
            if (spans.Count == 0 || PackageSecurityPackage.Vulnurabilities == null)
            {
                yield break;
            }

            SnapshotSpan span = spans.First();

            ITextSnapshotLine line = span.Snapshot.GetLineFromPosition(span.Start.Position);
            string            text = line.Extent.GetText();

            Match match = _regex.Match(text);

            if (match.Success)
            {
                string name    = match.Groups["name"].Value;
                string version = match.Groups["version"].Value;

                Vulnerability vul = PackageSecurityPackage.Vulnurabilities.CheckPackage(name, version);

                if (vul.Severity != VulnerabilityLevel.None)
                {
                    yield return(new TagSpan <AlertTag>(line.Extent, new AlertTag(vul)));
                }
            }
        }
Example #2
0
        private static Vulnerability AdjustSeverity(Vulnerability vulnerability)
        {
            if (vulnerability.Severity == VulnerabilityLevel.None)
            {
                vulnerability.Severity = VulnerabilityLevel.Info;
            }

            return(vulnerability);
        }
Example #3
0
        internal void Update(AlertTag alertTag)
        {
            if (alertTag == null)
            {
                return;
            }

            Vulnerability vul = alertTag.Vulnerability;
            Uri           url;

            if (vul.Info.Any() && Uri.TryCreate(vul.Info.FirstOrDefault(), UriKind.Absolute, out url))
            {
                Click += (s, e) =>
                {
                    e.Handled = true;
                    Process.Start(vul.Info.First());
                };
            }

            _image.Source = GetMoniker(vul.Severity).GetImage(_size);
            ToolTip       = $"This package contains security issues.\n\nRisk level: {vul.Severity}";
        }
Example #4
0
 public AlertTag(Vulnerability vulnerability)
 {
     Vulnerability = vulnerability;
 }