diff --git a/README.md b/README.md index 3f4adf4..b4ac7f4 100644 --- a/README.md +++ b/README.md @@ -76,10 +76,13 @@ Features include: ### File Operations ```http -POST /upload # Upload files for analysis -GET /analyze/static/ # Static file analysis -POST /analyze/dynamic/ # Dynamic file analysis -POST /analyze/dynamic/ # Process analysis +POST /upload # Upload files for analysis +GET /analyze/static/ # Static file analysis +POST /analyze/dynamic/ # Dynamic file analysis +POST /analyze/dynamic/ # Process analysis +GET /file//info # Get file info +GET /file//static # Get results for file static analysis +GET /file//dynamic # Get results for file dynamic analysis ``` ### System Management diff --git a/app/routes.py b/app/routes.py index 5e5cb96..f150910 100644 --- a/app/routes.py +++ b/app/routes.py @@ -409,6 +409,48 @@ def register_routes(app): except Exception as e: return jsonify({'error': str(e)}), 500 + @app.route('/file//', methods=['GET']) + def get_analysis_results(target, analysis_type): + try: + # Find result folder for the given hash + result_path = find_file_by_hash(target, app.config['upload']['result_folder']) + if not result_path: + return jsonify({'error': 'Results not found'}), 404 + + # Handle different types of requests + if analysis_type == 'info': + # Read and return the file info + file_info_path = os.path.join(result_path, 'file_info.json') + if not os.path.exists(file_info_path): + return jsonify({'error': 'File info not found'}), 404 + + with open(file_info_path, 'r') as f: + results = json.load(f) + + elif analysis_type in ['static', 'dynamic']: + # Read and return the analysis results + results_file = f'{analysis_type}_analysis_results.json' + results_path = os.path.join(result_path, results_file) + if not os.path.exists(results_path): + return jsonify({'error': 'Analysis results not found'}), 404 + + with open(results_path, 'r') as f: + results = json.load(f) + + else: + return jsonify({'error': 'Invalid analysis type'}), 400 + + return jsonify({ + 'status': 'success', + 'results': results + }) + + except Exception as e: + return jsonify({ + 'status': 'error', + 'error': str(e) + }), 500 + @app.route('/cleanup', methods=['POST']) def cleanup(): try: