Skip to content
API Documentation
BastionGuard™
bsc::ui::anonymous_namespace{UIClient.cpp} Namespace Reference

Functions

void connection_to_json (const bsc::model::Connection &c, json &j)
bsc::rule::OperatorType op_type_from_string (const std::string &s)
bsc::rule::Operator operator_from_json (const json &j)
bsc::rule::Rule rule_from_json (const json &j)

Function Documentation

◆ connection_to_json()

void bsc::ui::anonymous_namespace{UIClient.cpp}::connection_to_json ( const bsc::model::Connection & c,
json & j )

Definition at line 34 of file UIClient.cpp.

34 {
35 j["protocol"] = c.protocol;
36 j["src_ip"] = c.src_ip;
37 j["src_port"] = c.src_port;
38 j["dst_ip"] = c.dst_ip;
39 j["dst_host"] = c.dst_host;
40 j["dst_port"] = c.dst_port;
41 j["user_id"] = c.user_id;
42 j["process_id"] = c.process_id;
43 j["process_path"] = c.process_path;
44 j["process_comm"] = c.process_comm;
45 j["process_cwd"] = c.process_cwd;
46 j["process_args"] = c.process_args;
47 j["process_env"] = c.process_env;
48 j["process_checksums"] = c.process_checksums;
49 json tree = json::array();
50 for (const auto& [name, pid] : c.process_tree) {
51 tree.push_back({{"name", name}, {"pid", pid}});
52 }
53 j["process_tree"] = std::move(tree);
54}
nlohmann::json json
Definition UIClient.cpp:29
std::vector< std::pair< std::string, std::uint32_t > > process_tree
std::uint32_t process_id
std::vector< std::string > process_args
std::uint32_t dst_port
std::uint32_t src_port
std::map< std::string, std::string > process_checksums
std::map< std::string, std::string > process_env
std::uint32_t user_id

References connection_to_json(), bsc::model::Connection::dst_host, bsc::model::Connection::dst_ip, bsc::model::Connection::dst_port, bsc::model::Connection::process_args, bsc::model::Connection::process_checksums, bsc::model::Connection::process_comm, bsc::model::Connection::process_cwd, bsc::model::Connection::process_env, bsc::model::Connection::process_id, bsc::model::Connection::process_path, bsc::model::Connection::process_tree, bsc::model::Connection::protocol, bsc::model::Connection::src_ip, bsc::model::Connection::src_port, and bsc::model::Connection::user_id.

Referenced by connection_to_json().

◆ op_type_from_string()

bsc::rule::OperatorType bsc::ui::anonymous_namespace{UIClient.cpp}::op_type_from_string ( const std::string & s)

◆ operator_from_json()

bsc::rule::Operator bsc::ui::anonymous_namespace{UIClient.cpp}::operator_from_json ( const json & j)

Definition at line 67 of file UIClient.cpp.

67 {
69 op.type = op_type_from_string(j.value("type", std::string{"simple"}));
70 op.operand = j.value("operand", std::string{});
71 op.data = j.value("data", std::string{});
72 op.sensitive = j.value("sensitive", false);
73 if (j.contains("list") && j["list"].is_array()) {
74 for (const auto& item : j["list"]) op.list.push_back(operator_from_json(item));
75 }
76 return op;
77}
bsc::rule::Operator operator_from_json(const json &j)
Definition UIClient.cpp:67
bsc::rule::OperatorType op_type_from_string(const std::string &s)
Definition UIClient.cpp:57
std::string operand
Definition Rule.hpp:15
std::string data
Definition Rule.hpp:16
OperatorType type
Definition Rule.hpp:14
std::vector< Operator > list
Definition Rule.hpp:18

References bsc::rule::Operator::data, bsc::rule::Operator::list, op_type_from_string(), bsc::rule::Operator::operand, operator_from_json(), bsc::rule::Operator::sensitive, and bsc::rule::Operator::type.

Referenced by operator_from_json(), and rule_from_json().

◆ rule_from_json()

bsc::rule::Rule bsc::ui::anonymous_namespace{UIClient.cpp}::rule_from_json ( const json & j)

Definition at line 79 of file UIClient.cpp.

79 {
81 r.created = j.value("created", std::int64_t{0});
82 r.name = j.value("name", std::string{});
83 r.description = j.value("description", std::string{});
84 r.enabled = j.value("enabled", true);
85 r.precedence = j.value("precedence", false);
86 r.nolog = j.value("nolog", false);
87 r.action = j.value("action", std::string{"allow"});
88 r.duration = j.value("duration", std::string{"once"});
89 if (j.contains("operator") && j["operator"].is_object()) {
90 r.op = operator_from_json(j["operator"]);
91 }
92 return r;
93}

References operator_from_json(), and rule_from_json().

Referenced by rule_from_json().