malscan/malscan.go
Yvan Janssens 1217a12f80
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Implement sanity check so we stop startup if we can't detect any malware samples.
2023-04-07 13:45:57 +02:00

44 lines
970 B
Go

package main
import (
"fmt"
"log"
"time"
)
func banner() {
fmt.Println(" _ \n _ __ ___ __ _| |___ ___ __ _ _ __ \n| '_ ` _ \\ / _` | / __|/ __/ _` | '_ \\ \n| | | | | | (_| | \\__ \\ (_| (_| | | | |\n|_| |_| |_|\\__,_|_|___/\\___\\__,_|_| |_|\n ")
fmt.Println("malscan v0.1 microservice")
fmt.Println("")
}
func sanity_check() bool {
vName, error := scan_data([]byte("X5O!P%@AP[4\\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*"))
if error != nil && vName == "" {
panic(error)
}
if vName == "Win.Test.EICAR_HDB-1" {
return true
}
return false
}
func main() {
banner()
// start freshclam goroutine
go freshclam_update()
log.Println("Carrying out sanity checks...")
if !sanity_check() {
log.Println("Sanity check failed!")
return
}
log.Println("Sanity check passed! Continuing startup...")
// loop forever.
for {
time.Sleep(1 * time.Second)
}
}