From dc765a19c5f4908015be21fc1c8cbb8f9f961622 Mon Sep 17 00:00:00 2001 From: Jan Lauber Date: Fri, 17 Dec 2021 17:44:55 +0100 Subject: [PATCH 1/2] remove checking for no vuln files found Signed-off-by: Jan Lauber --- controllers/reportsController.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/controllers/reportsController.go b/controllers/reportsController.go index f88a878..c90ca76 100644 --- a/controllers/reportsController.go +++ b/controllers/reportsController.go @@ -43,14 +43,6 @@ func CreateReport(c *fiber.Ctx) error { if existingReport.ID != 0 { // Report already exists in database, delete all existing vulnerable files db.Model(&existingReport).Association("VulnerableFiles").Clear() - - // Check if vulnerable files are empty - if len(report.VulnerableFiles) == 0 { - // No vulnerable files, delete report - db.Delete(&existingReport) - return c.Status(200).JSON(map[string]interface{}{"message": "Report deleted"}) - } - // Add new vulnerable files to existing report db.Model(&existingReport).Association("VulnerableFiles").Append(report.VulnerableFiles) return c.Status(200).JSON(existingReport) @@ -75,14 +67,6 @@ func UpdateReport(c *fiber.Ctx) error { if existingReport.ID != 0 { // Delete all existing vulnerable files db.Model(&existingReport).Association("VulnerableFiles").Clear() - - // Check if vulnerable files are empty - if len(report.VulnerableFiles) == 0 { - // No vulnerable files, delete report - db.Delete(&existingReport) - return c.Status(200).JSON(map[string]interface{}{"message": "Report deleted"}) - } - // Add new vulnerable files to existing report db.Model(&existingReport).Association("VulnerableFiles").Append(report.VulnerableFiles) // Update existing with new values From 654fa098ccb0e5039959ddcbd8b9bb51f55c6d4a Mon Sep 17 00:00:00 2001 From: Jan Lauber Date: Fri, 17 Dec 2021 17:46:57 +0100 Subject: [PATCH 2/2] update api docs Signed-off-by: Jan Lauber --- docs/reports/id/post.md | 2 +- docs/reports/post.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reports/id/post.md b/docs/reports/id/post.md index 12ad448..bd3d621 100644 --- a/docs/reports/id/post.md +++ b/docs/reports/id/post.md @@ -82,7 +82,7 @@ Update a specific report with the new values provided. You can update everything ### Or -**Condition** : If you send only the servername without the vulnerableFiles, the report will be deleted. +**Condition** : If you send only the servername without the vulnerableFiles, the linked vulnerable files will be deleted, but the report with the servername will be kept. **Code** : `200 OK` diff --git a/docs/reports/post.md b/docs/reports/post.md index 835ae5b..430c278 100644 --- a/docs/reports/post.md +++ b/docs/reports/post.md @@ -81,7 +81,7 @@ All the old values will be flushed. ### Or -**Condition** : If you send only the servername without the vulnerableFiles, the report will be deleted. +**Condition** : If you send only the servername without the vulnerableFiles, the linked vulnerable files will be deleted, but the report with the servername will be kept. **Code** : `200 OK`