diff --git a/code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs b/code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs index e68caf7..bc1de8a 100644 --- a/code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs +++ b/code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs @@ -79,7 +79,7 @@ public async Task ExtractAndAnalyzeTreeAsync([FromQuery] ProjectT ExecuteCommand("npm", "install", projectGuid.ToString()); ExecuteCommand("rm", "tree.json", projectGuid.ToString()); ExecuteCommand("npm", "list --all --json >> tree.json", projectGuid.ToString()); - List depTree = ExtractTree(projectGuid.ToString() + "/tree.json"); + List depTree = ExtractTree(AppDomain.CurrentDomain.BaseDirectory + projectGuid.ToString() + "/tree.json"); List resTree = await AnalyzeTreeAsync(depTree) ?? []; if (resTree.Count != 0) { JsonLdObject resultAsJsonLd = new JsonLdObject() { @@ -106,9 +106,9 @@ public async Task ExtractAndAnalyzeTreeAsync([FromQuery] ProjectT /// Command used for programm private void ExecuteCommand(string prog, string command, string dir) { ProcessStartInfo process = new ProcessStartInfo { - FileName = "bash", + FileName = "cmd", RedirectStandardInput = true, - WorkingDirectory = dir, + WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory + dir, }; Process runProcess = Process.Start(process)!; runProcess.StandardInput.WriteLine($"{prog} {command}"); @@ -216,29 +216,6 @@ private NodePackage ExtractDependencyInfo(JsonProperty dependency) { } } return resulstList; - #region oldcode - //SearchDbController searchDbController = new SearchDbController(); - //List designation = []; - //foreach (Tuple x in nodePackages) { - // designation.Add(x.Item1); - //} - - //List results = await searchDbController.SearchPackagesAsList(designation); - ////List results = searchDbController.SearchPackagesAsListMono(designation); - - //// find the critical points - //if (results.Count == 0) { - // return null; - //} - //List resulstListOld = []; - //foreach (NodePackage x in depTree) { - // NodePackageResult? temp = checkVulnerabilities(x, results); - // if (temp is not null) { - // resulstList.Add(temp); - // } - //} - //return resulstList; - #endregion } /// @@ -275,6 +252,8 @@ private List AnalyzeSubtree(NodePackage nodePackage) { foreach (CveResult x in cveData) { // check if (x.Designation.Equals(package.Name)) { r.isCveTracked = true; + r.CvssV31 = x.CvssV31; + r.Description = x.Description; } } if (r.isCveTracked == false && !DepCheck(r)) { diff --git a/code/AmIVulnerable/docker-compose.yml b/code/AmIVulnerable/docker-compose.yml index e4f9e26..ad47f03 100644 --- a/code/AmIVulnerable/docker-compose.yml +++ b/code/AmIVulnerable/docker-compose.yml @@ -21,6 +21,8 @@ services: ports: - 3306:3306 command: --default-authentication-plugin=mysql_native_password + cap_add: + - SYS_NICE # CAP_SYS_NICE amivulnerable: container_name: ApiAmIVulnerable