2016-08-18 21:16:44 +00:00
|
|
|
package kolide
|
|
|
|
|
|
2017-01-10 20:54:35 +00:00
|
|
|
import "golang.org/x/net/context"
|
2016-08-18 21:16:44 +00:00
|
|
|
|
2016-09-04 05:13:42 +00:00
|
|
|
type OsqueryService interface {
|
2017-01-10 04:40:21 +00:00
|
|
|
EnrollAgent(ctx context.Context, enrollSecret, hostIdentifier string) (nodeKey string, err error)
|
|
|
|
|
AuthenticateHost(ctx context.Context, nodeKey string) (host *Host, err error)
|
|
|
|
|
GetClientConfig(ctx context.Context) (config *OsqueryConfig, err error)
|
|
|
|
|
GetDistributedQueries(ctx context.Context) (queries map[string]string, err error)
|
Push distributed query errors over results websocket (#878)
As of recently, osquery will report when a distributed query fails. We now
expose errors over the results websocket. When a query errored on the host, the
`error` key in the result will be non-null. Note that osquery currently doesn't
provide any details so the error string will always be "failed". I anticipate
that we will fix this and the string is included for future-proofing.
Successful result:
```
{
"type": "result",
"data": {
"distributed_query_execution_id": 15,
"host": {
... omitted ...
},
"rows": [
{
"hour": "1"
}
],
"error": null
}
}
```
Failed result:
```
{
"type": "result",
"data": {
"distributed_query_execution_id": 14,
"host": {
... omitted ...
},
"rows": [
],
"error": "failed"
}
}
```
2017-01-11 03:34:32 +00:00
|
|
|
SubmitDistributedQueryResults(ctx context.Context, results OsqueryDistributedQueryResults, statuses map[string]string) (err error)
|
2017-01-10 04:40:21 +00:00
|
|
|
SubmitStatusLogs(ctx context.Context, logs []OsqueryStatusLog) (err error)
|
|
|
|
|
SubmitResultLogs(ctx context.Context, logs []OsqueryResultLog) (err error)
|
2016-08-19 18:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2016-09-06 21:28:07 +00:00
|
|
|
type OsqueryDistributedQueryResults map[string][]map[string]string
|
2016-08-24 02:30:55 +00:00
|
|
|
|
2016-09-19 23:11:39 +00:00
|
|
|
type QueryContent struct {
|
2016-12-13 22:22:05 +00:00
|
|
|
Query string `json:"query"`
|
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
|
Interval uint `json:"interval"`
|
|
|
|
|
Platform *string `json:"platform,omitempty"`
|
|
|
|
|
Version *string `json:"version,omitempty"`
|
|
|
|
|
Snapshot *bool `json:"snapshot,omitempty"`
|
|
|
|
|
Removed *bool `json:"removed,omitempty"`
|
|
|
|
|
Shard *uint `json:"shard,omitempty"`
|
2016-09-19 23:11:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Queries map[string]QueryContent
|
|
|
|
|
|
|
|
|
|
type PackContent struct {
|
|
|
|
|
Platform string `json:"platform,omitempty"`
|
|
|
|
|
Version string `json:"version,omitempty"`
|
|
|
|
|
Shard uint `json:"shard,omitempty"`
|
|
|
|
|
Discovery []string `json:"discovery,omitempty"`
|
|
|
|
|
Queries Queries `json:"queries"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Packs map[string]PackContent
|
|
|
|
|
|
|
|
|
|
type Decorators struct {
|
|
|
|
|
Load []string `json:"load,omitempty"`
|
|
|
|
|
Always []string `json:"always,omitempty"`
|
|
|
|
|
Interval map[string][]string `json:"interval,omitempty"`
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-04 05:13:42 +00:00
|
|
|
type OsqueryConfig struct {
|
2016-12-31 17:56:54 +00:00
|
|
|
Options map[string]interface{} `json:"options"`
|
|
|
|
|
Decorators Decorators `json:"decorators,omitempty"`
|
|
|
|
|
Packs Packs `json:"packs,omitempty"`
|
2016-08-18 21:16:44 +00:00
|
|
|
}
|
2016-08-19 18:24:59 +00:00
|
|
|
|
2016-09-06 21:28:07 +00:00
|
|
|
type OsqueryResultLog struct {
|
2017-01-10 20:54:35 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
|
HostIdentifier string `json:"hostIdentifier"`
|
|
|
|
|
UnixTime string `json:"unixTime"`
|
|
|
|
|
CalendarTime string `json:"calendarTime"`
|
|
|
|
|
// Columns stores the columns of differential queries
|
|
|
|
|
Columns map[string]string `json:"columns,omitempty"`
|
|
|
|
|
// Snapshot stores the rows and columns of snapshot queries
|
|
|
|
|
Snapshot []map[string]string `json:"snapshot,omitempty"`
|
|
|
|
|
Action string `json:"action"`
|
|
|
|
|
Decorations map[string]string `json:"decorations"`
|
2016-09-06 21:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type OsqueryStatusLog struct {
|
|
|
|
|
Severity string `json:"severity"`
|
|
|
|
|
Filename string `json:"filename"`
|
|
|
|
|
Line string `json:"line"`
|
|
|
|
|
Message string `json:"message"`
|
|
|
|
|
Version string `json:"version"`
|
|
|
|
|
Decorations map[string]string `json:"decorations"`
|
|
|
|
|
}
|