2626
2727#include " Types.hpp"
2828#include " DdsUtils.hpp"
29+ #include " SecureLogUtils.hpp"
2930
3031// Heartbeat listener to automatically monitor other applications
3132class HeartbeatListener
@@ -114,6 +115,13 @@ class OrchestratorApp {
114115
115116 waitset_status += status_read_condition;
116117
118+ if (SecureLogUtils::is_secure (participant)) {
119+ securelog_reader = SecureLogUtils::setup_secure_log_reader (
120+ std::bind (&OrchestratorApp::process_secure_log, this , std::placeholders::_1),
121+ default_provider
122+ );
123+ }
124+
117125 app = Gtk::Application::create (" orchestrator.orchestrator" );
118126 app->signal_activate ().connect ([this ]() { ui_setup (); });
119127 }
@@ -134,6 +142,10 @@ class OrchestratorApp {
134142 std::map<Common::DeviceType, Gtk::RadioButton *> device_map;
135143 Gtk::ScrolledWindow *scroll;
136144 Glib::RefPtr<Gtk::TextBuffer> buffer;
145+ Gtk::Label *security_indicator = nullptr ;
146+ sigc::connection security_flash_connection;
147+ bool security_flash_on = false ;
148+ int security_flash_ticks_remaining = 0 ;
137149
138150 // Connext entities
139151 dds::domain::DomainParticipant participant = dds::core::null;
@@ -145,6 +157,9 @@ class OrchestratorApp {
145157 rti::core::cond::AsyncWaitSet waitset_status;
146158 std::shared_ptr<HeartbeatListener> hb_listener;
147159
160+ // Connext secure logging entities
161+ SecureLogUtils::SecureLogReader securelog_reader = {dds::core::null, dds::core::null};
162+
148163 void log_alert (std::string msg)
149164 {
150165 Glib::signal_idle ().connect ([this , msg]() -> bool {
@@ -193,6 +208,86 @@ class OrchestratorApp {
193208 command_writer.write (command);
194209 }
195210
211+ void set_security_indicator_ok ()
212+ {
213+ if (security_indicator == nullptr ) {
214+ return ;
215+ }
216+
217+ auto ctx = security_indicator->get_style_context ();
218+ ctx->remove_class (" security-threat-on" );
219+ ctx->remove_class (" security-threat-off" );
220+ ctx->add_class (" security-ok" );
221+ security_indicator->set_text (" SECURITY: OK" );
222+ }
223+
224+ void trigger_security_flash ()
225+ {
226+ Glib::signal_idle ().connect ([this ]() -> bool {
227+ if (security_indicator == nullptr ) {
228+ return false ;
229+ }
230+
231+ // Keep flashing for ~8s after the latest threat event.
232+ security_flash_ticks_remaining = 16 ;
233+
234+ if (security_flash_connection.connected ()) {
235+ return false ;
236+ }
237+
238+ security_flash_on = false ;
239+ security_flash_connection = Glib::signal_timeout ().connect (
240+ [this ]() -> bool {
241+ if (security_indicator == nullptr ) {
242+ return false ;
243+ }
244+
245+ auto ctx = security_indicator->get_style_context ();
246+ ctx->remove_class (" security-ok" );
247+ ctx->remove_class (" security-threat-on" );
248+ ctx->remove_class (" security-threat-off" );
249+
250+ security_flash_on = !security_flash_on;
251+ if (security_flash_on) {
252+ security_indicator->set_text (" SECURITY THREAT" );
253+ ctx->add_class (" security-threat-on" );
254+ } else {
255+ security_indicator->set_text (" SECURITY THREAT" );
256+ ctx->add_class (" security-threat-off" );
257+ }
258+
259+ --security_flash_ticks_remaining;
260+ if (security_flash_ticks_remaining <= 0 ) {
261+ set_security_indicator_ok ();
262+ security_flash_connection.disconnect ();
263+ return false ;
264+ }
265+
266+ return true ;
267+ },
268+ 500 );
269+
270+ return false ;
271+ });
272+ }
273+
274+ bool is_security_threat (const DDSSecurity::BuiltinLoggingTypeV2 &sample)
275+ {
276+ return static_cast <int32_t >(sample.severity ())
277+ // return sample.value<int32_t>("severity")
278+ <= static_cast <int32_t >(DDSSecurity::LoggingLevel::WARNING_LEVEL );
279+ }
280+
281+ void process_secure_log (const SecureLogUtils::SecureLogType& log)
282+ {
283+ if (is_security_threat (log)) {
284+ std::stringstream ss;
285+ ss << " SECURITY THREAT [" << log.appname () << " ] " << log.message ();
286+ log_alert (ss.str ());
287+ trigger_security_flash ();
288+ }
289+ }
290+
196291 void process_status ()
197292 {
198293 dds::sub::LoanedSamples<Common::DeviceStatus> samples =
@@ -263,6 +358,17 @@ class OrchestratorApp {
263358 hdr->pack_start (*logo, false , false , 0 );
264359 hdr->reorder_child (*logo, 0 );
265360 } catch (...) {}
361+
362+ if (SecureLogUtils::is_secure (participant)) {
363+ security_indicator = Gtk::manage (new Gtk::Label (" SECURITY: OK" ));
364+ auto ctx = security_indicator->get_style_context ();
365+ ctx->add_class (" security-indicator" );
366+ ctx->add_class (" security-ok" );
367+ security_indicator->set_margin_start (10 );
368+ security_indicator->set_margin_end (4 );
369+ security_indicator->set_visible (true );
370+ hdr->pack_end (*security_indicator, false , false , 0 );
371+ }
266372 }
267373 }
268374
0 commit comments