Categorygithub.com/linquize/envdb
modulepackage
0.4.1
Repository: https://github.com/linquize/envdb.git
Documentation: pkg.go.dev

# README

Build Status

Envdb - Environment Database

  • NOTE: envdb is still beta software.

Envdb turns your production, dev, cloud, etc environments into a database cluster you can search using osquery as the foundation.

Envdb allows you to register each computer, server or asset as a node in a cluster. Once a new node is connected it becomes available for search from the Envdb ui. Envdb was built using golang so the whole application, node client and server comes as one single binary. This makes it really easy to deploy and get working in seconds.

Video Intro: https://youtu.be/ydYr7Ykwzy8

How it works.

Envdb wraps the osquery process with a node agent (node as in cluster node) that can communicate back to a central location. When that node gets a new query, it's executed and then sent back to the tcp server for rendering. Once the request is processed it's then sent to any avaliable web clients using websockets.

Envdb has an embedded sqlite database for node storage and saved searches.

ui --websockets--> server --tcp--> node client.

Download

Pre-built versions (deb/tar.gz) of envdb are avaliable for linux 386/amd64. linux downloads

Building on macosx is easy tho, checkout the section below.

Building

Make sure you have Go installed. I used Go version 1.4.1.

deps

  • go get github.com/jteeuwen/go-bindata/...
  • go get github.com/elazarl/go-bindata-assetfs
  • go get github.com/tools/godep

make

  • git clone https://github.com/mephux/envdb.git
  • cd envdb
  • make

Usage

  • NOTICE: The default username and password for the UI.
usage: envdb [<flags>] <command> [<flags>] [<args> ...]

The Environment Database - Ask your environment questions

Flags:
  --help       Show help.
  --debug      Enable debug logging.
  --dev        Enable dev mode. (read assets from disk and
               enable debug output)
  -q, --quiet  Remove all output logging.
  --version    Show application version.

Commands:
  help [<command>]
    Show help for a command.

  server [<flags>]
    Start the tcp server for node connections.

  node --server=127.0.0.1 [<flags>] <node-name>
    Register a new node.

  users [<flags>]
    User Management (Default lists all users).

Server

$ envdb help server

  usage: envdb [<flags>] server [<flags>] [<command>]

  Start the tcp server for node connections.

  Flags:
    -p, --port=3636  Port for the server to listen on.
    -P, --http-port=8080  
                     Port for the web server to listen on.

  Args:
    [<command>]  Daemon command. (start,status,stop)
Running the server without a `command` (start, stop or status) will run the server in the foreground.

* Note: By default this will start the tcp server on port 3636 and the web server on port 8080.

Node Client

$ envdb help node

  usage: envdb [<flags>] node --server=127.0.0.1 [<flags>] <node-name>

  Register a new node.

  Flags:
    -s, --server=127.0.0.1  
                     Address for server to connect to.
    -p, --port=PORT  Port to use for connection.

  Args:
    <node-name>  A name used to uniquely identify this node.
`sudo envdb node --server <ip to server> SomeBoxName`
  • That's it - it's really that simple.

User Management

  • list users envdb users

  • add a new user envdb users --add

  • remove a new user envdb users --remove <email>

More UI

Self-Promotion

Like envdb? Follow the repository on GitHub and if you would like to stalk me, follow mephux on Twitter and GitHub.

TODO

  • add in memeory pagination for results.
  • Node/Server auth, verification and validation.
  • Code cleanup (will continue forever).

# Functions

AllNodes Return all nodes in the database.
Find all saved queries in the database.
CreateUser creates record of a new user.
DBInit will initialize the database and add default values.
Initialize the database settings.
Find all users in the database.
Find a saved query by its id.
Find a user in the database by email address.
GetNodeByNodeId node by node id which is also the connection id.
Generate a salt for the user.
HomeDir returns path of '~'(in Linux) on Windows, it returns error when the variable does not exist.
IsEmail checks a string to validate its a proper email address.
Check that a given email address is unique in the database.
IsExist checks whether a file or directory exists.
Load all of the default saved queries.
Generate a new key pair to be used for the http and tcp servers.
NewLogger will initialize a new Logger struct.
NewNodeConfig new node configuration.
Initialize a new Response.
Insert a new saved query to the database.
Create a new server.
Initialize a new ServerConfig This will also create a default key pair and a empty Daemon struct in case the process is to be ran in the background.
No description provided by the author
NodeUpdateOnlineStatus will update a nodes connection state on server start to clean up nodes that didn't properly disconnect if the server is killed without running cleanup.
NodeUpdateOrCreate Will create a new node if it doesn't exist.
OsQueryInfo ather information about osqueryi from the node.
http://code.google.com/p/go/source/browse/pbkdf2/pbkdf2.go?repo=crypto.
Convert the bytes returned to json and do some basic counting to make sure we never send more than the DefaultRowRow to the UI.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SetEngine will setup and connect to the database.
No description provided by the author
VersionCheck.
No description provided by the author

# Constants

DebugLevel 5.
No description provided by the author
DefaultServerPort the default tcp server port.
DefaultWebServerPort the default web server port.
Email regex.
ErrorLevel 2.
FatalLevel 1.
InfoLevel 4.
MinOsQueryVersion Supported osqueryi version.
Name application name.
PanicLevel 0.
Version application version number.
WarnLevel 3.

# Variables

No description provided by the author
Connection is a channel to control the nodes connection state.
DebugPrefix allows you to change its styling.
DefaultCacheFile stores the node connection id.
Default log path.
DefaultNodePath node path.
Default private key path used for tcp/http servers.
Default public key path used for tcp/http servers.
Default row limit.
Default server path.
Default store path i.e database file.
DevMode Development mode switch.
ErrorPrefix allows you to change its styling.
FatalPrefix allows you to change its styling.
InfoPrefix allows you to change its styling.
KillClient tells the node if it should disconnect or not.
Log Global logger.
PanicPrefix allows you to change its styling.
RetryCount holds the current number of connection retry attempts.
TestMode.
TimeFormat global time format string.
WarnPrefix allows you to change its styling.

# Structs

Daemon wrapper for the daemon.Context struct.
Logger holds logging configurations.
Message struct is used to pass data during the node checkin process.
Node struct holds the socket, configurations and other metadata.
NodeCache holds the node connection id.
NodeConfig holds all node configuration values.
Holds node metadata.
NodeDb Database Table for node.
OsQueryInfo holds information about osquery.
Query Holds the raw sql and format options to be passed to osqueryi.
Query database table.
QueryResults holds all results returned by osqueryi.
Response wraps QueryResults.
Server holds the tcp server socket, connected nodes and configurations.
ServerConfig holds all server configurations.
Settings database table.
No description provided by the author
User database table.

# Interfaces

No description provided by the author

# Type aliases

No description provided by the author