Coverage Report

Created: 2025-07-23 08:14

/src/osquery/plugins/config/parsers/kafka_topics.cpp
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * Copyright (c) 2014-present, The osquery authors
3
 *
4
 * This source code is licensed as defined by the LICENSE file found in the
5
 * root directory of this source tree.
6
 *
7
 * SPDX-License-Identifier: (Apache-2.0 OR GPL-2.0-only)
8
 */
9
10
#include <iostream>
11
12
#include <osquery/config/config.h>
13
#include <osquery/registry/registry_factory.h>
14
#include <plugins/config/parsers/kafka_topics.h>
15
16
namespace osquery {
17
18
/// Root key to retrieve Kafka topic configurations.
19
const std::string kKafkaTopicParserRootKey("kafka_topics");
20
21
40.2k
std::vector<std::string> KafkaTopicsConfigParserPlugin::keys() const {
22
40.2k
  return {kKafkaTopicParserRootKey};
23
40.2k
}
24
25
Status KafkaTopicsConfigParserPlugin::update(const std::string& source,
26
40.2k
                                             const ParserConfig& config) {
27
40.2k
  auto topics = config.find(kKafkaTopicParserRootKey);
28
40.2k
  if (topics != config.end()) {
29
0
    auto doc = JSON::newObject();
30
0
    auto obj = doc.getObject();
31
0
    doc.copyFrom(topics->second.doc(), obj);
32
0
    doc.add(kKafkaTopicParserRootKey, obj);
33
0
    data_ = std::move(doc);
34
0
  }
35
40.2k
  return Status();
36
40.2k
}
37
38
REGISTER_INTERNAL(KafkaTopicsConfigParserPlugin,
39
                  "config_parser",
40
                  "kafka_topics");
41
} // namespace osquery