palantir / tenablesc-client

A Golang-based API client for Tenable.SC
Other
9 stars 8 forks source link

Base URL not picked and resulting into golang http panic #80

Open fruganyumisa opened 11 months ago

fruganyumisa commented 11 months ago

What happened?

I am trying to use the client for a getting all scans as I configured the client and added necessary envs when I try to trigger GetAllScans

What did you want to happen?

Return all scans

My implimentation is as below

func ScansHandler(w http.ResponseWriter, r *http.Request) {

client := tenablesc.NewClient(
    os.Getenv("TENABLE_URL"),
).SetAPIKey(
    os.Getenv("TENABLE_ACCESS_KEY"),
    os.Getenv("TENABLE_SECRET_KEY"),
)

_, err := client.GetCurrentUser()
if err != nil {
    exception := fmt.Errorf("Unable to authenticate to tenable some error occured : %w", err)
    fmt.Println(exception)
    os.Exit(1)

}

scans, err := client.GetAllScans()
if err != nil {
    log.Fatal(err)
}

for _, scan := range scans {

    log.Print(scan.Name)
}

}

this is what I get

go run main.go Server Listening on port :8080 Unable to authenticate to tenable some error occured : failed to get current user: failed to make request: Get "/currentUser?fields=authType%2Cdescription%2Cgroup%2Cid%2Cname%2CorgName%2Corganization%2Crole%2Cstatus%2Cusername": unsupported protocol scheme "" exit status 1