Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

58 fixchange extractandanalyse endpoint #60

Merged
merged 2 commits into from
May 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
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() {
Context = "https://localhost:7203/views/nodePackageResult",
Expand All @@ -106,9 +106,9 @@
/// <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 @@ -165,7 +165,7 @@
/// </summary>
/// <param name="depTree">List of all top level node packages.</param>
/// <returns>List of NodePackageResult.</returns>
private async Task<List<NodePackageResult?>> AnalyzeTreeAsync(List<NodePackage> depTree) {

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

View workflow job for this annotation

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

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

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

View workflow job for this annotation

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

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

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

View workflow job for this annotation

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

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

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

View workflow job for this annotation

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

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

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

View workflow job for this annotation

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

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

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

View workflow job for this annotation

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

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
List<Tuple<string, string>> nodePackages = [];
// preperation list
foreach (NodePackage x in depTree) {
Expand Down Expand Up @@ -206,7 +206,7 @@

// find the critical points
if (cveResults.Count == 0) {
return null;

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

View workflow job for this annotation

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

Possible null reference return.

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

View workflow job for this annotation

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

Possible null reference return.

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

View workflow job for this annotation

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

Possible null reference return.

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

View workflow job for this annotation

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

Possible null reference return.

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

View workflow job for this annotation

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

Possible null reference return.

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

View workflow job for this annotation

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

Possible null reference return.
}
List<NodePackageResult?> resulstList = [];
foreach (NodePackage x in depTree) {
Expand All @@ -216,29 +216,6 @@
}
}
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 @@
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
2 changes: 2 additions & 0 deletions code/AmIVulnerable/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading