How to Detect Security Threats from Text in Go

Cloudmersive
2 min readAug 11, 2021

We are living in a world where new and innovative technology solutions are created almost every day. However, as our technology continues to evolve, so too do the variety of threats that target them. To guard your web applications against some of the difficult-to-detect attacks, you can use the following API in Go to automatically scan an input string for XSS attacks, SQL injection attacks, XXE attacks, SSRF threats, and JID threats.

To call the security function, simply input the user-facing text string and your API key into the below example code:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/security/threat-detection/content/automatic/detect/string"
method := "POST"
payload := strings.NewReader(`"<string>"`)client := &http.Client {
}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Apikey", "YOUR-API-KEY-HERE")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}

The result will be returned promptly and will indicate if any of the implicated threats have been detected. If you need to obtain an API key, you can do so by registering for a free account on the Cloudmersive website; this provides 800 monthly calls across our library of APIs.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.