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))); } } }
private static Vulnerability AdjustSeverity(Vulnerability vulnerability) { if (vulnerability.Severity == VulnerabilityLevel.None) { vulnerability.Severity = VulnerabilityLevel.Info; } return(vulnerability); }
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}"; }
public AlertTag(Vulnerability vulnerability) { Vulnerability = vulnerability; }