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

Implement wifi-ish table for linux #702

Merged
merged 22 commits into from
Feb 4, 2021

Conversation

blaedj
Copy link
Contributor

@blaedj blaedj commented Jan 27, 2021

This commit:

  • adds a simple 'string-delimited' strategy for dataflatten, including
    record-splitting based on the idea that if we see a key 'again', we
    should start a new record, instead of over-writing the key.
  • adds a new KeyValue data source type to dataflattentable
  • adds options to the TablePluginExec function
  • implements a wifi table via a dataflattentable.TablePluginExec call

Note that this table will only work if nmcli is installed, so it's not a true
solution for all linux installations.

osquery> select * from kolide_nmcli where key not in ('BSSID', 'SSID', 'SSID-HEX');
+-------------+--------+-----------+-------------------------------------------------+-------+
| fullkey     | parent | key       | value                                           | query |
+-------------+--------+-----------+-------------------------------------------------+-------+
| 7/CHAN      | 7      | CHAN      | 11                                              |       |
| 7/RATE      | 7      | RATE      | 130 Mbit/s                                      |       |
| 7/BARS      | 7      | BARS      | ▂▄▆█                                            |       |
| 7/WPA-FLAGS | 7      | WPA-FLAGS | (none)                                          |       |
| 7/NAME      | 7      | NAME      | AP[8]                                           |       |
| 7/MODE      | 7      | MODE      | Infra                                           |       |
| 7/RSN-FLAGS | 7      | RSN-FLAGS | pair_ccmp group_ccmp psk                        |       |
| 7/SIGNAL    | 7      | SIGNAL    | 90                                              |       |
| 7/DEVICE    | 7      | DEVICE    | wlp2s0                                          |       |
| 7/FREQ      | 7      | FREQ      | 2462 MHz                                        |       |
| 7/SECURITY  | 7      | SECURITY  | WPA2                                            |       |
| 7/ACTIVE    | 7      | ACTIVE    | no                                              |       |
| 7/IN-USE    | 7      | IN-USE    |                                                 |       |
| 7/DBUS-PATH | 7      | DBUS-PATH | /org/freedesktop/NetworkManager/AccessPoint/127 |       |
| 0/SIGNAL    | 0      | SIGNAL    | 100                                             |       |
| 0/SECURITY  | 0      | SECURITY  | WPA2                                            |       |
| 0/DBUS-PATH | 0      | DBUS-PATH | /org/freedesktop/NetworkManager/AccessPoint/123 |       |
| 0/MODE      | 0      | MODE      | Infra                                           |       |
| 0/CHAN      | 0      | CHAN      | 6                                               |       |
| 0/BARS      | 0      | BARS      | ▂▄▆█                                            |       |
| 0/WPA-FLAGS | 0      | WPA-FLAGS | (none)                                          |       |
| 0/DEVICE    | 0      | DEVICE    | wlp2s0                                          |       |
| 0/FREQ      | 0      | FREQ      | 2437 MHz                                        |       |
| 0/RATE      | 0      | RATE      | 195 Mbit/s                                      |       |
| 0/RSN-FLAGS | 0      | RSN-FLAGS | pair_ccmp group_ccmp psk                        |       |
| 0/ACTIVE    | 0      | ACTIVE    | no                                              |       |
| 0/IN-USE    | 0      | IN-USE    |                                                 |       |
| 0/NAME      | 0      | NAME      | AP[1]                                           |       |

This commit:
 - uses the --pretty flag to nmcli, because that causes each wifi
 network's properties to be separated by a line of dashes
This commit:
 - implements a new strategy for detecting separators between new
 records, without relying on the `--pretty` flag.
This commit:
 - adds a new KeyValue DataSourceType, that assumes a simple string
 separator between key and value in a single line
 - adds a new 'StringDelmitedUnseparatedFunc' to be used as the
 dataFunc for tables with the KeyValue datasource type
 - adds a funcitonal option for setting the separator string for
 KeyValue tables (the default is ":")
 - updates the TablePluginExec function to accept functional options
 parameters
   - including adding the ExecTableOpt type for the function options
 - updates platform_tables_linux to define kolide_nmcli as a
 TablePluginExec call
@blaedj blaedj marked this pull request as ready for review February 3, 2021 15:36
Copy link
Contributor

@directionless directionless left a comment

Choose a reason for hiding this comment

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

I like this. Some small scale things

pkg/osquery/tables/dataflattentable/tables.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/osquery/tables/dataflattentable/exec.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/osquery/table/platform_tables_linux.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
pkg/dataflatten/string_delimited.go Outdated Show resolved Hide resolved
@directionless directionless merged commit 8eb766a into kolide:master Feb 4, 2021
@blaedj blaedj deleted the nmcli-networks branch February 4, 2021 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants