Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /SHAdd0WTAka_Zen-Ai-Pentest /poc /backend /app /routers /plugins.py
| """ | |
| Plugin Marketplace Router | |
| Endpoints for plugin management | |
| """ | |
| from typing import Optional | |
| from fastapi import APIRouter, Depends, File, HTTPException, UploadFile, status | |
| from app.models.user import User | |
| from app.routers.auth import get_current_active_user, require_admin | |
| from app.services.plugin_service import plugin_service | |
| router = APIRouter() | |
| async def list_marketplace_plugins( | |
| category: Optional[str] = None, | |
| current_user: User = Depends(get_current_active_user), | |
| ): | |
| """List available plugins from marketplace""" | |
| plugins = plugin_service.get_marketplace_plugins() | |
| if category: | |
| plugins = [p for p in plugins if p["category"] == category] | |
| return {"success": True, "data": plugins} | |
| async def list_installed_plugins( | |
| category: Optional[str] = None, | |
| current_user: User = Depends(get_current_active_user), | |
| ): | |
| """List installed plugins""" | |
| plugins = plugin_service.list_plugins(category) | |
| return {"success": True, "data": plugins} | |
| async def get_plugin_info( | |
| plugin_id: str, | |
| current_user: User = Depends(get_current_active_user), | |
| ): | |
| """Get detailed information about a plugin""" | |
| info = plugin_service.get_plugin_info(plugin_id) | |
| if not info: | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Plugin not found") | |
| return {"success": True, "data": info} | |
| async def install_plugin( | |
| plugin_id: str, | |
| file: UploadFile = File(...), | |
| current_user: User = Depends(require_admin), | |
| ): | |
| """Install a plugin from package (admin only)""" | |
| try: | |
| content = await file.read() | |
| result = plugin_service.install_plugin(content, plugin_id) | |
| return result | |
| except ValueError as e: | |
| raise HTTPException(status_code=status.HTTP_400_BAD_REQUEST, detail=str(e)) | |
| async def uninstall_plugin( | |
| plugin_id: str, | |
| current_user: User = Depends(require_admin), | |
| ): | |
| """Uninstall a plugin (admin only)""" | |
| try: | |
| result = plugin_service.uninstall_plugin(plugin_id) | |
| return result | |
| except ValueError as e: | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e)) | |
| async def execute_plugin( | |
| plugin_id: str, | |
| payload: dict, | |
| current_user: User = Depends(get_current_active_user), | |
| ): | |
| """Execute a plugin""" | |
| try: | |
| result = plugin_service.execute_plugin(plugin_id, **payload) | |
| return result | |
| except ValueError as e: | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e)) | |
| async def update_plugin_config( | |
| plugin_id: str, | |
| config: dict, | |
| current_user: User = Depends(require_admin), | |
| ): | |
| """Update plugin configuration (admin only)""" | |
| try: | |
| result = plugin_service.update_plugin_config(plugin_id, config) | |
| return result | |
| except ValueError as e: | |
| raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(e)) | |
| async def list_plugin_categories( | |
| current_user: User = Depends(get_current_active_user), | |
| ): | |
| """List available plugin categories""" | |
| return { | |
| "success": True, | |
| "data": [ | |
| { | |
| "id": "scanner", | |
| "name": "Security Scanners", | |
| "description": "Vulnerability and security scanners", | |
| }, | |
| { | |
| "id": "reporter", | |
| "name": "Report Generators", | |
| "description": "Custom report generation plugins", | |
| }, | |
| { | |
| "id": "notification", | |
| "name": "Notifications", | |
| "description": "Alert and notification plugins", | |
| }, | |
| { | |
| "id": "custom", | |
| "name": "Custom", | |
| "description": "Custom utility plugins", | |
| }, | |
| ], | |
| } | |
Xet Storage Details
- Size:
- 4.07 kB
- Xet hash:
- 72706530051975f700d9443711b6864c687f707d39dfbecd9d6b499fb404a615
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.