51 lines
2.0 KiB
Python
51 lines
2.0 KiB
Python
from crewai import CrewBase, Agent, Task, Crew
|
|
from crewai_tools import MCPServerAdapter
|
|
from mcp import StdioServerParameters
|
|
import os
|
|
from typing import Dict, Any
|
|
|
|
|
|
class SecurityReviewCrew(CrewBase):
|
|
"""Security Review Crew for conducting security reviews."""
|
|
|
|
agents_config = "config/agents.yaml"
|
|
tasks_config = "config/tasks.yaml"
|
|
|
|
def __init__(self):
|
|
super().__init__()
|
|
# Trivy uses native MCP server, so we don't need to configure a wrapper.
|
|
# However, we might need to set up connection parameters if required by the native server.
|
|
# For now, we assume the native Trivy MCP server is available at a known address or via stdio.
|
|
# We'll leave the MCP server configuration empty and rely on the native server being available.
|
|
self.trivy_server_params = None # Placeholder for if we need to configure stdio parameters
|
|
|
|
@Agent
|
|
def security_reviewer(self) -> Agent:
|
|
"""Application Security Engineer agent for security review."""
|
|
return Agent(
|
|
config=self.agents_config["security_reviewer"],
|
|
tools=[], # Tools will be added via MCP adapter in the task
|
|
verbose=True
|
|
)
|
|
|
|
@Task
|
|
def security_review_task(self) -> Task:
|
|
"""Task for conducting security review."""
|
|
return Task(
|
|
config=self.tasks_config["security_review_task"],
|
|
)
|
|
|
|
@Crew
|
|
def crew(self) -> Crew:
|
|
"""Create the Security Review crew."""
|
|
# If we had an MCP server to wrap, we would create an adapter here.
|
|
# Since Trivy is native, we don't add any tools via MCPServerAdapter.
|
|
# However, the native server should be available in the MCP ecosystem.
|
|
# We'll assume the tools are automatically available or will be handled differently.
|
|
return Crew(
|
|
agents=[self.security_reviewer()],
|
|
tasks=[self.security_review_task()],
|
|
process="sequential",
|
|
verbose=True,
|
|
# No additional tools from MCP wrapper for Trivy (native)
|
|
) |