Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support add the version in InternalExtensionInfo #96

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -46,7 +46,7 @@ func main() {
log.Fatalf(`Usage: %s --socket SOCKET_PATH`, os.Args[0])
}

server, err := osquery.NewExtensionManagerServer("foobar", *socket)
server, err := osquery.NewExtensionManagerServer("foobar", "0.0.0", *socket)
if err != nil {
log.Fatalf("Error creating extension: %s\n", err)
}
Expand Down
1 change: 1 addition & 0 deletions examples/config/main.go
Expand Up @@ -32,6 +32,7 @@ func main() {

server, err := osquery.NewExtensionManagerServer(
"example_extension",
"0.0.0",
*socket,
serverTimeout,
serverPingInterval,
Expand Down
2 changes: 1 addition & 1 deletion examples/distributed/main.go
Expand Up @@ -16,7 +16,7 @@ func main() {
flag.Int("interval", 0, "")
flag.Parse()

server, err := osquery.NewExtensionManagerServer("example_distributed", *socketPath)
server, err := osquery.NewExtensionManagerServer("example_distributed", "0.0.0", *socketPath)
if err != nil {
log.Fatalf("Error creating extension: %s\n", err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/logger/main.go
Expand Up @@ -15,7 +15,7 @@ func main() {
flag.Int("interval", 0, "")
flag.Parse()

server, err := osquery.NewExtensionManagerServer("example_logger", *socketPath)
server, err := osquery.NewExtensionManagerServer("example_logger", "0.0.0", *socketPath)
if err != nil {
log.Fatalf("Error creating extension: %s\n", err)
}
Expand Down
2 changes: 2 additions & 0 deletions examples/table/main.go
Expand Up @@ -14,6 +14,7 @@ var (
socket = flag.String("socket", "", "Path to the extensions UNIX domain socket")
timeout = flag.Int("timeout", 3, "Seconds to wait for autoloaded extensions")
interval = flag.Int("interval", 3, "Seconds delay between connectivity checks")
_ = flag.Bool("verbose", true, "")
)

func main() {
Expand All @@ -30,6 +31,7 @@ func main() {

server, err := osquery.NewExtensionManagerServer(
"example_extension",
"0.0.0",
*socket,
serverTimeout,
serverPingInterval,
Expand Down
7 changes: 5 additions & 2 deletions server.go
Expand Up @@ -41,6 +41,7 @@ const defaultPingInterval = 5 * time.Second
// communication with the osquery process.
type ExtensionManagerServer struct {
name string
version string
sockPath string
serverClient ExtensionManager
registry map[string](map[string]OsqueryPlugin)
Expand Down Expand Up @@ -80,7 +81,7 @@ func ServerPingInterval(interval time.Duration) ServerOption {
// communicating with osquery over the socket at the provided path. If
// resolving the address or connecting to the socket fails, this function will
// error.
func NewExtensionManagerServer(name string, sockPath string, opts ...ServerOption) (*ExtensionManagerServer, error) {
func NewExtensionManagerServer(name string, version string, sockPath string, opts ...ServerOption) (*ExtensionManagerServer, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of making version a required parameter (which would be a breaking API change), can you make a ServerOption that allows setting the version?

// Initialize nested registry maps
registry := make(map[string](map[string]OsqueryPlugin))
for reg, _ := range validRegistryNames {
Expand All @@ -89,6 +90,7 @@ func NewExtensionManagerServer(name string, sockPath string, opts ...ServerOptio

manager := &ExtensionManagerServer{
name: name,
version: version,
sockPath: sockPath,
registry: registry,
timeout: defaultTimeout,
Expand Down Expand Up @@ -143,7 +145,8 @@ func (s *ExtensionManagerServer) Start() error {

stat, err := s.serverClient.RegisterExtension(
&osquery.InternalExtensionInfo{
Name: s.name,
Name: s.name,
Version: s.version,
},
registry,
)
Expand Down