diff --git a/index.js b/index.js index 81ac446..ceadaa5 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ const helper = require("./helpers.js"); const loggy = require("./logging") const Eta = require("eta"); const _ = require("underscore") +const path = require("path") loggy.init(true) @@ -24,6 +25,26 @@ app.use( }) ); +// Allowed urls for requests to /assets/ +const allowsURLs = [ + 'bootstrap-icons/font/bootstrap-icons.css', + 'js-cookie/dist/js.cookie.min.js', + 'bootstrap/dist/css/bootstrap.min.css', + 'mdbootstrap/css/style.css', + 'bootstrap/dist/js/bootstrap.bundle.min.js', + 'jquery/dist/jquery.min.js', + 'darkreader/darkreader.js', + 'bootstrap-duration-picker/dist/bootstrap-duration-picker.css', + 'flatpickr/dist/flatpickr.min.css', + 'bootstrap-duration-picker/dist/bootstrap-duration-picker-debug.js', + 'flatpickr/dist/flatpickr.js', + 'bootstrap-icons/font/fonts/bootstrap-icons.woff2', + 'bootstrap/dist/css/bootstrap.min.css.map', + 'less/dist/less.min.js', + 'less/dist/less.min.js.map', + 'mdbootstrap/js/mdb.min.js' +]; + let loadedData = {} loggy.log("Loading config", "info", "Config"); @@ -391,6 +412,16 @@ app.get("/api/ui/v1/lang/set", function (req, res) { }); +app.use("/assets/*", function handleModuleFiles(req, res) { + if(allowsURLs.indexOf(req.params[0]) > -1){ + res.sendFile(path.join(__dirname, "node_modules", req.params[0])); + } else { + loggy.log("Attempt to access restricted asset file " + req.params[0], "error", "Security") + res.status(403).json({ status: "error", reason: "Access to restricted asset file denied" }); + } + // console.log(recordedURLs) +}) + app.use(function (req, res, next) { res.status(404); loggy.log("Server responded with 404 error", "warn", "Server", true); @@ -415,6 +446,8 @@ app.use(function (req, res, next) { + + /*app.use(function(err, req, res, next) { console.error(err.stack); if(String(err.stack).includes("TypeError: Cannot read properties of undefined")) { diff --git a/log-journal.json b/log-journal.json index 9005d23..f20cc2a 100644 --- a/log-journal.json +++ b/log-journal.json @@ -1 +1 @@ -[{"timestamp":"2022-07-23 12:23:17.692","level":"info","module":"Logging","message":"2022-07-23 12:23:17.692 [info] [Logging] Logging initialized"},{"timestamp":"2022-07-23 12:23:17.694","level":"info","module":"Server","message":"2022-07-23 12:23:17.694 [info] [Server] Preparing server"},{"timestamp":"2022-07-23 12:23:17.695","level":"info","module":"Server","message":"2022-07-23 12:23:17.695 [info] [Server] Preparing static routes"},{"timestamp":"2022-07-23 12:23:17.696","level":"info","module":"Server","message":"2022-07-23 12:23:17.696 [info] [Server] Preparing middlewares"},{"timestamp":"2022-07-23 12:23:17.696","level":"info","module":"Config","message":"2022-07-23 12:23:17.696 [info] [Config] Loading config"},{"timestamp":"2022-07-23 12:23:17.698","level":"info","module":"Language","message":"2022-07-23 12:23:17.698 [info] [Language] Searching for languages"},{"timestamp":"2022-07-23 12:23:17.699","level":"info","module":"Language","message":"2022-07-23 12:23:17.699 [info] [Language] Found 3 languages"},{"timestamp":"2022-07-23 12:23:17.699","level":"info","module":"Language","message":"2022-07-23 12:23:17.699 [info] [Language] Reading language file"},{"timestamp":"2022-07-23 12:23:17.699","level":"info","module":"Websocket","message":"2022-07-23 12:23:17.699 [info] [Websocket] Preparing websocket"},{"timestamp":"2022-07-23 12:23:17.700","level":"info","module":"Server","message":"2022-07-23 12:23:17.700 [info] [Server] Preparing routes"},{"timestamp":"2022-07-23 12:23:17.701","level":"info","module":"Server","message":"2022-07-23 12:23:17.701 [info] [Server] Starting server"},{"timestamp":"2022-07-23 13:34:09.137","level":"info","module":"Shutdown","message":"2022-07-23 13:34:09.137 [info] [Shutdown] Caught interrupt signal and shutting down gracefully"}] \ No newline at end of file +[{"timestamp":"2022-08-18 16:11:01.607","level":"info","module":"Logging","message":"2022-08-18 16:11:01.607 [info] [Logging] Logging initialized"},{"timestamp":"2022-08-18 16:11:01.608","level":"info","module":"Server","message":"2022-08-18 16:11:01.608 [info] [Server] Preparing server"},{"timestamp":"2022-08-18 16:11:01.609","level":"info","module":"Server","message":"2022-08-18 16:11:01.609 [info] [Server] Preparing static routes"},{"timestamp":"2022-08-18 16:11:01.610","level":"info","module":"Server","message":"2022-08-18 16:11:01.610 [info] [Server] Preparing middlewares"},{"timestamp":"2022-08-18 16:11:01.611","level":"info","module":"Config","message":"2022-08-18 16:11:01.611 [info] [Config] Loading config"},{"timestamp":"2022-08-18 16:11:01.612","level":"info","module":"Language","message":"2022-08-18 16:11:01.612 [info] [Language] Searching for languages"},{"timestamp":"2022-08-18 16:11:01.612","level":"info","module":"Language","message":"2022-08-18 16:11:01.612 [info] [Language] Found 3 languages"},{"timestamp":"2022-08-18 16:11:01.612","level":"info","module":"Language","message":"2022-08-18 16:11:01.612 [info] [Language] Reading language file"},{"timestamp":"2022-08-18 16:11:01.612","level":"info","module":"Websocket","message":"2022-08-18 16:11:01.612 [info] [Websocket] Preparing websocket"},{"timestamp":"2022-08-18 16:11:01.613","level":"info","module":"Server","message":"2022-08-18 16:11:01.613 [info] [Server] Preparing routes"},{"timestamp":"2022-08-18 16:11:01.614","level":"info","module":"Server","message":"2022-08-18 16:11:01.614 [info] [Server] Starting server"},{"timestamp":"2022-08-18 16:13:27.222","level":"error","module":"Security","message":"2022-08-18 16:13:27.222 [error] [Security] Attempt to access restricted asset file mdbootstrap/js/mdb.min.js"},{"timestamp":"2022-08-18 16:13:27.674","level":"error","module":"Security","message":"2022-08-18 16:13:27.674 [error] [Security] Attempt to access restricted asset file mdbootstrap/js/mdb.min.js"},{"timestamp":"2022-08-18 16:13:46.931","level":"info","module":"Shutdown","message":"2022-08-18 16:13:46.931 [info] [Shutdown] Caught interrupt signal and shutting down gracefully"}] \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9c669c4..ed9888b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "opencountdown", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "opencountdown", - "version": "1.0.1", + "version": "1.0.2", "license": "LGPL-3.0", "dependencies": { "body-parser": "^1.19.2", diff --git a/static/bootstrap-duration-picker b/static/bootstrap-duration-picker deleted file mode 120000 index 3b83664..0000000 --- a/static/bootstrap-duration-picker +++ /dev/null @@ -1 +0,0 @@ -../node_modules/bootstrap-duration-picker/dist/ \ No newline at end of file diff --git a/static/bootstrap/dist b/static/bootstrap/dist deleted file mode 120000 index 8fc3423..0000000 --- a/static/bootstrap/dist +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/bootstrap/dist \ No newline at end of file diff --git a/static/colorpicker/css b/static/colorpicker/css deleted file mode 120000 index 3cf966e..0000000 --- a/static/colorpicker/css +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/bootstrap-colorpicker/dist/css \ No newline at end of file diff --git a/static/colorpicker/js b/static/colorpicker/js deleted file mode 120000 index cc23749..0000000 --- a/static/colorpicker/js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/bootstrap-colorpicker/dist/js \ No newline at end of file diff --git a/static/css/bootstrap-icons.css b/static/css/bootstrap-icons.css deleted file mode 120000 index 996baca..0000000 --- a/static/css/bootstrap-icons.css +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/bootstrap-icons/font/bootstrap-icons.css \ No newline at end of file diff --git a/static/css/fonts/bootstrap-icons.woff b/static/css/fonts/bootstrap-icons.woff deleted file mode 120000 index 6a1958f..0000000 --- a/static/css/fonts/bootstrap-icons.woff +++ /dev/null @@ -1 +0,0 @@ -../../../node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff \ No newline at end of file diff --git a/static/css/fonts/bootstrap-icons.woff2 b/static/css/fonts/bootstrap-icons.woff2 deleted file mode 120000 index 90ff4c9..0000000 --- a/static/css/fonts/bootstrap-icons.woff2 +++ /dev/null @@ -1 +0,0 @@ -../../../node_modules/bootstrap-icons/font/fonts/bootstrap-icons.woff2 \ No newline at end of file diff --git a/static/flatpickr/dist b/static/flatpickr/dist deleted file mode 120000 index 9c148d9..0000000 --- a/static/flatpickr/dist +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/flatpickr/dist/ \ No newline at end of file diff --git a/static/js/cookie.js b/static/js/cookie.js deleted file mode 120000 index 9097170..0000000 --- a/static/js/cookie.js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/js-cookie/dist/js.cookie.min.js \ No newline at end of file diff --git a/static/js/darkreader.js b/static/js/darkreader.js deleted file mode 120000 index f810896..0000000 --- a/static/js/darkreader.js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/darkreader/darkreader.js \ No newline at end of file diff --git a/static/js/jquery.min.js b/static/js/jquery.min.js deleted file mode 120000 index 08ac9f2..0000000 --- a/static/js/jquery.min.js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/jquery/dist/jquery.min.js \ No newline at end of file diff --git a/static/js/less.min.js b/static/js/less.min.js deleted file mode 120000 index 9ac4459..0000000 --- a/static/js/less.min.js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/less/dist/less.min.js \ No newline at end of file diff --git a/static/mdbootstrap/css b/static/mdbootstrap/css deleted file mode 120000 index 5ada75b..0000000 --- a/static/mdbootstrap/css +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/mdbootstrap/css/ \ No newline at end of file diff --git a/static/mdbootstrap/js b/static/mdbootstrap/js deleted file mode 120000 index 6a0f520..0000000 --- a/static/mdbootstrap/js +++ /dev/null @@ -1 +0,0 @@ -../../node_modules/mdbootstrap/js \ No newline at end of file diff --git a/templates/brokenTranslation.html b/templates/brokenTranslation.html index ee0cc76..ca58dd2 100644 --- a/templates/brokenTranslation.html +++ b/templates/brokenTranslation.html @@ -10,26 +10,27 @@ - - + + - - + + - - + + - - - + + + - + - + +
@@ -115,17 +116,9 @@ - + - + + @@ -19,11 +19,9 @@ javascriptEnabled: true }; - + - - diff --git a/templates/newAdminPanel.html b/templates/newAdminPanel.html index bf43948..2c9b6c9 100644 --- a/templates/newAdminPanel.html +++ b/templates/newAdminPanel.html @@ -10,28 +10,27 @@ - - + + - - - + + + - - - + + + - - - + + + - + - - + @@ -429,7 +428,7 @@ - +