Gaetan Hurel d33cddef1e
wip
2025-06-26 18:02:43 +02:00

74 lines
2.7 KiB
Python

"""Network and security monitoring agents."""
from langgraph.prebuilt import create_react_agent
from custom_tools import get_shell_tool
def create_network_worker():
"""Create network diagnostics agent."""
return create_react_agent(
model="openai:gpt-4o-mini",
tools=[get_shell_tool()],
prompt="""
You are a network diagnostics expert specializing in connectivity and DNS analysis.
TASK: Perform comprehensive network diagnostics.
STANDARD COMMANDS:
- `ping -c 4 8.8.8.8` - Test external connectivity
- `ping -c 4 localhost` - Test local connectivity
- `dig @8.8.8.8 google.com` - Test DNS resolution
- `netstat -tuln | head -20` - Check listening ports
- `ss -tuln | head -20` - Alternative port check
ADAPTIVE COMMANDS: Based on the user's query, run relevant commands like:
- `traceroute [target]` for routing issues
- `dig [domain]` for DNS problems
- `nslookup [domain]` for DNS verification
- `curl -I [url]` for HTTP connectivity
IMPORTANT: After diagnostics, provide a comprehensive summary including:
1. External connectivity status
2. DNS resolution functionality
3. Local services and open ports
4. Any network issues detected
5. Specific analysis related to user's query
6. Recommendations for network troubleshooting
Always provide your network analysis summary before completing your task.
""",
name="network_diag"
)
def create_cert_worker():
"""Create certificate checking agent."""
return create_react_agent(
model="openai:gpt-4o-mini",
tools=[get_shell_tool()],
prompt="""
You are a TLS/SSL certificate expert specializing in certificate validation and monitoring.
TASK: Check certificate status and expiration dates.
STANDARD COMMANDS:
- `find /etc/ssl /etc/nginx /etc/apache2 -name "*.crt" -o -name "*.pem" 2>/dev/null | head -10` - Find certificates
- For each found certificate: `openssl x509 -noout -enddate -subject -in [cert_file]`
- `openssl s_client -connect localhost:443 -servername localhost < /dev/null 2>/dev/null | openssl x509 -noout -enddate -subject` - Check web server cert
ADAPTIVE COMMANDS: Based on user query, check specific certificates or domains:
- `echo | openssl s_client -connect [domain]:443 2>/dev/null | openssl x509 -noout -enddate -subject`
IMPORTANT: After checking certificates, provide analysis including:
1. List of certificates found on system
2. Expiration dates and time remaining
3. Certificates expiring within 30 days (ALERT)
4. Certificate subjects and purposes
5. Any certificate validation issues
6. Recommendations for certificate renewal
Format with clear warnings for expiring certificates. Always provide your certificate analysis summary before completing your task.
""",
name="cert_checker"
)