Пример #1
0
        public static void AddPackage(PackageMagic package)
        {
            if (LoadedJsonFile)
            {
                return;
            }

            IPackageMagic checkIfExist = packages.Find(z => z.Name == package.Name && z.Version == package.Version);

            if (checkIfExist == null)
            {
                packages.Add(package);
            }
            else
            {
                //Console.WriteLine("Skipped - " + package.Name + " " + package.Version);
            }
        }
        public static async Task <List <OssIndexResponse> > CheckVulnerabilityOnPackage(PackageMagic package, string packageManager)
        {
            List <OssIndexResponse> objResponse = null;
            var result = await Client.GetAsync($"v2.0/package/{packageManager}/{package.Name}/{package.Version}");

            if (result.IsSuccessStatusCode)
            {
                string content = await result.Content.ReadAsStringAsync();

                objResponse = JsonConvert.DeserializeObject <List <OssIndexResponse> >(content);
                Console.WriteLine($"Checked vulnerabilitys from OSS Index -  {packageManager}/{package.Name}/{package.Version}");
                foreach (var item in objResponse)
                {
                    package.OssIndexResponse = item;
                    if (item.vulnerabilities != null)
                    {
                        Console.WriteLine($"*************************************************************");

                        Console.WriteLine($"Vulnerability found in package - {package.Name}:{package.Version}");
                        foreach (var vul in item.vulnerabilities)
                        {
                            Console.WriteLine($"Vulnerability found in package - {vul.title}");
                            Console.WriteLine($"Vulnerability found in package - {vul.description}");
                            Console.WriteLine($"Vulnerability found in package - {vul.resource}");
                        }
                        Console.WriteLine($"*************************************************************");
                    }
                }
            }
            else
            {
                Console.WriteLine($"OSS Index error statuscode {result.StatusCode}");
            }

            return(objResponse);
        }
Пример #3
0
 public static void RemovePackage(PackageMagic package)
 {
     packages.Remove(package);
 }