To use GoCenter:
export GOPROXY=https://gocenter.io
bitbucket.org/cyfir/cyfir-sdk-go
January 1st 0001
Last Modified
0
Stars
NOASSERTION
License
7
Downloads
ReadMe
Mod File
GoDocs
New
Security
Dependencies (0)
Used By (0)
Metrics
Versions
CyFIR SDK for Go
cyfir-sdk-go is the offical libary for using Go with the CyFIR Web API.
Getting the SDK
Usng the following to get the SDK.
$ go get -u bitbucket.org/cyfir/cyfir-sdk-go
Then include the SDK by adding the following to your import.
"bitbucket.org/cyfir/cyfir-sdk-go"
Note: The package is called cyfir.
Authentication using a User Name and Password
Use the following to login to the CyFIR API using a user name and password that you would normally use to authenticate with in CyFIR Investigator.
Note: You will also need to know the consumer key and consumer secret for OAuth.
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1)
connection, err := cyfir.UserLogin(ctx, cyfir.UserOptions {
URL: "https://[ADDRESS]/",
Username: "[CyFIR User]",
Password: "[CyFIR Password]",
});
cancel()
if err != nil {
panic(err)
}
Authentication using an API Key
Use the following to login to the CyFIR API using an API Key generated from CyFIR Investigator.
connection, err := cyfir.KeyLogin(cyfir.KeyOptions {
URL: "https://[ADDRESS]/",
Key: "[API KEY]",
});
if err != nil {
panic(err)
}
An Example
package main
import (
"fmt"
"context"
"bitbucket.org/cyfir/cyfir-sdk-go"
)
func main() {
connection, err := cyfir.KeyLogin(cyfir.KeyOptions {
URL: "https://[ADDRESS]/",
Key: "[API KEY]",
});
if err != nil {
panic(err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second*1)
agents, _, _, err := connection.GetAgents(ctx, -1, "", 10000)
cancel()
if err != nil {
panic(err)
}
for _, agent := range agents {
if agent.IsOnline {
fmt.Println(agent.MachineName + "is Online")
}
}
return
}