diff --git a/backend/internal/openappsec-log.js b/backend/internal/openappsec-log.js
index 22def5c3..74a23adc 100755
--- a/backend/internal/openappsec-log.js
+++ b/backend/internal/openappsec-log.js
@@ -6,86 +6,6 @@ const { APPSEC_LOG_DIR } = require('../lib/constants');
const internalOpenappsecLog = {
- /**
- * All logs
- *
- * @param {Access} access
- * @param {Array} [expand]
- * @param {String} [search_query]
- * @returns {Promise}
- */
- getAllold: (access, expand, search_query) => {
- return access.can('auditlog:list')
- .then(() => {
-
- const directoryPath = APPSEC_LOG_DIR;
-
- const readdir = util.promisify(fs.readdir);
- const readFile = util.promisify(fs.readFile);
-
- async function listLogFiles(dir) {
- const files = await readdir(dir);
- const logFiles = files.filter(file => path.extname(file).startsWith('.log'));
-
- const sortedLogFiles = logFiles.sort((a, b) => {
- const baseA = path.basename(a, path.extname(a));
- const baseB = path.basename(b, path.extname(b));
-
- if (baseA < baseB) return -1;
- if (baseA > baseB) return 1;
-
- return path.extname(a).localeCompare(path.extname(b));
- });
-
- // Group the log files by their base name
- const groupedFiles = sortedLogFiles.reduce((groups, file) => {
- const fileName = path.basename(file, path.extname(file));
- if (!groups[fileName]) {
- groups[fileName] = [];
- }
- groups[fileName].push(file);
- return groups;
- }, {});
-
- const wrappedObjects = [];
-
- for (const [groupName, files] of Object.entries(groupedFiles)) {
- for (const file of files) {
- try {
- const content = await readFile(path.join(dir, file), 'utf8');
- const lines = content.split('\n');
- for (const line of lines) {
- try {
- const json = JSON.parse(line);
- const wrappedObject = {
- source: groupName,
- meta: json,
- serviceName: json.eventSource.serviceName,
- eventPriority: json.eventPriority,
- eventSeverity: json.eventSeverity,
- eventLevel: json.eventLevel,
- eventTime: json.eventTime,
- eventName: json.eventName
- };
- wrappedObjects.push(wrappedObject);
- } catch (err) {
- // Ignore lines that don't contain JSON data
- }
- }
- } catch (err) {
- console.error(`Failed to read file ${file}: ${err.message}`);
- }
- }
- }
- wrappedObjects.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime));
- return wrappedObjects;
- }
-
- let groupedFiles = listLogFiles(directoryPath).catch(console.error);
- return groupedFiles;
- });
- },
-
countTotalLines: async function (directoryPath) {
const files = await fs.promises.readdir(directoryPath);
const logFiles = files.filter(file => path.extname(file).startsWith('.log'));
@@ -153,7 +73,7 @@ const internalOpenappsecLog = {
getAll: function (access, expand, search_query) {
return access.can('auditlog:list')
.then(async () => {
- const directoryPath = '/app/openappsec_files/logs';
+ const directoryPath = APPSEC_LOG_DIR;
const files = await fs.promises.readdir(directoryPath);
const logFiles = files.filter(file => path.extname(file).startsWith('.log'));
@@ -175,12 +95,10 @@ const internalOpenappsecLog = {
});
},
-
getPage: function (access, expand, search_query, page, perPage) {
return access.can('auditlog:list')
.then(async () => {
- const directoryPath = '/app/openappsec_files/logs';
-
+ const directoryPath = APPSEC_LOG_DIR;
let totalDataLines = await this.countTotalLines(directoryPath);
console.log("totalLineCount: " + totalDataLines);
diff --git a/frontend/js/app/openappsec-log/list-all/item.ejs b/frontend/js/app/openappsec-log/list-all/item.ejs
new file mode 100644
index 00000000..ecc0214c
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-all/item.ejs
@@ -0,0 +1,43 @@
+
+
+ <%- formatDbDate(eventTime, 'D-M-YYYY, H:mm') %>
+ |
+
+
+ <% var sevirityClass = 'bg-success';
+ switch (eventSeverity) {
+ case 'Critical':
+ sevirityClass = 'bg-danger';
+ break;
+ case 'Warning':
+ sevirityClass = 'bg-warning';
+ break;
+ case 'Info':
+ sevirityClass = 'bg-success';
+ //sevirityClass = 'bg-info';
+ break;
+ case 'Debug':
+ sevirityClass = 'bg-success';
+ break;
+ }
+ %>
+ <%- eventSeverity %>
+
+ |
+<%- assetName %> |
+<%- securityAction %> |
+<%- waapIncidentType %> |
+<%- httpSourceId %> |
+<%- sourceIp %> |
+<%- proxyIp %> |
+<%- httpHostName %> |
+<%- httpMethod %> |
+<%- httpResponseCode %> |
+<%- httpUriPath %> |
+<%- protectionName %> |
+<%- matchedLocation %> |
+<%- matchedParameter %> |
+<%- matchedSample %> |
+
+ open
+ |
diff --git a/frontend/js/app/openappsec-log/list-all/item.js b/frontend/js/app/openappsec-log/list-all/item.js
new file mode 100644
index 00000000..009e3a3e
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-all/item.js
@@ -0,0 +1,32 @@
+const Mn = require('backbone.marionette');
+const Controller = require('../../controller');
+const template = require('./item.ejs');
+
+module.exports = Mn.View.extend({
+ template: template,
+ tagName: 'tr',
+
+ ui: {
+ meta: 'a.meta'
+ },
+
+ events: {
+ 'click @ui.meta': function (e) {
+ e.preventDefault();
+ Controller.showOpenappsecMeta(this.model);
+ }
+ },
+
+ templateContext: {
+ more: function() {
+ switch (this.object_type) {
+ case 'redirection-host':
+ case 'stream':
+ case 'proxy-host':
+ return this.meta.domain_names.join(', ');
+ }
+
+ return '#' + (this.object_id || '?');
+ }
+ }
+});
diff --git a/frontend/js/app/openappsec-log/list-all/main.ejs b/frontend/js/app/openappsec-log/list-all/main.ejs
new file mode 100644
index 00000000..184cddd4
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-all/main.ejs
@@ -0,0 +1,22 @@
+
+ Time |
+ Event Severity |
+ Asset Name |
+ Security Action |
+ AppSec Incident Type |
+ Source Identifier |
+ Source IP |
+ Proxy IP |
+ HTTP Host |
+ HTTP Method |
+ HTTP Response Code |
+ HTTP URI Path |
+ Protection Name |
+ Matched Location |
+ Matched Parameter |
+ Matched Sample |
+ |
+
+
+
+
diff --git a/frontend/js/app/openappsec-log/list-all/main.js b/frontend/js/app/openappsec-log/list-all/main.js
new file mode 100644
index 00000000..777d2db7
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-all/main.js
@@ -0,0 +1,60 @@
+const Mn = require('backbone.marionette');
+const ItemView = require('./item');
+const template = require('./main.ejs');
+
+let TableBody = Mn.CollectionView.extend({
+ tagName: 'tbody',
+ childView: ItemView,
+
+ initialize: function (options) {
+ this.options = new Backbone.Model(options);
+ console.log("options: ", options);
+ // this.page = options.page;
+ // this.perPage = options.perPage;
+ this.updatePage();
+ // this.listenTo(this.options, 'change:page', this.updatePage);
+ },
+
+ updatePage: function () {
+ let perPage = this.perPage || this.collection.length;
+ let page = this.page || 1;
+ let models;
+ if (this.perPage && this.page) {
+ console.log('updatePage2');
+ models = this.collection.models.slice((page - 1) * perPage, page * perPage);
+ } else {
+ console.log('updatePage3');
+
+ models = this.collection.models;
+ }
+ this.collection.reset(models);
+ }
+
+ // updatePage: function () {
+ // let perPage = this.perPage || this.collection.length;
+ // let page = this.page || 1;
+ // let models = this.collection.models.slice((page - 1) * perPage, page * perPage);
+ // this.collection.reset(models);
+ // }
+});
+
+module.exports = Mn.View.extend({
+ tagName: 'table',
+ className: 'table table-hover table-outline table-vcenter card-table',
+ template: template,
+
+ regions: {
+ body: {
+ el: 'tbody',
+ replaceElement: true
+ }
+ },
+
+ onRender: function () {
+ this.showChildView('body', new TableBody({
+ collection: this.collection,
+ // page: this.options.page,
+ // perPage: this.options.perPage
+ }));
+ }
+});
diff --git a/frontend/js/app/openappsec-log/list-important/item.ejs b/frontend/js/app/openappsec-log/list-important/item.ejs
new file mode 100644
index 00000000..5537babb
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-important/item.ejs
@@ -0,0 +1,43 @@
+
+
+ <%- formatDbDate(eventTime, 'D-M-YY, H:mm') %>
+ |
+
+
+ <% var sevirityClass = 'bg-success';
+ switch (eventSeverity) {
+ case 'Critical':
+ sevirityClass = 'bg-danger';
+ break;
+ case 'Warning':
+ sevirityClass = 'bg-warning';
+ break;
+ case 'Info':
+ sevirityClass = 'bg-success';
+ //sevirityClass = 'bg-info';
+ break;
+ case 'Debug':
+ sevirityClass = 'bg-success';
+ break;
+ }
+ %>
+ <%- eventSeverity %>
+
+ |
+<%- assetName %> |
+<%- securityAction %> |
+<%- waapIncidentType %> |
+<%- httpSourceId %> |
+<%- sourceIp %> |
+<%- proxyIp %> |
+<%- httpHostName %> |
+<%- httpMethod %> |
+<%- httpResponseCode %> |
+<%- httpUriPath %> |
+<%- protectionName %> |
+<%- matchedLocation %> |
+<%- matchedParameter %> |
+<%- matchedSample %> |
+
+ open
+ |
diff --git a/frontend/js/app/openappsec-log/list-important/item.js b/frontend/js/app/openappsec-log/list-important/item.js
new file mode 100644
index 00000000..009e3a3e
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-important/item.js
@@ -0,0 +1,32 @@
+const Mn = require('backbone.marionette');
+const Controller = require('../../controller');
+const template = require('./item.ejs');
+
+module.exports = Mn.View.extend({
+ template: template,
+ tagName: 'tr',
+
+ ui: {
+ meta: 'a.meta'
+ },
+
+ events: {
+ 'click @ui.meta': function (e) {
+ e.preventDefault();
+ Controller.showOpenappsecMeta(this.model);
+ }
+ },
+
+ templateContext: {
+ more: function() {
+ switch (this.object_type) {
+ case 'redirection-host':
+ case 'stream':
+ case 'proxy-host':
+ return this.meta.domain_names.join(', ');
+ }
+
+ return '#' + (this.object_id || '?');
+ }
+ }
+});
diff --git a/frontend/js/app/openappsec-log/list-important/main.ejs b/frontend/js/app/openappsec-log/list-important/main.ejs
new file mode 100644
index 00000000..184cddd4
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-important/main.ejs
@@ -0,0 +1,22 @@
+
+ Time |
+ Event Severity |
+ Asset Name |
+ Security Action |
+ AppSec Incident Type |
+ Source Identifier |
+ Source IP |
+ Proxy IP |
+ HTTP Host |
+ HTTP Method |
+ HTTP Response Code |
+ HTTP URI Path |
+ Protection Name |
+ Matched Location |
+ Matched Parameter |
+ Matched Sample |
+ |
+
+
+
+
diff --git a/frontend/js/app/openappsec-log/list-important/main.js b/frontend/js/app/openappsec-log/list-important/main.js
new file mode 100644
index 00000000..0c90551b
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-important/main.js
@@ -0,0 +1,43 @@
+const Mn = require('backbone.marionette');
+const ItemView = require('./item');
+const template = require('./main.ejs');
+
+let TableBody = Mn.CollectionView.extend({
+ tagName: 'tbody',
+ childView: ItemView,
+
+ initialize: function (options) {
+ this.options = new Backbone.Model(options);
+ this.page = options.page;
+ this.perPage = options.perPage;
+ this.updatePage();
+ this.listenTo(this.options, 'change:page', this.updatePage);
+ },
+
+ updatePage: function () {
+ console.log('updatePage');
+ let models = this.collection.models.slice((this.page - 1) * this.perPage, this.page * this.perPage);
+ this.collection.reset(models);
+ }
+});
+
+module.exports = Mn.View.extend({
+ tagName: 'table',
+ className: 'table table-hover table-outline table-vcenter card-table',
+ template: template,
+
+ regions: {
+ body: {
+ el: 'tbody',
+ replaceElement: true
+ }
+ },
+
+ onRender: function () {
+ this.showChildView('body', new TableBody({
+ collection: this.collection,
+ page: this.options.page,
+ perPage: this.options.perPage
+ }));
+ }
+});
diff --git a/frontend/js/app/openappsec-log/list-notifications/item.ejs b/frontend/js/app/openappsec-log/list-notifications/item.ejs
new file mode 100644
index 00000000..e901a23e
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-notifications/item.ejs
@@ -0,0 +1,32 @@
+
+<%- formatDbDate(eventTime, 'D-M-YY, H:mm') %> |
+
+
+ <% var sevirityClass = 'bg-success';
+ switch (eventSeverity) {
+ case 'Critical':
+ sevirityClass = 'bg-danger';
+ break;
+ case 'Warning':
+ sevirityClass = 'bg-warning';
+ break;
+ case 'Info':
+ sevirityClass = 'bg-success';
+ //sevirityClass = 'bg-info';
+ break;
+ case 'Debug':
+ sevirityClass = 'bg-success';
+ break;
+ }
+ %>
+ <%- eventSeverity %>
+
+ |
+<%- eventPriority %> |
+<%- eventTopic %> |
+<%- eventName %> |
+<%- suggestedRemediation %> |
+<%- assetName %> |
+
+ open
+ |
diff --git a/frontend/js/app/openappsec-log/list-notifications/item.js b/frontend/js/app/openappsec-log/list-notifications/item.js
new file mode 100644
index 00000000..009e3a3e
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-notifications/item.js
@@ -0,0 +1,32 @@
+const Mn = require('backbone.marionette');
+const Controller = require('../../controller');
+const template = require('./item.ejs');
+
+module.exports = Mn.View.extend({
+ template: template,
+ tagName: 'tr',
+
+ ui: {
+ meta: 'a.meta'
+ },
+
+ events: {
+ 'click @ui.meta': function (e) {
+ e.preventDefault();
+ Controller.showOpenappsecMeta(this.model);
+ }
+ },
+
+ templateContext: {
+ more: function() {
+ switch (this.object_type) {
+ case 'redirection-host':
+ case 'stream':
+ case 'proxy-host':
+ return this.meta.domain_names.join(', ');
+ }
+
+ return '#' + (this.object_id || '?');
+ }
+ }
+});
diff --git a/frontend/js/app/openappsec-log/list-notifications/main.ejs b/frontend/js/app/openappsec-log/list-notifications/main.ejs
new file mode 100644
index 00000000..9092a11a
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-notifications/main.ejs
@@ -0,0 +1,13 @@
+
+ Time |
+ Event Severity |
+ Event Priority |
+ Event Topic |
+ Event Name |
+ Suggested Remediation if Applicable |
+ Asset Name |
+ |
+
+
+
+
\ No newline at end of file
diff --git a/frontend/js/app/openappsec-log/list-notifications/main.js b/frontend/js/app/openappsec-log/list-notifications/main.js
new file mode 100644
index 00000000..0c90551b
--- /dev/null
+++ b/frontend/js/app/openappsec-log/list-notifications/main.js
@@ -0,0 +1,43 @@
+const Mn = require('backbone.marionette');
+const ItemView = require('./item');
+const template = require('./main.ejs');
+
+let TableBody = Mn.CollectionView.extend({
+ tagName: 'tbody',
+ childView: ItemView,
+
+ initialize: function (options) {
+ this.options = new Backbone.Model(options);
+ this.page = options.page;
+ this.perPage = options.perPage;
+ this.updatePage();
+ this.listenTo(this.options, 'change:page', this.updatePage);
+ },
+
+ updatePage: function () {
+ console.log('updatePage');
+ let models = this.collection.models.slice((this.page - 1) * this.perPage, this.page * this.perPage);
+ this.collection.reset(models);
+ }
+});
+
+module.exports = Mn.View.extend({
+ tagName: 'table',
+ className: 'table table-hover table-outline table-vcenter card-table',
+ template: template,
+
+ regions: {
+ body: {
+ el: 'tbody',
+ replaceElement: true
+ }
+ },
+
+ onRender: function () {
+ this.showChildView('body', new TableBody({
+ collection: this.collection,
+ page: this.options.page,
+ perPage: this.options.perPage
+ }));
+ }
+});
diff --git a/frontend/js/app/openappsec-log/list/main.js b/frontend/js/app/openappsec-log/list/main.js
index 01f5edd4..a7ef3281 100755
--- a/frontend/js/app/openappsec-log/list/main.js
+++ b/frontend/js/app/openappsec-log/list/main.js
@@ -14,12 +14,6 @@ let TableBody = Mn.CollectionView.extend({
this.listenTo(this.options, 'change:page', this.updatePage);
},
- setPage: function (page) {
- this.page = page;
- this.updatePage();
- this.render();
- },
-
updatePage: function () {
let models = this.collection.models.slice((this.page - 1) * this.perPage, this.page * this.perPage);
this.collection.reset(models);
diff --git a/frontend/js/app/openappsec-log/main.ejs b/frontend/js/app/openappsec-log/main.ejs
index 81c0cabc..4beee89c 100755
--- a/frontend/js/app/openappsec-log/main.ejs
+++ b/frontend/js/app/openappsec-log/main.ejs
@@ -13,14 +13,31 @@
-->
-