Skip to content

khulnasoft/go-threatmatrix

Go-ThreatMatrix

Go Reference GitHub issues GitHub license

go-threatmatrix is a client library/SDK that allows developers to easily automate and integrate ThreatMatrix with their own set of tools!

Table of Contents

Getting Started

Pre requisites

  • Go 1.17+

Installation

Use go get to retrieve the SDK to add it to your GOPATH workspace, or project's Go module dependencies.

$ go get github.com/khulnasoft/go-threatmatrix

Usage

This library was built with ease of use in mind! Here are some quick examples to get you started. If you need more example you can go to the examples directory

To start using the go-threatmatrix library you first need to import it:

import "github.com/khulnasoft/go-threatmatrix/gothreatmatrix"

Construct a new ThreatMatrixClient, then use the various services to easily access different parts of Threatmatrix's REST API. Here's an example of getting all jobs:

clientOptions := gothreatmatrix.ThreatMatrixClientOptions{
	Url:         "your-cool-URL-goes-here",
	Token:       "your-super-secret-token-goes-here",
	// This is optional
	Certificate: "your-optional-certificate-goes-here",
}

threatmatrix := gothreatmatrix.NewThreatMatrixClient(
	&clientOptions,
	nil
)

ctx := context.Background()

// returns *[]Jobs or an ThreatMatrixError!
jobs, err := threatmatrix.JobService.List(ctx)

For easy configuration and set up we opted for options structs. Where we can customize the client API or service endpoint to our liking! For more information go here. Here's a quick example!

// ...Making the client and context!

tagOptions = gothreatmatrix.TagParams{
  Label: "NEW TAG",
  Color: "#ffb703",
}

createdTag, err := threatmatrix.TagService.Create(ctx, tagOptions)
if err != nil {
	fmt.Println(err)
} else {
	fmt.Println(createdTag)
}

Examples

The examples directory contains a couple for clear examples, of which one is partially listed here as well:

package main

import (
	"fmt"

	"github.com/khulnasoft/go-threatmatrix/gothreatmatrix"
)

func main(){
	threatmatrixOptions := gothreatmatrix.ThreatMatrixClientOptions{
		Url:         "your-cool-url-goes-here",
		Token:       "your-super-secret-token-goes-here",
		Certificate: "your-optional-certificate-goes-here",
	}	

	client := gothreatmatrix.NewThreatMatrixClient(
		&threatmatrixOptions,
		nil,
	)

	ctx := context.Background()

	// Get User details!
	user, err := client.UserService.Access(ctx)
	if err != nil {
		fmt.Println("err")
		fmt.Println(err)
	} else {
		fmt.Println("USER Details")
		fmt.Println(*user)
	}
}

For complete usage of go-threatmatrix, see the full package docs.

Contribute

If you want to follow the updates, discuss, contribute, or just chat then please join our slack channel we'd love to hear your feedback!

License

Licensed under the GNU AFFERO GENERAL PUBLIC LICENSE.

Links

FAQ

Generate API key

You need a valid API key to interact with the ThreatMatrix server.

v4.0 and above

You can get an API by doing the following:

  1. Log / Signin into threatmatrix
  2. At the upper right click on your profile from the drop down select API Access/ Sessions
  3. Then generate an API key or see it!

v4.0 below

Keys should be created from the admin interface of ThreatMatrix: you have to go in the Durin section (click on Auth tokens) and generate a key there.

About

No description, website, or topics provided.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages