How to Detect SQLI Attacks in Go

Cloudmersive
1 min readMar 2, 2022

--

Taking the most common security threats seriously can take your application to a new level. Easily detect SQLI injection attacks in any given text with the SQLI iteration of our Security API. Connect with ready-to-run code from our API Console (Cloudmersive API Console) below.

To connect, copy the below into your environment:

package mainimport (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {url := "https://api.cloudmersive.com/security/threat-detection/content/sql-injection/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))
}

Supply your Cloudmersive API key where indicated and include your input string as the payload. If you don’t currently have an API key, create a free account on the Cloudmersive website (with zero financial commitments) to receive one. After that, the API response will indicate if the scan was successful, and if there was an attack (‘true’) or if there was not an attack (‘false’) within the provided text.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet