Skip to content

Commit

Permalink
endpoint extractAndAnalyze now filled description and cvssv31
Browse files Browse the repository at this point in the history
  • Loading branch information
Kretchen001 committed May 26, 2024
1 parent 2649425 commit 4437e07
Showing 1 changed file with 5 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<IActionResult> ExtractAndAnalyzeTreeAsync([FromQuery] ProjectT
ExecuteCommand("npm", "install", projectGuid.ToString());
ExecuteCommand("rm", "tree.json", projectGuid.ToString());
ExecuteCommand("npm", "list --all --json >> tree.json", projectGuid.ToString());
List<NodePackage> depTree = ExtractTree(projectGuid.ToString() + "/tree.json");
List<NodePackage> depTree = ExtractTree(AppDomain.CurrentDomain.BaseDirectory + projectGuid.ToString() + "/tree.json");
List<NodePackageResult> resTree = await AnalyzeTreeAsync(depTree) ?? [];

Check warning on line 83 in code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest

Nullability of reference types in value of type 'List<NodePackageResult?>' doesn't match target type 'List<NodePackageResult>'.

Check warning on line 83 in code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-ubuntu-latest

Nullability of reference types in value of type 'List<NodePackageResult?>' doesn't match target type 'List<NodePackageResult>'.

Check warning on line 83 in code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows-latest

Nullability of reference types in value of type 'List<NodePackageResult?>' doesn't match target type 'List<NodePackageResult>'.

Check warning on line 83 in code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-windows-latest

Nullability of reference types in value of type 'List<NodePackageResult?>' doesn't match target type 'List<NodePackageResult>'.

Check warning on line 83 in code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-macOS-latest

Nullability of reference types in value of type 'List<NodePackageResult?>' doesn't match target type 'List<NodePackageResult>'.

Check warning on line 83 in code/AmIVulnerable/AmIVulnerable/Controllers/DependeciesController.cs

View workflow job for this annotation

GitHub Actions / build-and-test-macOS-latest

Nullability of reference types in value of type 'List<NodePackageResult?>' doesn't match target type 'List<NodePackageResult>'.
if (resTree.Count != 0) {
JsonLdObject resultAsJsonLd = new JsonLdObject() {
Expand All @@ -106,9 +106,9 @@ public async Task<IActionResult> ExtractAndAnalyzeTreeAsync([FromQuery] ProjectT
/// <param name="command">Command used for programm</param>
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}");
Expand Down Expand Up @@ -216,29 +216,6 @@ private NodePackage ExtractDependencyInfo(JsonProperty dependency) {
}
}
return resulstList;
#region oldcode
//SearchDbController searchDbController = new SearchDbController();
//List<string> designation = [];
//foreach (Tuple<string, string> x in nodePackages) {
// designation.Add(x.Item1);
//}

//List<CveResult> results = await searchDbController.SearchPackagesAsList(designation);
////List<CveResult> results = searchDbController.SearchPackagesAsListMono(designation);

//// find the critical points
//if (results.Count == 0) {
// return null;
//}
//List<NodePackageResult?> resulstListOld = [];
//foreach (NodePackage x in depTree) {
// NodePackageResult? temp = checkVulnerabilities(x, results);
// if (temp is not null) {
// resulstList.Add(temp);
// }
//}
//return resulstList;
#endregion
}

/// <summary>
Expand Down Expand Up @@ -275,6 +252,8 @@ private List<NodePackage> 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)) {
Expand Down

0 comments on commit 4437e07

Please sign in to comment.