1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef SECURITY_GUARD_MODEL_CFG_MARSHALLING_H 17 #define SECURITY_GUARD_MODEL_CFG_MARSHALLING_H 18 19 #include <string> 20 #include <vector> 21 22 #include "nlohmann/json.hpp" 23 #include "config_define.h" 24 #include "security_event_info.h" 25 namespace OHOS::Security::SecurityGuard { 26 using Field = struct { 27 std::string fieldName; 28 std::string fieldType; 29 std::string value; 30 }; 31 32 using Rule = struct { 33 int64_t eventId; 34 std::vector<Field> fields; 35 std::string fieldsRelation; 36 }; 37 38 using BuildInDetectionCfg = struct { 39 std::vector<Rule> rules; 40 std::string rulesRelation; 41 std::string trueResult; 42 std::string falseResult; 43 }; 44 45 using AppDetectionCfg = struct { 46 std::string detectionCategory; 47 std::string configFileName; 48 std::string trueResult; 49 std::string falseResult; 50 }; 51 52 constexpr const char *AUDIT_TABLE = "audit_event"; 53 constexpr const char *RISK_TABLE = "risk_event"; 54 55 void from_json(const nlohmann::json &jsonObj, Field &field) {}; 56 void from_json(const nlohmann::json &jsonObj, Rule &rule) {}; 57 void from_json(const nlohmann::json &jsonObj, BuildInDetectionCfg &config) {}; 58 void to_json(nlohmann::json &jsonObj, const ModelCfg &modelCfg) {}; 59 void from_json(const nlohmann::json &jsonObj, ModelCfg &modelCfg) {}; 60 void to_json(nlohmann::json &jsonObj, const EventCfg &eventCfg) {}; 61 void from_json(const nlohmann::json &jsonObj, EventCfg &eventCfg) {}; 62 void to_json(nlohmann::json &jsonObj, const DataMgrCfgSt &dataMgrCfg) {}; 63 void from_json(const nlohmann::json &jsonObj, DataMgrCfgSt &dataMgrCfg) {}; 64 void to_json(nlohmann::json &jsonObj, const SecEvent &eventDataSt) {}; 65 void to_json(nlohmann::json &jsonObj, const EventContentSt &eventContentSt) {}; 66 void from_json(const nlohmann::json &jsonObj, EventContentSt &eventContentSt) {}; 67 } // namespace OHOS::Security::SecurityGuard 68 69 #endif // SECURITY_GUARD_MODEL_CFG_MARSHALLING_H 70