From 6e240699abaac5a78bc4f97012e6deda239a6747 Mon Sep 17 00:00:00 2001 From: iglocska Date: Mon, 16 Mar 2020 13:24:01 +0100 Subject: [PATCH 01/21] new: [dashboard] multi line chart UI added --- .../dashboard/Widgets/MultiBarChart.ctp | 32 ------ .../dashboard/Widgets/MultiLineChart.ctp | 100 ++++++++++++++++++ app/webroot/css/multi-line-chart.css | 20 ++++ 3 files changed, 120 insertions(+), 32 deletions(-) delete mode 100644 app/View/Elements/dashboard/Widgets/MultiBarChart.ctp create mode 100644 app/View/Elements/dashboard/Widgets/MultiLineChart.ctp create mode 100644 app/webroot/css/multi-line-chart.css diff --git a/app/View/Elements/dashboard/Widgets/MultiBarChart.ctp b/app/View/Elements/dashboard/Widgets/MultiBarChart.ctp deleted file mode 100644 index 93d1472c8..000000000 --- a/app/View/Elements/dashboard/Widgets/MultiBarChart.ctp +++ /dev/null @@ -1,32 +0,0 @@ - - $count) { - $value = $count; - if (!empty($data['logarithmic'])) { - $value = $data['logarithmic'][$entry]; - } - echo sprintf( - '', - 'text-align:right;width:33%;', - h($entry), - 'width:100%', - sprintf( - '
%s
', - h($entry) . ': ' . h($count), - sprintf( - 'background-color:%s; width:%s; color:white; text-align:center;', - (empty($data['colours'][$entry]) ? '#0088cc' : h($data['colours'][$entry])), - 100 * h($value) / $max . '%;' - ), - h($count) - ), - ' ' - ); - } -?> -
%s%s
diff --git a/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp b/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp new file mode 100644 index 000000000..a03955cc3 --- /dev/null +++ b/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp @@ -0,0 +1,100 @@ +Html->script('d3'); + echo $this->Html->css('multi-line-chart'); + $seed = rand(); + if (!empty($data['formula'])) { + echo sprintf( + '
%s
', + h($data['formula']) + ); + } +?> + + diff --git a/app/webroot/css/multi-line-chart.css b/app/webroot/css/multi-line-chart.css new file mode 100644 index 000000000..860b81c02 --- /dev/null +++ b/app/webroot/css/multi-line-chart.css @@ -0,0 +1,20 @@ +path { + stroke-width: 1; + fill: none; + stroke-linejoin: round; + stroke-linecap: round; +} +circle { + stroke-width: 1; +} +.axis path, +.axis line { + fill: none; + stroke: grey; + stroke-width: 1; + shape-rendering: crispEdges; +} +.legend, .label, .hover-text{ + font-size: x-small; + background-color: white; +} From fa0eb43120ebd74518d19450a2068bf895824509 Mon Sep 17 00:00:00 2001 From: iglocska Date: Mon, 16 Mar 2020 13:57:15 +0100 Subject: [PATCH 02/21] fix: [dashboard] css conflict resolved - in a really hacky way for now --- .../dashboard/Widgets/MultiLineChart.ctp | 8 +++----- app/webroot/css/main.css | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp b/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp index a03955cc3..7f8457e1a 100644 --- a/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp +++ b/app/View/Elements/dashboard/Widgets/MultiLineChart.ctp @@ -1,6 +1,5 @@ Html->script('d3'); - echo $this->Html->css('multi-line-chart'); $seed = rand(); if (!empty($data['formula'])) { echo sprintf( @@ -72,12 +71,12 @@ var insight = ""; ]); svg.append("g") - .attr("class", "x axis") + .attr("class", "x axis axis_multi_line_chart") .attr("transform", "translate(0," + height + ")") .call(xAxis); svg.append("g") - .attr("class", "y axis") + .attr("class", "y axis axis_multi_line_chart") .call(yAxis) var data_node = svg.selectAll(".data-node-") @@ -86,7 +85,7 @@ var insight = ""; .attr("class", "data-node-"); data_node.append("path") - .attr("class", "line") + .attr("class", "line path_multi_line_chart") .attr("d", function(d) { return line(d.values); }) .style("stroke", function(d) { return color(d.name); }); @@ -96,5 +95,4 @@ var insight = ""; .attr("x", 3) .attr("dy", ".35em") .text(function(d) { return d.name; }); - diff --git a/app/webroot/css/main.css b/app/webroot/css/main.css index 173bda0e2..8fa21e7b2 100644 --- a/app/webroot/css/main.css +++ b/app/webroot/css/main.css @@ -2523,3 +2523,20 @@ table tr:hover .down-expand-button { font-size: 125%; margin:5px; } + +.path_multi_line_chart { + stroke-width: 1; + fill: none; + stroke-linejoin: round; + stroke-linecap: round; +} +.path_multi_line_chart { + stroke-width: 1; +} +.axis_multi_line_chart path, +.axis_multi_line_chart line { + fill: none; + stroke: grey; + stroke-width: 1; + shape-rendering: crispEdges; +} From 502a68e176617bdd59f50504224c3547e9e140ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 18 Mar 2020 00:37:25 +0100 Subject: [PATCH 03/21] fix: [INSTALL] Properly run tests. Related: #5209 --- docs/generic/supportFunctions.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/generic/supportFunctions.md b/docs/generic/supportFunctions.md index 9ea8719a4..5b480f757 100644 --- a/docs/generic/supportFunctions.md +++ b/docs/generic/supportFunctions.md @@ -833,13 +833,12 @@ genRCLOCAL () { # Run PyMISP tests runTests () { - echo "url = '${MISP_BASEURL}' -key = '${AUTH_KEY}'" |sudo tee ${PATH_TO_MISP}/PyMISP/tests/keys.py + echo "url = \"${MISP_BASEURL}\" +key = \"${AUTH_KEY}\"" |sudo tee ${PATH_TO_MISP}/PyMISP/tests/keys.py sudo chown -R $WWW_USER:$WWW_USER $PATH_TO_MISP/PyMISP/ sudo -H -u $WWW_USER sh -c "cd $PATH_TO_MISP/PyMISP && git submodule foreach git pull origin master" sudo -H -u $WWW_USER ${PATH_TO_MISP}/venv/bin/pip install -e $PATH_TO_MISP/PyMISP/.[fileobjects,neo,openioc,virustotal,pdfexport] - sudo -H -u $WWW_USER git clone https://github.com/viper-framework/viper-test-files.git $PATH_TO_MISP/PyMISP/tests/viper-test-files sudo -H -u $WWW_USER sh -c "cd $PATH_TO_MISP/PyMISP && ${PATH_TO_MISP}/venv/bin/python tests/testlive_comprehensive.py" } From 2d5fd9227519985133fe6486699bb2b4742e8cf0 Mon Sep 17 00:00:00 2001 From: Steve Clement Date: Wed, 18 Mar 2020 13:57:25 +0900 Subject: [PATCH 04/21] fix: [install] Updated installer and checksums --- INSTALL/INSTALL.sh | 5 ++--- INSTALL/INSTALL.sh.sfv | 6 +++--- INSTALL/INSTALL.sh.sha1 | 2 +- INSTALL/INSTALL.sh.sha256 | 2 +- INSTALL/INSTALL.sh.sha384 | 2 +- INSTALL/INSTALL.sh.sha512 | 2 +- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/INSTALL/INSTALL.sh b/INSTALL/INSTALL.sh index 3802235bb..86b3437e5 100644 --- a/INSTALL/INSTALL.sh +++ b/INSTALL/INSTALL.sh @@ -988,13 +988,12 @@ genRCLOCAL () { # Run PyMISP tests runTests () { - echo "url = '${MISP_BASEURL}' -key = '${AUTH_KEY}'" |sudo tee ${PATH_TO_MISP}/PyMISP/tests/keys.py + echo "url = \"${MISP_BASEURL}\" +key = \"${AUTH_KEY}\"" |sudo tee ${PATH_TO_MISP}/PyMISP/tests/keys.py sudo chown -R $WWW_USER:$WWW_USER $PATH_TO_MISP/PyMISP/ sudo -H -u $WWW_USER sh -c "cd $PATH_TO_MISP/PyMISP && git submodule foreach git pull origin master" sudo -H -u $WWW_USER ${PATH_TO_MISP}/venv/bin/pip install -e $PATH_TO_MISP/PyMISP/.[fileobjects,neo,openioc,virustotal,pdfexport] - sudo -H -u $WWW_USER git clone https://github.com/viper-framework/viper-test-files.git $PATH_TO_MISP/PyMISP/tests/viper-test-files sudo -H -u $WWW_USER sh -c "cd $PATH_TO_MISP/PyMISP && ${PATH_TO_MISP}/venv/bin/python tests/testlive_comprehensive.py" } diff --git a/INSTALL/INSTALL.sh.sfv b/INSTALL/INSTALL.sh.sfv index d4ee7513a..e578da42c 100644 --- a/INSTALL/INSTALL.sh.sfv +++ b/INSTALL/INSTALL.sh.sfv @@ -1,5 +1,5 @@ -; Generated by RHash v1.3.9 on 2020-03-10 at 18:43.24 +; Generated by RHash v1.3.9 on 2020-03-18 at 13:56.48 ; Written by Kravchenko Aleksey (Akademgorodok) - http://rhash.sf.net/ ; -; 100109 18:43.24 2020-03-10 INSTALL.sh -INSTALL.sh 68CED66FC4D5C4A7F0041BF7DAC60113FAB614E5 5DFCF61AEB56A736930EE8A77959BD90C2F8AD6AD11CD1B09AB60D1E68D18BD0 D03AECC77CF64A90DA971C562EB49C373954151B712966EF6482F6E032F992B568BB8E0C2FF3EAFB300DB7BF768796E4 3981E487FD3C4822F353232ABFB8A017E299702E1E5B1D75A2DC901D6CC8CF356F848CA944FBD04A25E9CA459645FDC5F03D2AA08A31C471F40E8AABEF01A0EF +; 99980 13:56.48 2020-03-18 INSTALL.sh +INSTALL.sh 04A834FCD3BC9DA5282EDE8A3D2C459FBC625E46 FBCA1473FEC26AD5A6C1AE6AE3D9AF11E47E7758F30B160BC047ABE9978F4476 7281B13AA7D6B016152096D35619C2CECC7EC49F8F41CF8A3B8284335D950D35F273FA56FEA63EC5ADB3669038239C61 FA17DF3AA0CBC54D2B48AE14FB296C91C12FC6CF8E3704B8AF1B2CB2CDE9C6FAF591A2E42A38C01C299C62390868E7766EF682A6B3B556BAFC469688E8AED6E7 diff --git a/INSTALL/INSTALL.sh.sha1 b/INSTALL/INSTALL.sh.sha1 index 64518e70c..ec7c207fa 100644 --- a/INSTALL/INSTALL.sh.sha1 +++ b/INSTALL/INSTALL.sh.sha1 @@ -1 +1 @@ -68ced66fc4d5c4a7f0041bf7dac60113fab614e5 INSTALL.sh +04a834fcd3bc9da5282ede8a3d2c459fbc625e46 INSTALL.sh diff --git a/INSTALL/INSTALL.sh.sha256 b/INSTALL/INSTALL.sh.sha256 index a49ca79a4..1f4397bb7 100644 --- a/INSTALL/INSTALL.sh.sha256 +++ b/INSTALL/INSTALL.sh.sha256 @@ -1 +1 @@ -5dfcf61aeb56a736930ee8a77959bd90c2f8ad6ad11cd1b09ab60d1e68d18bd0 INSTALL.sh +fbca1473fec26ad5a6c1ae6ae3d9af11e47e7758f30b160bc047abe9978f4476 INSTALL.sh diff --git a/INSTALL/INSTALL.sh.sha384 b/INSTALL/INSTALL.sh.sha384 index 33edb6640..36c9ec1e1 100644 --- a/INSTALL/INSTALL.sh.sha384 +++ b/INSTALL/INSTALL.sh.sha384 @@ -1 +1 @@ -d03aecc77cf64a90da971c562eb49c373954151b712966ef6482f6e032f992b568bb8e0c2ff3eafb300db7bf768796e4 INSTALL.sh +7281b13aa7d6b016152096d35619c2cecc7ec49f8f41cf8a3b8284335d950d35f273fa56fea63ec5adb3669038239c61 INSTALL.sh diff --git a/INSTALL/INSTALL.sh.sha512 b/INSTALL/INSTALL.sh.sha512 index 107740845..0c79ff282 100644 --- a/INSTALL/INSTALL.sh.sha512 +++ b/INSTALL/INSTALL.sh.sha512 @@ -1 +1 @@ -3981e487fd3c4822f353232abfb8a017e299702e1e5b1d75a2dc901d6cc8cf356f848ca944fbd04a25e9ca459645fdc5f03d2aa08a31c471f40e8aabef01a0ef INSTALL.sh +fa17df3aa0cbc54d2b48ae14fb296c91c12fc6cf8e3704b8af1b2cb2cde9c6faf591a2e42a38c01c299c62390868e7766ef682a6b3b556bafc469688e8aed6e7 INSTALL.sh From c8a111447c52c631218d1928bcc101ec04bf4336 Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 19 Mar 2020 09:16:10 +0100 Subject: [PATCH 05/21] fix: [suricata] fixed an invalid validation of https hostnames that blocked the attributes from being included in the exports --- app/Lib/Export/NidsSuricataExport.php | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/app/Lib/Export/NidsSuricataExport.php b/app/Lib/Export/NidsSuricataExport.php index 6f88b78ff..76631200d 100644 --- a/app/Lib/Export/NidsSuricataExport.php +++ b/app/Lib/Export/NidsSuricataExport.php @@ -109,7 +109,6 @@ class NidsSuricataExport extends NidsExport $data['host'] = ''; } } - switch ($scheme) { case "http": $data['host'] = NidsExport::replaceIllegalChars($data['host']); @@ -126,26 +125,18 @@ class NidsSuricataExport extends NidsExport } else { $content = 'flow:to_server,established; content:"' . $data['host'] . '"; fast_pattern; nocase; http_header; content:"' . $data['path'] . '"; nocase; http_uri;'; } - break; case "https": $data['host'] = NidsExport::replaceIllegalChars($data['host']); $tag = 'tag:session,600,seconds;'; - # IP: classic IP rule for HTTPS - if (filter_var($data['host'], FILTER_VALIDATE_IP)) { - $suricata_protocol = 'tcp'; - $suricata_src_ip = '$HOME_NET'; - $suricata_src_port = 'any'; - $suricata_dst_ip = $data['host']; - $suricata_dst_port = NidsExport::getProtocolPort($scheme, $data['port']); - $content = 'flow:to_server; app-layer-protocol:tls;'; - } - # Domain: rule on https certificate subject - else { - $createRule = false; - } + $suricata_protocol = 'tcp'; + $suricata_src_ip = '$HOME_NET'; + $suricata_src_port = 'any'; + $suricata_dst_ip = $data['host']; + $suricata_dst_port = NidsExport::getProtocolPort($scheme, $data['port']); + $content = 'flow:to_server; app-layer-protocol:tls;'; break; case "ssh": @@ -196,7 +187,6 @@ class NidsSuricataExport extends NidsExport break; } - if ($createRule) { $attribute['value'] = NidsExport::replaceIllegalChars($attribute['value']); // substitute chars not allowed in rule $this->rules[] = sprintf( From e5d775e9c83318ad7f9507dad38255e9fed37f1e Mon Sep 17 00:00:00 2001 From: iglocska Date: Thu, 19 Mar 2020 11:08:09 +0100 Subject: [PATCH 06/21] fix: [message] user creation shouldn't include the "User notified of new credentials" part of the notification mesage if emailing is disabled --- app/Controller/UsersController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Controller/UsersController.php b/app/Controller/UsersController.php index 5516c075c..08fbd0677 100644 --- a/app/Controller/UsersController.php +++ b/app/Controller/UsersController.php @@ -723,7 +723,7 @@ class UsersController extends AppController $user = $this->User->find('first', array('conditions' => array('User.id' => $this->User->id), 'recursive' => -1)); $password = isset($this->request->data['User']['password']) ? $this->request->data['User']['password'] : false; $result = $this->User->initiatePasswordReset($user, true, true, $password); - if ($result) { + if ($result && empty(Configure::read('MISP.disable_emailing'))) { $notification_message .= ' User notified of new credentials.'; } } From f9ae0bef4876416260c5f27fca2b1b5da28b4821 Mon Sep 17 00:00:00 2001 From: mokaddem Date: Thu, 19 Mar 2020 14:05:37 +0100 Subject: [PATCH 07/21] chg: [widgets] Added support of scoped CSS --- app/View/Dashboards/widget_loader.ctp | 45 +++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/app/View/Dashboards/widget_loader.ctp b/app/View/Dashboards/widget_loader.ctp index c71696853..592359fd9 100644 --- a/app/View/Dashboards/widget_loader.ctp +++ b/app/View/Dashboards/widget_loader.ctp @@ -1,6 +1,47 @@ -
+ $line) { + if (strlen($line) > 0) { + if (endsWith($line, "{")) { + $cssLines[$i] = sprintf("%s %s", $prependSelector, $line); + } + } + } + $cssScopedLines = implode(PHP_EOL, $cssLines); + return sprintf("", PHP_EOL, $cssScopedLines, PHP_EOL); + } + + $widgetHtml = $this->element('/dashboard/Widgets/' . $config['render']); + $widgetCSS = ""; + $seed = ""; + $styleTag = ""; + $styleTagIndex = strpos($widgetHtml, $styleTag); + $closingStyleTagIndex = strpos($widgetHtml, $styleClosingTag) + strlen($styleClosingTag); + if ($styleTagIndex !== false && $closingStyleTagIndex !== false && $closingStyleTagIndex > $styleTagIndex) { // enforced scoped css + $seed = rand(); + $widgetCSS = substr($widgetHtml, $styleTagIndex, $closingStyleTagIndex); + $widgetHtml = str_replace($widgetCSS, "", $widgetHtml); // remove CSS + $widgetCSS = str_replace($styleTag, "", $widgetCSS); // remove the style node + $widgetCSS = str_replace($styleClosingTag, "", $widgetCSS); // remove closing style node + $widgetCSS = preppendScopedId($widgetCSS, $seed); + } +?> +
> element('/dashboard/Widgets/' . $config['render']); + echo $widgetHtml; + echo $widgetCSS; ?>
+ + diff --git a/app/View/Helper/ScopedCSSHelper.php b/app/View/Helper/ScopedCSSHelper.php index e575e3372..6311f5687 100644 --- a/app/View/Helper/ScopedCSSHelper.php +++ b/app/View/Helper/ScopedCSSHelper.php @@ -19,7 +19,7 @@ App::uses('AppHelper', 'View/Helper'); $cssLines = explode("\n", $css); foreach ($cssLines as $i => $line) { if (strlen($line) > 0) { - if (endsWith($line, "{")) { + if ($this->endsWith($line, "{") || $this->endsWith($line, ",")) { $cssLines[$i] = sprintf("%s %s", $prependSelector, $line); } } @@ -32,7 +32,7 @@ App::uses('AppHelper', 'View/Helper'); { $css = ""; $seed = ""; - $htmlStyleTag = ""; $styleTagIndex = strpos($html, $htmlStyleTag); $closingStyleTagIndex = strpos($html, $styleClosingTag) + strlen($styleClosingTag); @@ -42,7 +42,7 @@ App::uses('AppHelper', 'View/Helper'); $html = str_replace($css, "", $html); // remove CSS part $css = str_replace($htmlStyleTag, "", $css); // remove the style node $css = str_replace($styleClosingTag, "", $css); // remove closing style node - $css = preppendScopedId($css, $seed); + $css = $this->preppendScopedId($css, $seed); } return array( "seed" => $seed, diff --git a/app/webroot/css/main.css b/app/webroot/css/main.css index 8fa21e7b2..173bda0e2 100644 --- a/app/webroot/css/main.css +++ b/app/webroot/css/main.css @@ -2523,20 +2523,3 @@ table tr:hover .down-expand-button { font-size: 125%; margin:5px; } - -.path_multi_line_chart { - stroke-width: 1; - fill: none; - stroke-linejoin: round; - stroke-linecap: round; -} -.path_multi_line_chart { - stroke-width: 1; -} -.axis_multi_line_chart path, -.axis_multi_line_chart line { - fill: none; - stroke: grey; - stroke-width: 1; - shape-rendering: crispEdges; -} From ac678e7e48d379351229323122047d92c174a9ec Mon Sep 17 00:00:00 2001 From: mokaddem Date: Fri, 20 Mar 2020 08:27:22 +0100 Subject: [PATCH 11/21] chg: [scopedCSS] Simplified usage and added documentation --- app/View/Dashboards/widget_loader.ctp | 10 +++------ app/View/Helper/ScopedCSSHelper.php | 31 +++++++++++++++++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/app/View/Dashboards/widget_loader.ctp b/app/View/Dashboards/widget_loader.ctp index dbb70e324..103bebd9a 100644 --- a/app/View/Dashboards/widget_loader.ctp +++ b/app/View/Dashboards/widget_loader.ctp @@ -1,14 +1,10 @@ element('/dashboard/Widgets/' . $config['render']); - $result = $this->ScopedCSS->createScopedCSS($widgetHtml); - $seed = $result['seed']; - $widgetHtml = $result['html']; - $widgetCSS = $result['css']; + $scopedHtml = $this->ScopedCSS->createScopedCSS($widgetHtml); ?> -
> +