From 722d316508e62a9eb6fe18f9ff11bfd934cc5e18 Mon Sep 17 00:00:00 2001 From: Fabian Franz Date: Sun, 4 Jul 2021 22:34:06 +0200 Subject: [PATCH] www/nginx: hotfix api endpoints + frontend for Phalcon 4 --- .../OPNsense/Nginx/Api/LogsController.php | 6 +- .../OPNsense/Nginx/Api/SettingsController.php | 60 +++++++++---------- .../OPNsense/Nginx/IndexController.php | 2 +- .../www/js/nginx/dist/tls_handshakes.min.js | 2 +- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/LogsController.php b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/LogsController.php index 0f0b70912..de4d4cf5b 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/LogsController.php +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/LogsController.php @@ -59,7 +59,7 @@ class LogsController extends ApiControllerBase * action to query the TLS handshake information - useful for building fingerprint databases * @throws \Exception */ - public function tls_handshakesAction() + public function tlsHandshakesAction() { $this->sendConfigdToClient('nginx tls_handshakes'); } @@ -90,7 +90,7 @@ class LogsController extends ApiControllerBase * @return array if feasible, otherwise null and the data is sent directly back * @throws \OPNsense\Base\ModelException ? */ - public function stream_accessesAction($uuid = null) + public function streamAccessesAction($uuid = null) { $this->nginx = new Nginx(); if (!isset($uuid)) { @@ -109,7 +109,7 @@ class LogsController extends ApiControllerBase * @return array if feasible, otherwise null and the data is sent directly back * @throws \OPNsense\Base\ModelException ? */ - public function stream_errorsAction($uuid = null) + public function streamErrorsAction($uuid = null) { $this->nginx = new Nginx(); if (!isset($uuid)) { diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php index 36beafbc7..29c56282e 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/Api/SettingsController.php @@ -340,34 +340,34 @@ class SettingsController extends ApiMutableModelControllerBase } // http security headers - public function searchsecurity_headerAction() + public function searchsecurityHeaderAction() { return $this->searchBase('security_header', array('description')); } - public function getsecurity_headerAction($uuid = null) + public function getsecurityHeaderAction($uuid = null) { $this->sessionClose(); return $this->getBase('security_header', 'security_header', $uuid); } - public function addsecurity_headerAction() + public function addsecurityHeaderAction() { return $this->addBase('security_header', 'security_header'); } - public function delsecurity_headerAction($uuid) + public function delsecurityHeaderAction($uuid) { return $this->delBase('security_header', $uuid); } - public function setsecurity_headerAction($uuid) + public function setsecurityHeaderAction($uuid) { return $this->setBase('security_header', 'security_header', $uuid); } // access limit zone headers - public function searchlimit_zoneAction() + public function searchlimitZoneAction() { return $this->searchBase( 'limit_zone', @@ -375,23 +375,23 @@ class SettingsController extends ApiMutableModelControllerBase ); } - public function getlimit_zoneAction($uuid = null) + public function getlimitZoneAction($uuid = null) { $this->sessionClose(); return $this->getBase('limit_zone', 'limit_zone', $uuid); } - public function addlimit_zoneAction() + public function addlimitZoneAction() { return $this->addBase('limit_zone', 'limit_zone'); } - public function dellimit_zoneAction($uuid) + public function dellimitZoneAction($uuid) { return $this->delBase('limit_zone', $uuid); } - public function setlimit_zoneAction($uuid) + public function setlimitZoneAction($uuid) { return $this->setBase('limit_zone', 'limit_zone', $uuid); } @@ -433,34 +433,34 @@ class SettingsController extends ApiMutableModelControllerBase } // TLS fingerprints for MITM detection - public function searchtls_fingerprintAction() + public function searchtlsFingerprintAction() { return $this->searchBase('tls_fingerprint', array('description')); } - public function gettls_fingerprintAction($uuid = null) + public function gettlsFingerprintAction($uuid = null) { $this->sessionClose(); return $this->getBase('tls_fingerprint', 'tls_fingerprint', $uuid); } - public function addtls_fingerprintAction() + public function addtlsFingerprintAction() { return $this->addBase('tls_fingerprint', 'tls_fingerprint'); } - public function deltls_fingerprintAction($uuid) + public function deltlsFingerprintAction($uuid) { return $this->delBase('tls_fingerprint', $uuid); } - public function settls_fingerprintAction($uuid) + public function settlsFingerprintAction($uuid) { return $this->setBase('tls_fingerprint', 'tls_fingerprint', $uuid); } // limit_request_connection - public function searchlimit_request_connectionAction() + public function searchlimitRequestConnectionAction() { return $this->searchBase( 'limit_request_connection', @@ -468,28 +468,28 @@ class SettingsController extends ApiMutableModelControllerBase ); } - public function getlimit_request_connectionAction($uuid = null) + public function getlimitRequestConnectionAction($uuid = null) { $this->sessionClose(); return $this->getBase('limit_request_connection', 'limit_request_connection', $uuid); } - public function addlimit_request_connectionAction() + public function addlimitRequestConnectionAction() { return $this->addBase('limit_request_connection', 'limit_request_connection'); } - public function dellimit_request_connectionAction($uuid) + public function dellimitRequestConnectionAction($uuid) { return $this->delBase('limit_request_connection', $uuid); } - public function setlimit_request_connectionAction($uuid) + public function setlimitRequestConnectionAction($uuid) { return $this->setBase('limit_request_connection', 'limit_request_connection', $uuid); } // cache path - public function searchcache_pathAction() + public function searchcachePathAction() { return $this->searchBase( 'cache_path', @@ -497,23 +497,23 @@ class SettingsController extends ApiMutableModelControllerBase ); } - public function getcache_pathAction($uuid = null) + public function getcachePathAction($uuid = null) { $this->sessionClose(); return $this->getBase('cache_path', 'cache_path', $uuid); } - public function addcache_pathAction() + public function addcachePathAction() { return $this->addBase('cache_path', 'cache_path'); } - public function delcache_pathAction($uuid) + public function delcachePathAction($uuid) { return $this->delBase('cache_path', $uuid); } - public function setcache_pathAction($uuid) + public function setcachePathAction($uuid) { return $this->setBase('cache_path', 'cache_path', $uuid); } @@ -719,28 +719,28 @@ class SettingsController extends ApiMutableModelControllerBase } } // SYSLOG targets - public function searchsyslog_targetAction() + public function searchsyslogTargetAction() { return $this->searchBase('syslog_target', array('description', 'host', 'facility', 'severity')); } - public function getsyslog_targetAction($uuid = null) + public function getsyslogTargetAction($uuid = null) { $this->sessionClose(); return $this->getBase('syslog_target', 'syslog_target', $uuid); } - public function addsyslog_targetAction() + public function addsyslogTargetAction() { return $this->addBase('syslog_target', 'syslog_target'); } - public function delsyslog_targetAction($uuid) + public function delsyslogTargetAction($uuid) { return $this->delBase('syslog_target', $uuid); } - public function setsyslog_targetAction($uuid) + public function setsyslogTargetAction($uuid) { return $this->setBase('syslog_target', 'syslog_target', $uuid); } diff --git a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php index 9af641c11..e80537625 100644 --- a/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php +++ b/www/nginx/src/opnsense/mvc/app/controllers/OPNsense/Nginx/IndexController.php @@ -82,7 +82,7 @@ class IndexController extends \OPNsense\Base\IndexController /** * show the nginx TLS handshakes page /ui/nginx/index/tls_handshakes */ - public function tls_handshakesAction() + public function tlsHandshakesAction() { $this->view->pick('OPNsense/Nginx/tls_handshakes'); } diff --git a/www/nginx/src/opnsense/www/js/nginx/dist/tls_handshakes.min.js b/www/nginx/src/opnsense/www/js/nginx/dist/tls_handshakes.min.js index 7e7980893..d703bd4a5 100644 --- a/www/nginx/src/opnsense/www/js/nginx/dist/tls_handshakes.min.js +++ b/www/nginx/src/opnsense/www/js/nginx/dist/tls_handshakes.min.js @@ -1 +1 @@ -!function(t){var n={};function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(n){return t[n]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=28)}([function(t,n,e){var o=e(2),r=e(4),i=/[&<>"']/g,c=RegExp(i.source);t.exports=function(t){return(t=r(t))&&c.test(t)?t.replace(i,o):t}},function(t,n,e){var o=e(6).Symbol;t.exports=o},function(t,n,e){var o=e(3)({"&":"&","<":"<",">":">",'"':""","'":"'"});t.exports=o},function(t,n){t.exports=function(t){return function(n){return null==t?void 0:t[n]}}},function(t,n,e){var o=e(5);t.exports=function(t){return null==t?"":o(t)}},function(t,n,e){var o=e(1),r=e(9),i=e(10),c=e(11),l=1/0,u=o?o.prototype:void 0,s=u?u.toString:void 0;t.exports=function t(n){if("string"==typeof n)return n;if(i(n))return r(n,t)+"";if(c(n))return s?s.call(n):"";var e=n+"";return"0"==e&&1/n==-l?"-0":e}},function(t,n,e){var o=e(7),r="object"==typeof self&&self&&self.Object===Object&&self,i=o||r||Function("return this")();t.exports=i},function(t,n,e){(function(n){var e="object"==typeof n&&n&&n.Object===Object&&n;t.exports=e}).call(this,e(8))},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n){t.exports=function(t,n){for(var e=-1,o=null==t?0:t.length,r=Array(o);++e\n \n\n
\n
\n
\n
\n
\n \n
\n
\n';return __p}},function(module,exports,__webpack_require__){var _={escape:__webpack_require__(0)};module.exports=function(obj){obj||(obj={});var __t,__p="";with(obj)__p+='
\n
\n
\n
\n Count\n
\n
'+(null==(__t=_.escape(count))?"":__t)+'
\n
\n Ciphers\n
\n
'+(null==(__t=_.escape(ciphers))?"":__t)+'
\n
\n Curves\n
\n
'+(null==(__t=_.escape(curves))?"":__t)+'
\n
\n
\n
\n \n
\n\n
\n';return __p}},function(module,exports,__webpack_require__){var _={escape:__webpack_require__(0)};module.exports=function(obj){obj||(obj={});var __t,__p="";with(obj)__p+='
\n \n \n \n \n \n \n \n \n \n
\n
\n';return __p}},,,function(t,n,e){"use strict";e.r(n);var o=Backbone.Model.extend({url:"/api/nginx/logs/tls_handshakes"}),r=e(23),i=e.n(r),c=e(24),l=e.n(c),u=e(25),s=e.n(u);const a=new o,d=Backbone.View.extend({initialize:function(t){this.ua=t.ua},events:{"click button":"trust_fingerprint"},render:function(){this.$el.html(l()(this.model.toJSON()))},trust_fingerprint:function(){const t=this;BootstrapDialog.show({type:BootstrapDialog.TYPE_INFO,title:"Save new fingerprint",message:$("
").html(s()({})),buttons:[{label:"Save",cssClass:"btn-primary",icon:"fa fa-floppy-o ",action:function(n){t.handle_trust(n.$modalBody.find("#fp_description").val(),n.$modalBody.find("#fp_trusted").is(":checked")),n.close()}},{label:"Close",action:function(t){t.close()}}]})},handle_trust:function(t,n){ajaxCall("/api/nginx/settings/addtls_fingerprint",{tls_fingerprint:{curves:this.model.get("curves"),ciphers:this.model.get("ciphers"),user_agent:this.ua,trusted:n?"1":"0",description:t}},function(t,n){})}}),p=Backbone.View.extend({initialize:function(t){this.ua=t.ua,this.render()},render:function(){const t=this;this.$el.html(i()({ua:this.ua}));const n=this.$el.find(".content_holder"),e=this.$el.find(".chart_holder"),o=this.collection.map(function(t){return{label:t.get("ciphers")+"||"+t.get("curves"),value:t.get("count")}});this.collection.forEach(function(e){const o=new d({model:e,ua:t.ua});n.append(o.$el),o.render()});try{nv.addGraph(function(){const t=nv.models.pieChart();return t.x(function(t){return t.label}),t.y(function(t){return t.value}),t.showLabels(!1),t.labelType("value"),t.donut(!0),t.donutRatio(.2),d3.select(e[0]).datum(o).transition().duration(350).call(t),t})}catch(t){console.log(t)}}}),f=new(Backbone.View.extend({initialize:function(){this.listenTo(this.model,"sync",this.render)},render:function(){this.$el.html(""),this.render_all(this.model.attributes)},render_all(t){for(const n in t)if(t.hasOwnProperty(n)){const e=new Backbone.Collection(t[n]),o=new p({collection:e,ua:n});this.$el.append(o.$el)}}}))({model:a});$("#tls_handshakes_application").append(f.$el),a.fetch()}]); \ No newline at end of file +!function(t){var n={};function e(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,e),r.l=!0,r.exports}e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:o})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(e.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var r in t)e.d(o,r,function(n){return t[n]}.bind(null,r));return o},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=28)}([function(t,n,e){var o=e(2),r=e(4),i=/[&<>"']/g,c=RegExp(i.source);t.exports=function(t){return(t=r(t))&&c.test(t)?t.replace(i,o):t}},function(t,n,e){var o=e(6).Symbol;t.exports=o},function(t,n,e){var o=e(3)({"&":"&","<":"<",">":">",'"':""","'":"'"});t.exports=o},function(t,n){t.exports=function(t){return function(n){return null==t?void 0:t[n]}}},function(t,n,e){var o=e(5);t.exports=function(t){return null==t?"":o(t)}},function(t,n,e){var o=e(1),r=e(9),i=e(10),c=e(11),l=1/0,u=o?o.prototype:void 0,s=u?u.toString:void 0;t.exports=function t(n){if("string"==typeof n)return n;if(i(n))return r(n,t)+"";if(c(n))return s?s.call(n):"";var e=n+"";return"0"==e&&1/n==-l?"-0":e}},function(t,n,e){var o=e(7),r="object"==typeof self&&self&&self.Object===Object&&self,i=o||r||Function("return this")();t.exports=i},function(t,n,e){(function(n){var e="object"==typeof n&&n&&n.Object===Object&&n;t.exports=e}).call(this,e(8))},function(t,n){var e;e=function(){return this}();try{e=e||new Function("return this")()}catch(t){"object"==typeof window&&(e=window)}t.exports=e},function(t,n){t.exports=function(t,n){for(var e=-1,o=null==t?0:t.length,r=Array(o);++e\n \n\n
\n
\n
\n
\n
\n \n
\n
\n';return __p}},function(module,exports,__webpack_require__){var _={escape:__webpack_require__(0)};module.exports=function(obj){obj||(obj={});var __t,__p="",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,"")}with(obj)"undefined"!=typeof count&&"undefined"!=typeof ciphers&&"undefined"!=typeof curves&&(__p+='\n
\n
\n
\n
\n Count\n
\n
'+(null==(__t=_.escape(count||""))?"":__t)+'
\n
\n Ciphers\n
\n
'+(null==(__t=_.escape(ciphers||""))?"":__t)+'
\n
\n Curves\n
\n
'+(null==(__t=_.escape(curves||""))?"":__t)+'
\n
\n
\n
\n \n
\n
\n'),__p+="\n";return __p}},function(module,exports,__webpack_require__){var _={escape:__webpack_require__(0)};module.exports=function(obj){obj||(obj={});var __t,__p="";with(obj)__p+='
\n \n \n \n \n \n \n \n \n \n
\n
\n';return __p}},,,function(t,n,e){"use strict";e.r(n);var o=Backbone.Model.extend({url:"/api/nginx/logs/tls_handshakes"}),r=e(23),i=e.n(r),c=e(24),l=e.n(c),u=e(25),s=e.n(u);const a=new o,d=Backbone.View.extend({initialize:function(t){this.ua=t.ua},events:{"click button":"trust_fingerprint"},render:function(){this.$el.html(l()(this.model.toJSON()))},trust_fingerprint:function(){const t=this;BootstrapDialog.show({type:BootstrapDialog.TYPE_INFO,title:"Save new fingerprint",message:$("
").html(s()({})),buttons:[{label:"Save",cssClass:"btn-primary",icon:"fa fa-floppy-o ",action:function(n){t.handle_trust(n.$modalBody.find("#fp_description").val(),n.$modalBody.find("#fp_trusted").is(":checked")),n.close()}},{label:"Close",action:function(t){t.close()}}]})},handle_trust:function(t,n){ajaxCall("/api/nginx/settings/addtls_fingerprint",{tls_fingerprint:{curves:this.model.get("curves"),ciphers:this.model.get("ciphers"),user_agent:this.ua,trusted:n?"1":"0",description:t}},function(t,n){})}}),p=Backbone.View.extend({initialize:function(t){this.ua=t.ua,this.render()},render:function(){const t=this;this.$el.html(i()({ua:this.ua}));const n=this.$el.find(".content_holder"),e=this.$el.find(".chart_holder"),o=this.collection.map(function(t){return{label:t.get("ciphers")+"||"+t.get("curves"),value:t.get("count")}});this.collection.forEach(function(e){const o=new d({model:e,ua:t.ua});n.append(o.$el),o.render()});try{nv.addGraph(function(){const t=nv.models.pieChart();return t.x(function(t){return t.label}),t.y(function(t){return t.value}),t.showLabels(!1),t.labelType("value"),t.donut(!0),t.donutRatio(.2),d3.select(e[0]).datum(o).transition().duration(350).call(t),t})}catch(t){console.log(t)}}}),f=new(Backbone.View.extend({initialize:function(){this.listenTo(this.model,"sync",this.render)},render:function(){this.$el.html(""),this.render_all(this.model.attributes)},render_all(t){for(const n in t)if(t.hasOwnProperty(n)&&void 0!==t[n]&&"function"!=typeof t[n]){const e=new Backbone.Collection(t[n]),o=new p({collection:e,ua:n});this.$el.append(o.$el)}}}))({model:a});$("#tls_handshakes_application").append(f.$el),a.fetch()}]); \ No newline at end of file