Skip to content

Commit ffb7a87

Browse files
committed
fix(security): remove fileId from API responses
- Remove internal database ID (fileId) from formatFileResponse - Remove fileId from formatFilesResponse - Update LibresignNextcloudFile type definition - Only expose nodeId which is the Nextcloud file system ID - Prevents exposure of internal database structure Signed-off-by: Vitor Mattos <[email protected]>
1 parent 614c83e commit ffb7a87

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/Controller/FileController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ private function formatFileResponse(FileEntity $mainEntity, array $childFiles):
684684
$response = [
685685
'message' => $this->l10n->t('Success'),
686686
'id' => $mainEntity->getNodeId(),
687-
'fileId' => $mainEntity->getId(),
688687
'nodeId' => $mainEntity->getNodeId(),
689688
'uuid' => $mainEntity->getUuid(),
690689
'name' => $mainEntity->getName(),
@@ -718,11 +717,10 @@ private function extractFileName(array $fileData): string {
718717

719718
/**
720719
* @param FileEntity[] $files
721-
* @return list<array{fileId: int, nodeId: int, uuid: string, name: string, status: int, statusText: string}>
720+
* @return list<array{nodeId: int, uuid: string, name: string, status: int, statusText: string}>
722721
*/
723722
private function formatFilesResponse(array $files): array {
724723
return array_values(array_map(fn (FileEntity $file) => [
725-
'fileId' => $file->getId(),
726724
'nodeId' => $file->getNodeId(),
727725
'uuid' => $file->getUuid(),
728726
'name' => $file->getName(),

lib/ResponseDefinitions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@
4747
* message: string,
4848
* name: non-falsy-string,
4949
* id: int,
50+
* nodeId: int,
5051
* uuid: string,
5152
* status: int,
5253
* statusText: string,
5354
* nodeType: 'file'|'envelope',
5455
* created_at: string,
55-
* files: list<array{id: int, uuid: string, name: string, status: int, statusText: string}>,
56+
* filesCount: int<0, max>,
57+
* files: list<array{nodeId: int, uuid: string, name: string, status: int, statusText: string}>,
5658
* }
5759
* @psalm-type LibresignIdentifyAccount = array{
5860
* id: non-negative-int,

0 commit comments

Comments
 (0)