1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
| from crewai import Agent, Task, Crew, Process
from crewai_tools import SerperDevTool, WebsiteSearchTool
# 工具
search_tool = SerperDevTool()
web_tool = WebsiteSearchTool()
# Agent 定義
researcher = Agent(
role="Vulnerability Researcher",
goal="Find the latest critical security vulnerabilities",
backstory="""You are a senior security researcher
specializing in web application vulnerabilities.""",
tools=[search_tool, web_tool],
verbose=True
)
analyst = Agent(
role="Security Analyst",
goal="Analyze vulnerabilities and assess their impact",
backstory="""You are a security analyst with expertise
in risk assessment and threat modeling.""",
verbose=True
)
writer = Agent(
role="Technical Writer",
goal="Create clear security advisories",
backstory="""You are a technical writer who creates
actionable security documentation.""",
verbose=True
)
# Task 定義
research_task = Task(
description="""Search for the top 5 critical CVEs
announced in the past month. Focus on web applications.""",
expected_output="List of CVEs with descriptions",
agent=researcher
)
analysis_task = Task(
description="""Analyze the CVEs from the research
and assess their risk level and impact.""",
expected_output="Risk assessment for each CVE",
agent=analyst,
context=[research_task]
)
report_task = Task(
description="""Create a security advisory report
based on the analysis.""",
expected_output="Markdown formatted security report",
agent=writer,
context=[analysis_task]
)
# 建立 Crew
security_crew = Crew(
agents=[researcher, analyst, writer],
tasks=[research_task, analysis_task, report_task],
process=Process.sequential,
verbose=True
)
# 執行
result = security_crew.kickoff()
print(result)
|