ossec

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 7 Imported by: 0

README

go-ossec

Package for interacting with OSSEC over SSH

Example

Error handling omitted

import (
  "os"
  "fmt"

  "github.com/bhoriuchi/go-ossec"
)

func main() {
	client, _ := New(&Options{
		Username:      os.Getenv("OSSEC_USER"),
		Password:      os.Getenv("OSSEC_PASSWORD"),
		Host:          os.Getenv("OSSEC_SERVER"),
		IgnoreHostKey: true,
		Debug:         false,
	})

  defer client.Close()

  // list all agents
  agentList, _ := client.List()

  // find a specific agent by name
  agent, _ := client.Find("name", "foo.bar.com")

  // import an agent
  agent, _ = client.Import("foo.bar.com", "")

  // get the agent's key
  key, _ := client.Key(agent.ID)

  // remove an agent
  client.Remove(agent.ID)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultBinPath = "/var/ossec/bin"
	DefaultTempDir = "/tmp"
	DefaultSSHPort = 22
)

Functions

This section is empty.

Types

type Agent

type Agent struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	IP   string `json:"ip"`
}

Agent an agent entry

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client an OSSEC client

func New

func New(opts *Options) (*Client, error)

New returns a new ossec client

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the session

func (*Client) Find

func (c *Client) Find(searchKey, searchValue string) (*Agent, error)

Finds an agent using a regex search on the name

func (*Client) Import

func (c *Client) Import(host, ip string) (*Agent, error)

Import imports a host and returns its id and key

func (*Client) Key

func (c *Client) Key(id string) (string, error)

gets the key

func (*Client) List

func (c *Client) List() ([]*Agent, error)

List lists all ossec agents

func (*Client) Remove

func (c *Client) Remove(id string) error

Remove removes a host from ossec

type Options

type Options struct {
	BinDir        string
	TempDir       string
	Username      string
	Password      string
	Host          string
	HostKey       string
	Port          int
	NoSudo        bool
	IgnoreHostKey bool
	Debug         bool
}

Options client options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL