Skip to content

Commit

Permalink
Merge pull request #14 from bluestoneag/novulns
Browse files Browse the repository at this point in the history
remove checking for no vuln files found
  • Loading branch information
janlauber authored Dec 17, 2021
2 parents a192596 + 654fa09 commit aeb7e9b
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
16 changes: 0 additions & 16 deletions controllers/reportsController.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion docs/reports/id/post.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
2 changes: 1 addition & 1 deletion docs/reports/post.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down

0 comments on commit aeb7e9b

Please sign in to comment.