Skip to content

Commit 966c5ca

Browse files
committed
Add binary_path option to osquery connection schema
The osquery Python SDK's SpawnInstance() hardcodes /usr/bin/osqueryd, so portable installs (e.g. ~/.local/bin/osqueryd) fail to connect. Accept a binary_path option and pass it through to SpawnInstance(path=...) when set; the field is surfaced in the connection schema for spawn mode.
1 parent 82c11b2 commit 966c5ca

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

sqlit/domains/connections/providers/osquery/adapter.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,14 @@ def connect(self, config: ConnectionConfig) -> OsqueryConnection:
131131
instance.open()
132132
return OsqueryConnection(instance, is_spawned=False)
133133
else:
134-
# Spawn embedded instance
135-
instance = osquery_module.SpawnInstance()
134+
# Spawn embedded instance. Accept an optional `binary_path` config
135+
# option so users can point at a portable osqueryd (e.g. installed
136+
# in ~/.local/bin) rather than the SDK's hardcoded /usr/bin/osqueryd.
137+
binary_path = config.get_option("binary_path")
138+
if binary_path:
139+
instance = osquery_module.SpawnInstance(path=str(binary_path))
140+
else:
141+
instance = osquery_module.SpawnInstance()
136142
instance.open()
137143
return OsqueryConnection(instance, is_spawned=True)
138144

sqlit/domains/connections/providers/osquery/schema.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ def _connection_mode_is_socket(v: dict) -> bool:
1212
return v.get("connection_mode") == "socket"
1313

1414

15+
def _connection_mode_is_spawn(v: dict) -> bool:
16+
return v.get("connection_mode", "spawn") == "spawn"
17+
18+
1519
SCHEMA = ConnectionSchema(
1620
db_type="osquery",
1721
display_name="osquery",
@@ -34,6 +38,14 @@ def _connection_mode_is_socket(v: dict) -> bool:
3438
visible_when=_connection_mode_is_socket,
3539
description="Path to osqueryd extension socket",
3640
),
41+
SchemaField(
42+
name="binary_path",
43+
label="osqueryd Binary Path",
44+
placeholder="/usr/bin/osqueryd",
45+
required=False,
46+
visible_when=_connection_mode_is_spawn,
47+
description="Path to osqueryd binary. Leave blank for the platform default.",
48+
),
3749
),
3850
supports_ssh=False,
3951
is_file_based=False,

0 commit comments

Comments
 (0)