malscan/rest.go

44 lines
896 B
Go
Raw Normal View History

2023-04-06 09:35:59 +00:00
package main
2023-04-07 11:57:58 +00:00
2023-04-07 12:22:47 +00:00
import (
"net/http"
"github.com/gin-gonic/gin"
)
2023-04-07 11:57:58 +00:00
type status_response struct {
2023-04-07 12:22:47 +00:00
Scanning_engine string `json:"scanning_engine"`
Signature_count int `json:"signature_count"`
Sanity_check bool `json:"sanity_check"`
2023-04-07 11:57:58 +00:00
}
type scan_response struct {
2023-04-07 12:22:47 +00:00
Malware_detected bool `json:"malware_detected"`
Malware_name string `json:"malware_name"`
Engine status_response `json:"engine"`
2023-04-07 11:57:58 +00:00
}
func scan_api(c *gin.Context) {
}
func status_api(c *gin.Context) {
2023-04-07 12:22:47 +00:00
scannerIsSane, sigCount := sanity_check()
responseData := status_response{
Sanity_check: scannerIsSane,
Signature_count: sigCount,
Scanning_engine: "clamav",
}
c.IndentedJSON(http.StatusOK, responseData)
2023-04-07 11:57:58 +00:00
}
func start_api() {
2023-04-07 12:22:47 +00:00
gin.SetMode(gin.ReleaseMode)
2023-04-07 11:57:58 +00:00
router := gin.Default()
router.PUT("/scan", scan_api)
router.GET("/status", status_api)
router.Run(":8080")
}