Skip to content
Snippets Groups Projects
Commit 6460ffd7 authored by Odin K. Henriksen's avatar Odin K. Henriksen
Browse files

Merge branch 'main' of git.gvk.idi.ntnu.no:Johannesb/dcsg2900-threattotal into main

parents 4cbc2104 27b33f37
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ import ( ...@@ -17,6 +17,7 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
// Retrieves data of uploaded file
func UploadFileRetrieve(c *gin.Context) { func UploadFileRetrieve(c *gin.Context) {
var fileData []byte var fileData []byte
...@@ -77,6 +78,7 @@ func UploadFileRetrieve(c *gin.Context) { ...@@ -77,6 +78,7 @@ func UploadFileRetrieve(c *gin.Context) {
c.Data(http.StatusOK, "application/json", fileData) 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) { func uploadFileRetrieveCall(id string) (data []byte, err error) {
var responseData utils.ResultFrontendResponse var responseData utils.ResultFrontendResponse
responseData, err = CallVirusTotal(id) responseData, err = CallVirusTotal(id)
...@@ -94,6 +96,7 @@ func uploadFileRetrieveCall(id string) (data []byte, err error) { ...@@ -94,6 +96,7 @@ func uploadFileRetrieveCall(id string) (data []byte, err error) {
return fileData, nil return fileData, nil
} }
// Uploads file to VirusTotal and returns an ID reference to the scan results in VirusTotal
func UploadFile(c *gin.Context) { func UploadFile(c *gin.Context) {
log.Println("Fileupload worked") log.Println("Fileupload worked")
logging.Loginfo("Fileupload worked") logging.Loginfo("Fileupload worked")
......
...@@ -118,6 +118,7 @@ func CallVirusTotal(id string) (response utils.ResultFrontendResponse, err error ...@@ -118,6 +118,7 @@ func CallVirusTotal(id string) (response utils.ResultFrontendResponse, err error
return response, nil 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 { func sortDanger(values []utils.FrontendResponse2, dangerSize int, safeSize int) []utils.FrontendResponse2 {
if dangerSize == 0 { if dangerSize == 0 {
return values return values
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment