-
Notifications
You must be signed in to change notification settings - Fork 8
audit_module
Audit module logs all the movements done in the SensibleData app. This module stores in a new data base (Audit data base) who is asking for data, at what time, the requested data, the users whose data has been consulted and if there has been any error during the operation. This data is stored in the data base in collections depending on the type.
function d: Debug, it logs a debug operation.
function w: Warning, it logs a warning operation.
function e: Error, it logs an error operation.
function log(severity, typ, tag, doc): stores the document 'doc' requested in the collection 'type' adding the time in which the request has been done, a tag 'tag' an the 'severity' (DEBUG, WARNING, ERROR). This function will copy into a file the log depending of the decision.
function decision: makes the decision to write in a file the log or not.
function copyToFile: logs to a file the operation using the module 'log'.
In the module where we get the response of the request, we call the audit to log the operation:
auditdb= audit.Audit()
doc_audit=response['meta'] //doc to be logged
users_return=[]
users_results = cursorToArray(results, decrypted = decrypted, probe=probe_settings['collection'])
for data_users in users_results:
if data_users['user'] not in users_return:
users_return.append(data_users['user'])
doc_audit['users']=users_return //add to the doc the users of the requested data
doc_audit=transform.transform(doc_audit) //transform the keys that contains invalid characters into valid ones
auditdb.d(typ='prueba',tag='prueba2',doc=doc_audit) //log a debug operation in audit data base