• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

samsmithnz / RepoGovernance / 6871646540

15 Nov 2023 01:19AM CUT coverage: 69.053% (+0.6%) from 68.496%
6871646540

Pull #660

github

web-flow
Merge f76d366d2 into 52b914122
Pull Request #660: Update to .NET 8

217 of 360 branches covered (0.0%)

Branch coverage included in aggregate %.

651 of 897 relevant lines covered (72.58%)

23.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

50.35
/src/RepoGovernance.Core/Helpers/DotnetPackages.cs
1
using Newtonsoft.Json;
2
using RepoGovernance.Core.Models.NuGetPackages;
3
using System.Diagnostics;
4
using Process = System.Diagnostics.Process;
5

6
namespace RepoGovernance.Core.Helpers
7
{
8
    public class DotNetPackages
9
    {
10
        public List<NugetPackage> GetNugetPackagesDeprecated(string json)
11
        {
1✔
12
            List<NugetPackage> results = new();
1✔
13

14
            //Process the output
15
            Root? root = JsonConvert.DeserializeObject<Root>(json);
1✔
16
            if (root != null && root.Projects != null && root.Projects.Count > 0)
1!
17
            {
1✔
18
                foreach (Project project in root.Projects)
7✔
19
                {
2✔
20
                    if (project.frameworks != null)
2!
21
                    {
×
22
                        foreach (Framework framework in project.frameworks)
×
23
                        {
×
24
                            foreach (Package package in framework.topLevelPackages)
×
25
                            {
×
26
                                results.Add(new NugetPackage()
×
27
                                {
×
28
                                    Path = project.path,
×
29
                                    Framework = framework.framework,
×
30
                                    PackageId = package.id,
×
31
                                    PackageVersion = package.requestedVersion,
×
32
                                    Type = "Deprecated"
×
33
                                });
×
34
                            }
×
35
                        }
×
36
                    }
×
37
                }
2✔
38
            }
1✔
39

40
            return results;
1✔
41
        }
1✔
42

43
        public List<NugetPackage> GetNugetPackagesOutdated(string json)
44
        {
1✔
45
            List<NugetPackage> results = new();
1✔
46
            
47
            //Process the output
48
            Root? root = JsonConvert.DeserializeObject<Root>(json);
1✔
49
            if (root != null && root.Projects != null && root.Projects.Count > 0)
1!
50
            {
1✔
51
                foreach (Project project in root.Projects)
7✔
52
                {
2✔
53
                    if (project.frameworks != null)
2!
54
                    {
×
55
                        foreach (Framework framework in project.frameworks)
×
56
                        {
×
57
                            foreach (Package package in framework.topLevelPackages)
×
58
                            {
×
59
                                results.Add(new NugetPackage()
×
60
                                {
×
61
                                    Path = project.path,
×
62
                                    Framework = framework.framework,
×
63
                                    PackageId = package.id,
×
64
                                    PackageVersion = package.latestVersion,
×
65
                                    Type = "Outdated"
×
66
                                });
×
67
                            }
×
68
                        }
×
69
                    }
×
70
                }
2✔
71
            }
1✔
72

73
            return results;
1✔
74
        }
1✔
75

76
        public List<NugetPackage> GetNugetPackagesVulnerable(string json)
77
        {
1✔
78
            List<NugetPackage> results = new();
1✔
79

80
            //Process the output
81
            Root? root = JsonConvert.DeserializeObject<Root>(json);
1✔
82
            if (root != null && root.Projects != null && root.Projects.Count > 0)
1!
83
            {
1✔
84
                foreach (Project project in root.Projects)
7✔
85
                {
2✔
86
                    if (project.frameworks != null)
2!
87
                    {
×
88
                        foreach (Framework framework in project.frameworks)
×
89
                        {
×
90
                            foreach (Package package in framework.topLevelPackages)
×
91
                            {
×
92
                                results.Add(new NugetPackage()
×
93
                                {
×
94
                                    Path = project.path,
×
95
                                    Framework = framework.framework,
×
96
                                    PackageId = package.id,
×
97
                                    PackageVersion = package.requestedVersion,
×
98
                                    Severity = package.GetFirstVulnerability(),
×
99
                                    Type = "Vulnerable"
×
100
                                });
×
101
                            }
×
102
                        }
×
103
                    }
×
104
                }
2✔
105
            }
1✔
106

107
            return results;
1✔
108
        }
1✔
109

110
        public string GetProcessOutput(string path, string arguments)
111
        {
3✔
112
            Process process = new();
3✔
113
            ProcessStartInfo startInfo = new()
3✔
114
            {
3✔
115
                FileName = "dotnet.exe",
3✔
116
                Arguments = arguments,
3✔
117
                WorkingDirectory = path,
3✔
118
                UseShellExecute = false,
3✔
119
                RedirectStandardOutput = true,
3✔
120
            };
3✔
121
            process.StartInfo = startInfo;
3✔
122
            process.Start();
3✔
123
            return process.StandardOutput.ReadToEnd();
3✔
124
        }
3✔
125
    }
126
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc