I work on a cloud telephony product ReceptionMonk . One feature lets a business owner upload their own audio for the phone menu: "Press 1 for sales, press 2 for support." Those files end up on the telephony server and play to every caller.
That means a stranger can send a file that lands on a server that talks to the phone network. So every upload goes through a virus scanner before it is stored. This post is about how that scanner gate is built in Go, and one decision we got wrong the first time.
The problem with "just call the scanner"
The first version of most upload scanning looks like this:
status , _ := scanner . Scan ( file ) if status == "infected" { return errors . New ( "virus found" ) } save ( file )
Enter fullscreen mode
Exit fullscreen mode
Read it again and ask: what happens when the scanner is down?
status is empty, it is not "infected" , and the file gets saved. The scanner fails, and the upload succeeds.…