From d2434faa15b52cdedd5aba8ee4b0799be79ff847 Mon Sep 17 00:00:00 2001 From: Johannes <johanmba@stud.ntnu.no> Date: Thu, 19 May 2022 19:19:45 +0200 Subject: [PATCH] more commenting, sufficient --- api/fileupload.go | 3 +++ api/virustotal.go | 1 + 2 files changed, 4 insertions(+) diff --git a/api/fileupload.go b/api/fileupload.go index 5400ff1..33e4b86 100644 --- a/api/fileupload.go +++ b/api/fileupload.go @@ -17,6 +17,7 @@ import ( "github.com/gin-gonic/gin" ) +// Retrieves data of uploaded file func UploadFileRetrieve(c *gin.Context) { var fileData []byte @@ -77,6 +78,7 @@ func UploadFileRetrieve(c *gin.Context) { c.Data(http.StatusOK, "application/json", fileData) } +// Performs request to virustotal, returning a full report of analyzed file func uploadFileRetrieveCall(id string) (data []byte, err error) { var responseData utils.ResultFrontendResponse responseData, err = CallVirusTotal(id) @@ -94,6 +96,7 @@ func uploadFileRetrieveCall(id string) (data []byte, err error) { return fileData, nil } +// Uploads file to VirusTotal and returns an ID reference to the scan results in VirusTotal func UploadFile(c *gin.Context) { log.Println("Fileupload worked") logging.Loginfo("Fileupload worked") diff --git a/api/virustotal.go b/api/virustotal.go index 46dab32..bfcc8af 100644 --- a/api/virustotal.go +++ b/api/virustotal.go @@ -118,6 +118,7 @@ func CallVirusTotal(id string) (response utils.ResultFrontendResponse, err error return response, nil } +// Sorts frontend display information from AV engines, based on malicious sites first, and harmless last func sortDanger(values []utils.FrontendResponse2, dangerSize int, safeSize int) []utils.FrontendResponse2 { if dangerSize == 0 { return values -- GitLab