Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah-Kolide committed Jan 24, 2024
1 parent 5d19fc9 commit 5eee8db
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 192 deletions.
6 changes: 2 additions & 4 deletions osquery/tables/system/linux/block_devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@

namespace osquery {
namespace tables {
QueryData genBlockDevs(QueryContext &context) {
QueryData results;

QueryData genBlockDevs(QueryContext& context) {
if (getuid() || geteuid()) {
VLOG(1) << "Not running as root, LVM and other column data not available";
return results;
}

QueryData results;
auto query_context = context.constraints.find("name")->second.getAll(EQUALS);
auto block_devices = enumerateBlockDevices(query_context, false);

Expand Down
13 changes: 9 additions & 4 deletions osquery/tables/system/linux/disk_encryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const std::string kEncryptionStatusNotEncrypted = "not encrypted";

namespace osquery {
namespace tables {
void genFDEStatusForBlockDevice(const BlockDevice& block_device, std::set<BlockDevice>& block_devices, std::map<std::string, Row>& encryption_status) {
void genFDEStatusForBlockDevice(const BlockDevice& block_device,
std::set<BlockDevice>& block_devices,
std::map<std::string, Row>& encryption_status) {
Row r;
r["name"] = block_device.name;
r["uuid"] = block_device.uuid;
Expand All @@ -40,7 +42,8 @@ void genFDEStatusForBlockDevice(const BlockDevice& block_device, std::set<BlockD
r["encryption_status"] = kEncryptionStatusEncrypted;
r["type"] = "";

auto crypt_init = crypt_init_by_name_and_header(&cd, r["name"].c_str(), nullptr);
auto crypt_init =
crypt_init_by_name_and_header(&cd, r["name"].c_str(), nullptr);
if (crypt_init < 0) {
VLOG(1) << "Unable to initialize crypt device for " << r["name"];
break;
Expand Down Expand Up @@ -82,7 +85,8 @@ void genFDEStatusForBlockDevice(const BlockDevice& block_device, std::set<BlockD
if (!block_device.parent.empty()) {
// Since `genFDEStatusForBlockDevice` is recursive, ensure no duplicates.
if (!encryption_status.count(block_device.parent)) {
if (auto parent = block_devices.find(block_device.parent); parent != block_devices.end()) {
if (auto parent = block_devices.find(block_device.parent);
parent != block_devices.end()) {
genFDEStatusForBlockDevice(*parent, block_devices, encryption_status);
}
}
Expand Down Expand Up @@ -116,7 +120,8 @@ QueryData genFDEStatus(QueryContext& context) {
for (const auto& block_device : block_devices) {
// Since `genFDEStatusForBlockDevice` is recursive, ensure no duplicates.
if (!encryption_status.count(block_device.name)) {
genFDEStatusForBlockDevice(block_device, block_devices, encryption_status);
genFDEStatusForBlockDevice(
block_device, block_devices, encryption_status);
}

results.push_back(encryption_status[block_device.name]);
Expand Down

0 comments on commit 5eee8db

Please sign in to comment.