MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / trigger_network_scan

Function trigger_network_scan

webapp_modern.py:15432–15493  ·  view source on GitHub ↗

Trigger a manual network scan

()

Source from the content-addressed store, hash-verified

15430
15431 return jsonify({
15432 'success': True,
15433 'message': 'System reboot initiated'
15434 })
15435
15436 except Exception as e:
15437 logger.error(f"Error rebooting system: {e}")
15438 return jsonify({'success': False, 'error': str(e)}), 500
15439
15440@app.route('/api/system/shutdown', methods=['POST'])
15441def shutdown_system():
15442 """Shut down the entire system"""
15443 try:
15444 import subprocess
15445
15446 # Schedule shutdown after a short delay to allow response to be sent
15447 def shutdown_delayed():
15448 import time
15449 time.sleep(3) # Give time for response to be sent
15450 try:
15451 subprocess.run(['sudo', 'shutdown', '-h', 'now'], check=True)
15452 except subprocess.CalledProcessError as e:
15453 logger.error(f"Failed to shut down system: {e}")
15454
15455 # Start shutdown in background thread
15456 import threading
15457 threading.Thread(target=shutdown_delayed, daemon=True).start()
15458
15459 return jsonify({
15460 'success': True,
15461 'message': 'System shutdown initiated'
15462 })
15463
15464 except Exception as e:
15465 logger.error(f"Error shutting down system: {e}")
15466 return jsonify({'success': False, 'error': str(e)}), 500
15467
15468# ============================================================================
15469# DATA MANAGEMENT ENDPOINTS
15470# ============================================================================
15471
15472@app.route('/api/data/reset-vulnerabilities', methods=['POST'])
15473def reset_vulnerabilities():
15474 """
15475 Reset all vulnerability data - removes all discovered vulnerabilities
15476
15477 IMPORTANT: Network Intelligence is the SINGLE SOURCE OF TRUTH for vulnerabilities.
15478 - Vulnerabilities are cleared from Network Intelligence (in-memory + JSON files)
15479 - Legacy CSV files are also cleared for backward compatibility
15480 - If the same vulnerabilities are found in future scans, they will be
15481 automatically re-added to Network Intelligence (auto-repopulation)
15482 """
15483 try:
15484 deleted_count = 0
15485
15486 # SINGLE SOURCE OF TRUTH: Clear Network Intelligence vulnerabilities
15487 if hasattr(shared_data, 'network_intelligence') and shared_data.network_intelligence:
15488 try:
15489 # Count all vulnerabilities across all networks

Callers

nothing calls this directly

Calls 6

_detect_local_cidrFunction · 0.85
broadcast_status_updateFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80
getMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected