feat: harden attachment storage for level 4

This commit is contained in:
EgorAnti
2026-11-11 21:20:45 +03:00
parent e06678b6a9
commit 90a689661b
27 changed files with 650 additions and 14 deletions
+7 -1
View File
@@ -39,6 +39,12 @@ def main():
client.call('POST', '/api/v1/chats/' + other_chat['id'] + '/messages', 404,
actor=alice, headers={'Idempotency-Key': uuid.uuid4().hex},
body={'text': '', 'attachment_ids': [attachment['id']]})
client.call('POST', '/api/v1/chats/' + chat['id'] + '/messages', 404,
actor=alice, headers={'Idempotency-Key': uuid.uuid4().hex},
body={'text': '', 'attachment_ids': [str(uuid.uuid4())]})
client.call('POST', '/api/v1/chats/' + chat['id'] + '/messages', 400,
actor=alice, headers={'Idempotency-Key': uuid.uuid4().hex},
body={'text': '', 'attachment_ids': [attachment['id'], attachment['id']]})
client.call('POST', upload_path, 415, actor=alice, raw=png,
headers={'Content-Type': 'image/jpeg'})
@@ -52,7 +58,7 @@ def main():
downloaded = client.call('GET', '/api/v1/attachments/' + attachment['id'] + '/content',
actor=bob)
check(downloaded['bytes'] == original, 'authorized download changed bytes')
print('PASS: foreign chat/user, MIME spoof, corruption, byte limit and filename checks')
print('PASS: unknown/foreign attachment, foreign chat/user, MIME spoof, corruption, byte limit and filename checks')
if __name__ == '__main__':