mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
SYNC: audit log UX
This commit is contained in:
committed by
Diflow
parent
bac3dc5f4c
commit
1bd153ea0b
@@ -80,4 +80,19 @@ describe('Team edition tests', () => {
|
|||||||
cy.testid('AdminMenuWidget_itemUsers').click();
|
cy.testid('AdminMenuWidget_itemUsers').click();
|
||||||
cy.contains('test@example.com');
|
cy.contains('test@example.com');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it.only('Audit logging', () => {
|
||||||
|
cy.testid('LoginPage_linkAdmin').click();
|
||||||
|
cy.testid('LoginPage_password').type('adminpwd');
|
||||||
|
cy.testid('LoginPage_submitLogin').click();
|
||||||
|
|
||||||
|
cy.testid('AdminMenuWidget_itemAuditLog').click();
|
||||||
|
cy.contains('Audit log is not enabled');
|
||||||
|
cy.testid('AdminMenuWidget_itemSettings').click();
|
||||||
|
cy.testid('AdminSettingsTab_auditLogCheckbox').click();
|
||||||
|
cy.testid('AdminMenuWidget_itemAuditLog').click();
|
||||||
|
cy.contains('No data for selected date');
|
||||||
|
|
||||||
|
cy.themeshot('auditlog');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -162,14 +162,31 @@ async function sendToAuditLog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function maskPasswords(script) {
|
function maskLogFields(script) {
|
||||||
return _.cloneDeepWith(script, (value, key) => {
|
return _.cloneDeepWith(script, (value, key) => {
|
||||||
if (_.isString(key) && key.toLowerCase().includes('password')) {
|
if (_.isString(key) && key.toLowerCase().includes('password')) {
|
||||||
return '****';
|
return '****';
|
||||||
}
|
}
|
||||||
|
if (key == 'query') {
|
||||||
|
return '****';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extractConnectionId(connection) {
|
||||||
|
if (
|
||||||
|
connection?.server == process.env.STORAGE_SERVER &&
|
||||||
|
connection?.database == process.env.STORAGE_DATABASE &&
|
||||||
|
connection?.port == process.env.STORAGE_PORT
|
||||||
|
) {
|
||||||
|
return '__storage';
|
||||||
|
}
|
||||||
|
if (connection?.conid) {
|
||||||
|
return connection.conid;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function analyseJsonRunnerScript(script) {
|
function analyseJsonRunnerScript(script) {
|
||||||
const [assignSource, assignTarget, copyStream] = _.isArray(script?.commands) ? script?.commands : [];
|
const [assignSource, assignTarget, copyStream] = _.isArray(script?.commands) ? script?.commands : [];
|
||||||
if (assignSource?.type != 'assign') {
|
if (assignSource?.type != 'assign') {
|
||||||
@@ -190,15 +207,15 @@ function analyseJsonRunnerScript(script) {
|
|||||||
return {
|
return {
|
||||||
category: 'import',
|
category: 'import',
|
||||||
component: 'RunnersController',
|
component: 'RunnersController',
|
||||||
event: 'import.data',
|
event: 'import.table',
|
||||||
action: 'import',
|
action: 'import',
|
||||||
severity: 'info',
|
severity: 'info',
|
||||||
message: 'Importing data',
|
message: `Importing table ${pureName}`,
|
||||||
pureName: pureName,
|
pureName: pureName,
|
||||||
conid: connection?.conid,
|
conid: extractConnectionId(connection),
|
||||||
database: connection?.database,
|
database: connection?.database,
|
||||||
schemaName: schemaName,
|
schemaName: schemaName,
|
||||||
detail: maskPasswords(script),
|
detail: maskLogFields(script),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -212,15 +229,33 @@ function analyseJsonRunnerScript(script) {
|
|||||||
return {
|
return {
|
||||||
category: 'export',
|
category: 'export',
|
||||||
component: 'RunnersController',
|
component: 'RunnersController',
|
||||||
event: 'export.data',
|
event: 'export.table',
|
||||||
action: 'export',
|
action: 'export',
|
||||||
severity: 'info',
|
severity: 'info',
|
||||||
message: 'Exporting data',
|
message: `Exporting table ${pureName}`,
|
||||||
pureName: pureName,
|
pureName: pureName,
|
||||||
conid: connection?.conid,
|
conid: extractConnectionId(connection),
|
||||||
database: connection?.database,
|
database: connection?.database,
|
||||||
schemaName: schemaName,
|
schemaName: schemaName,
|
||||||
detail: maskPasswords(script),
|
detail: maskLogFields(script),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assignSource?.functionName == 'queryReader') {
|
||||||
|
const connection = assignSource?.props?.connection;
|
||||||
|
if (connection) {
|
||||||
|
return {
|
||||||
|
category: 'export',
|
||||||
|
component: 'RunnersController',
|
||||||
|
event: 'export.query',
|
||||||
|
action: 'export',
|
||||||
|
severity: 'info',
|
||||||
|
message: 'Exporting query',
|
||||||
|
conid: extractConnectionId(connection),
|
||||||
|
database: connection?.database,
|
||||||
|
detail: maskLogFields(script),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -241,7 +276,7 @@ function logJsonRunnerScript(req, script) {
|
|||||||
event: 'script.run.json',
|
event: 'script.run.json',
|
||||||
action: 'script',
|
action: 'script',
|
||||||
severity: 'info',
|
severity: 'info',
|
||||||
detail: maskPasswords(script),
|
detail: maskLogFields(script),
|
||||||
message: 'Running JSON script',
|
message: 'Running JSON script',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user