/
table_osquery_docker_container.go
214 lines (208 loc) · 6.57 KB
/
table_osquery_docker_container.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
package osquery
import (
"context"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin/transform"
)
//// TABLE DEFINITION
func tableOSQueryDockerContainer(_ context.Context) *plugin.Table {
return &plugin.Table{
Name: "osquery_docker_container",
Description: "List of machine Docker containers.",
Columns: []*plugin.Column{
{
Name: "hostname",
Type: proto.ColumnType_STRING,
Description: "The name of the host on which the process is running.",
Transform: transform.FromField("Hostname"),
},
{
Name: "id",
Type: proto.ColumnType_STRING,
Description: "The container ID.",
Transform: transform.FromField("ID"),
},
{
Name: "name",
Type: proto.ColumnType_STRING,
Description: "The container name.",
Transform: transform.FromField("Name"),
},
{
Name: "image",
Type: proto.ColumnType_STRING,
Description: "The container image.",
Transform: transform.FromField("Image"),
},
{
Name: "image_id",
Type: proto.ColumnType_STRING,
Description: "The container image ID.",
Transform: transform.FromField("ImageID"),
},
{
Name: "command",
Type: proto.ColumnType_STRING,
Description: "The container command.",
Transform: transform.FromField("Command"),
},
{
Name: "created_at_unix",
Type: proto.ColumnType_INT,
Description: "The container creation time (as seconds from Epoch).",
Transform: transform.FromField("Created"),
},
{
Name: "created_at_date",
Type: proto.ColumnType_STRING,
Description: "The container creation time (as a date).",
Transform: transform.FromField("Created").Transform(EpochToDate),
},
{
Name: "state",
Type: proto.ColumnType_STRING,
Description: "The container state.",
Transform: transform.FromField("State"),
},
{
Name: "status",
Type: proto.ColumnType_STRING,
Description: "The container status.",
Transform: transform.FromField("Status"),
},
{
Name: "pid",
Type: proto.ColumnType_INT,
Description: "The container PID.",
Transform: transform.FromField("PID"),
},
{
Name: "path",
Type: proto.ColumnType_STRING,
Description: "The container path.",
Transform: transform.FromField("Path"),
},
{
Name: "config_entrypoint",
Type: proto.ColumnType_STRING,
Description: "The container configuration entrypoint.",
Transform: transform.FromField("ConfigEntryPoint"),
},
{
Name: "started_at",
Type: proto.ColumnType_STRING,
Description: "The container start time.",
Transform: transform.FromField("StartedAt"),
},
{
Name: "finished_at",
Type: proto.ColumnType_STRING,
Description: "The container finish time.",
Transform: transform.FromField("FinishedAt"),
},
{
Name: "privileged",
Type: proto.ColumnType_INT,
Description: "The container privileged status.",
Transform: transform.FromField("Privileged"),
},
{
Name: "security_options",
Type: proto.ColumnType_STRING,
Description: "The container security options.",
Transform: transform.FromField("SecurityOptions"),
},
{
Name: "env_variables",
Type: proto.ColumnType_STRING,
Description: "The container environment variables.",
Transform: transform.FromField("EnvVariables"),
},
{
Name: "readonly_rootfs",
Type: proto.ColumnType_STRING,
Description: "The container read-only root filesystem.",
Transform: transform.FromField("ReadOnlyRootFS"),
},
{
Name: "cgroup_namespace",
Type: proto.ColumnType_STRING,
Description: "The CGroups namespace of the container.",
Transform: transform.FromField("CGroupNamespace"),
},
{
Name: "ipc_namespace",
Type: proto.ColumnType_STRING,
Description: "The IPC namespace of the container.",
Transform: transform.FromField("IPCNamespace"),
},
{
Name: "mnt_namespace",
Type: proto.ColumnType_STRING,
Description: "The Mount namespace of the container.",
Transform: transform.FromField("MNTNamespace"),
},
{
Name: "net_namespace",
Type: proto.ColumnType_STRING,
Description: "The Net namespace of the container.",
Transform: transform.FromField("NetNamespace"),
},
{
Name: "pid_namespace",
Type: proto.ColumnType_STRING,
Description: "The PID namespace of the container.",
Transform: transform.FromField("PIDNamespace"),
},
{
Name: "user_namespace",
Type: proto.ColumnType_STRING,
Description: "The User namespace of the container.",
Transform: transform.FromField("UserNamespace"),
},
{
Name: "uts_namespace",
Type: proto.ColumnType_STRING,
Description: "The UTS namespace of the container.",
Transform: transform.FromField("UTSNamespace"),
},
},
List: &plugin.ListConfig{
Hydrate: makeListOSQuery[*osQueryDockerContainer]("select * from docker_containers;"),
KeyColumns: plugin.KeyColumnSlice{
&plugin.KeyColumn{
Name: "hostname",
Require: plugin.Required,
},
},
},
}
}
type osQueryDockerContainer struct {
Result
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
ImageID string `json:"image_id"`
Command string `json:"command"`
Created string `json:"created"`
State string `json:"state"`
Status string `json:"status"`
PID string `json:"pid"`
Path string `json:"path"`
ConfigEntryPoint string `json:"config_entrypoint"`
StartedAt string `json:"started_at"`
FinishedAt string `json:"finished_at"`
Privileged string `json:"privileged"`
SecurityOptions string `json:"security_options"`
EnvVariables string `json:"env_variables"`
ReadOnlyRootFS string `json:"readonly_rootfs"`
CGroupNamespace string `json:"cgroup_namespace"`
IPCNamespace string `json:"ipc_namespace"`
MNTNamespace string `json:"mnt_namespace"`
NetNamespace string `json:"net_namespace"`
PIDNamespace string `json:"pid_namespace"`
UserNamespace string `json:"user_namespace"`
UTSNamespace string `json:"uts_namespace"`
}