/src/osquery/plugins/config/parsers/logger.cpp
Line | Count | Source |
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 <osquery/registry/registry_factory.h> |
11 | | #include <plugins/config/parsers/logger.h> |
12 | | |
13 | | namespace rj = rapidjson; |
14 | | |
15 | | namespace osquery { |
16 | | |
17 | | const std::string LoggerConfigParserPlugin::kLoggerKey{"logger"}; |
18 | | |
19 | | Status LoggerConfigParserPlugin::update(const std::string& /* source */, |
20 | 64.6k | const ParserConfig& config) { |
21 | 64.6k | rj::Document& doc = data_.doc(); |
22 | | |
23 | 64.6k | auto it = doc.FindMember(kLoggerKey); |
24 | 64.6k | if (it != doc.MemberEnd()) { |
25 | 57 | doc.EraseMember(it); |
26 | 57 | } |
27 | | |
28 | 64.6k | auto cv = config.find(kLoggerKey); |
29 | 64.6k | if (cv != config.end()) { |
30 | 57 | auto doc = JSON::newObject(); |
31 | 57 | auto obj = doc.getObject(); |
32 | 57 | doc.copyFrom(cv->second.doc(), obj); |
33 | 57 | doc.add(kLoggerKey, obj); |
34 | 57 | data_ = std::move(doc); |
35 | 57 | } |
36 | | |
37 | 64.6k | return Status(); |
38 | 64.6k | } |
39 | | |
40 | | REGISTER_INTERNAL(LoggerConfigParserPlugin, "config_parser", "logger"); |
41 | | |
42 | | } // namespace osquery |