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

Fix last_connected column in wifi_networks on Catalina #6669

Merged
merged 8 commits into from
Oct 21, 2020
Prev Previous commit
Next Next commit
Clang-format
  • Loading branch information
mike-myers-tob committed Sep 24, 2020
commit 682104a207293bca035aca40244334359da20229
11 changes: 6 additions & 5 deletions osquery/tables/networking/darwin/wifi.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
{"disabled", "Disabled"},
{"temporarily_disabled", "TemporarilyDisabled"}};

// The name of the "last_connected" key changed in 10.15, and the
// The name of the "last_connected" key changed in 10.15, and the
// "auto_login" key no longer exists.
const std::map<std::string, std::string> kKnownWifiNetworkKeys = {
{"ssid", "SSID"},
Expand All @@ -57,18 +57,19 @@

// Check if we are running on macOS 10.15 or later. Keys have changed.
Status getKnownWifiNetworkKeys(std::map<std::string, std::string>& keys) {
auto qd = SQL::selectAllFrom("os_version");
auto qd = SQL::selectAllFrom("os_version");
Copy link
Member

Choose a reason for hiding this comment

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

I don't like this approach but I see it used in several other places so we can follow up and fix this later.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a table with one row in this case, but I can see it has been a performance problem in other cases in the past?

if (qd.size() != 1) {
return Status(-1, "Couldn't determine macOS version");
}

keys = (qd.front().at("major") < "11" && qd.front().at("minor") < "15")
? kKnownWifiNetworkKeysPreCatalina
: kKnownWifiNetworkKeys;
? kKnownWifiNetworkKeysPreCatalina
: kKnownWifiNetworkKeys;
return Status(0, "ok");
}

// Check if we are running on macOS 10.9, where the top-level key in the plist was different
// Check if we are running on macOS 10.9, where the top-level key in the plist
// was different
Status getKnownNetworksKey(std::string& key) {
auto qd = SQL::selectAllFrom("os_version");
if (qd.size() != 1) {
Expand Down