mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 14:01:15 +02:00
feat: Add API endpoint to list node files
Implement issue #2719 - Add API endpoint to list project files - Add GET /v3/projects/{project_id}/nodes/{node_id}/files endpoint - Add list_node_files() method to Project class - Add security checks to prevent path traversal - Filter out .ghost temporary files - Return file paths with MD5 checksums - Require Node.Audit privilege This allows users to discover dynamically created files such as QEMU disk images created via the disk image API. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
e0860555ba
commit
5b75d633aa
3 files changed
+69
No files matched your search
@@ -522,6 +522,23 @@ async def delete_disk_image(
|
||||
await node.delete(f"/disk_image/{disk_name}")
|
||||
|
||||
|
||||
@router.get("/{node_id}/files", response_model=List[schemas.ProjectFile], dependencies=[Depends(has_privilege("Node.Audit"))])
|
||||
async def list_node_files(node: Node = Depends(dep_node)) -> List[schemas.ProjectFile]:
|
||||
"""
|
||||
List files in a node directory.
|
||||
|
||||
Required privilege: Node.Audit
|
||||
"""
|
||||
|
||||
node_type = node.node_type
|
||||
res = await node.compute.http_query(
|
||||
"GET",
|
||||
f"/projects/{node.project.id}/nodes/{node_type}/{node.id}/files",
|
||||
timeout=None
|
||||
)
|
||||
return res.json
|
||||
|
||||
|
||||
@router.get("/{node_id}/files/{file_path:path}", dependencies=[Depends(has_privilege("Node.Audit"))])
|
||||
async def get_file(file_path: str, node: Node = Depends(dep_node)) -> Response:
|
||||
"""
|
||||
|
||||
Reference in new issue
Block a user