(params, record_uids)
| 1137 | |
| 1138 | |
| 1139 | def add_record_audit_data(params, record_uids): # type: (KeeperParams, Iterable[str]) -> None |
| 1140 | if not params.enterprise_ec_key: |
| 1141 | return |
| 1142 | |
| 1143 | uids = set((x for x in record_uids if x in params.record_cache)) |
| 1144 | audit_data = [] # type: List[record_pb2.RecordAddAuditData] |
| 1145 | for record_uid in uids: |
| 1146 | record = get_record(params, record_uid) |
| 1147 | if record: |
| 1148 | if record.title: |
| 1149 | title = record.title |
| 1150 | if len(title) > 900: |
| 1151 | title = title[:900] |
| 1152 | audit = record_pb2.RecordAddAuditData() |
| 1153 | audit.record_uid = utils.base64_url_decode(record_uid) |
| 1154 | audit.revision = record.revision |
| 1155 | data = { |
| 1156 | 'title': title, |
| 1157 | 'record_type': record.record_type, |
| 1158 | } |
| 1159 | if record.login_url: |
| 1160 | data['url'] = utils.url_strip(record.login_url) |
| 1161 | audit.data = crypto.encrypt_ec(json.dumps(data).encode('utf-8'), params.enterprise_ec_key) |
| 1162 | audit_data.append(audit) |
| 1163 | |
| 1164 | if audit_data: |
| 1165 | rq = record_pb2.AddAuditDataRequest() |
| 1166 | rq.records.extend(audit_data) |
| 1167 | try: |
| 1168 | communicate_rest(params, rq, 'vault/record_add_audit_data') |
| 1169 | except Exception as e: |
| 1170 | logging.info('Failed to store audit data: %s', str(e)) |
| 1171 | |
| 1172 | |
| 1173 | def add_record_v3(params, record, **kwargs): # type: (KeeperParams, dict, ...) -> Optional[bool] |
no test coverage detected