|
1 | 1 | import type { OrgFramework } from './frameworks'; |
2 | | -import type { FirecrawlVendorData } from './schema'; |
| 2 | +import type { VendorRiskAssessmentDataV1 } from './agent-types'; |
3 | 3 |
|
4 | 4 | export function buildRiskAssessmentDescription(params: { |
5 | 5 | vendorName: string; |
6 | 6 | vendorWebsite: string | null; |
7 | | - research: FirecrawlVendorData | null; |
| 7 | + research: VendorRiskAssessmentDataV1 | null; |
8 | 8 | frameworkChecklist: string[]; |
9 | 9 | organizationFrameworks: OrgFramework[]; |
10 | 10 | }): string { |
11 | | - const { vendorName, vendorWebsite, research, frameworkChecklist, organizationFrameworks } = |
12 | | - params; |
13 | | - |
14 | | - const instruction = |
15 | | - 'Conduct a risk assessment for this vendor. Review their controls and documentation against SOC 2 and ISO 27001 expectations and add a comment describing how your team will use the vendor securely.'; |
16 | | - |
17 | | - const links: Array<{ label: string; url: string }> = []; |
18 | | - if (research?.trust_portal_url) |
19 | | - links.push({ label: 'Trust Center', url: research.trust_portal_url }); |
20 | | - if (research?.security_overview_url) |
21 | | - links.push({ label: 'Security Overview', url: research.security_overview_url }); |
22 | | - if (research?.soc2_report_url) |
23 | | - links.push({ label: 'SOC 2 Report', url: research.soc2_report_url }); |
24 | | - if (research?.privacy_policy_url) |
25 | | - links.push({ label: 'Privacy Policy', url: research.privacy_policy_url }); |
26 | | - if (research?.terms_of_service_url) |
27 | | - links.push({ label: 'Terms of Service', url: research.terms_of_service_url }); |
28 | | - |
29 | | - const content: Array<Record<string, unknown>> = [ |
30 | | - { |
31 | | - type: 'paragraph', |
32 | | - content: [{ type: 'text', text: instruction }], |
33 | | - }, |
34 | | - { |
35 | | - type: 'paragraph', |
36 | | - content: [ |
37 | | - { type: 'text', marks: [{ type: 'bold' }], text: 'Vendor:' }, |
38 | | - { type: 'text', text: ` ${vendorName}` }, |
39 | | - ], |
40 | | - }, |
41 | | - ]; |
42 | | - |
43 | | - if (vendorWebsite) { |
44 | | - content.push({ |
45 | | - type: 'paragraph', |
46 | | - content: [ |
47 | | - { type: 'text', marks: [{ type: 'bold' }], text: 'Website:' }, |
48 | | - { type: 'text', text: ` ${vendorWebsite}` }, |
49 | | - ], |
50 | | - }); |
51 | | - } |
52 | | - |
53 | | - // Intentionally omit "Framework Focus" line to keep the description concise. |
54 | | - |
55 | | - if (frameworkChecklist.length > 0) { |
56 | | - content.push({ |
57 | | - type: 'paragraph', |
58 | | - content: [ |
59 | | - { type: 'text', marks: [{ type: 'bold' }], text: 'Framework-specific checks:' }, |
60 | | - ], |
61 | | - }); |
62 | | - content.push({ |
63 | | - type: 'bulletList', |
64 | | - content: frameworkChecklist.map((item) => ({ |
65 | | - type: 'listItem', |
66 | | - content: [{ type: 'paragraph', content: [{ type: 'text', text: item }] }], |
67 | | - })), |
68 | | - }); |
69 | | - } |
70 | | - |
71 | | - if (research?.company_description) { |
72 | | - content.push({ |
73 | | - type: 'paragraph', |
74 | | - content: [ |
75 | | - { type: 'text', marks: [{ type: 'bold' }], text: 'Company Overview:' }, |
76 | | - ], |
77 | | - }); |
78 | | - content.push({ |
79 | | - type: 'paragraph', |
80 | | - content: [{ type: 'text', text: research.company_description }], |
81 | | - }); |
82 | | - } |
83 | | - |
84 | | - const certs = research?.certified_security_frameworks?.filter(Boolean) ?? []; |
85 | | - if (certs.length > 0) { |
86 | | - content.push({ |
87 | | - type: 'paragraph', |
88 | | - content: [ |
89 | | - { type: 'text', marks: [{ type: 'bold' }], text: 'Security Certifications:' }, |
90 | | - ], |
91 | | - }); |
92 | | - content.push({ |
93 | | - type: 'bulletList', |
94 | | - content: certs.map((framework) => ({ |
95 | | - type: 'listItem', |
96 | | - content: [ |
97 | | - { type: 'paragraph', content: [{ type: 'text', text: framework }] }, |
98 | | - ], |
99 | | - })), |
100 | | - }); |
101 | | - } |
102 | | - |
103 | | - if (links.length > 0) { |
104 | | - content.push({ |
105 | | - type: 'paragraph', |
106 | | - content: [ |
107 | | - { type: 'text', marks: [{ type: 'bold' }], text: 'Relevant Links:' }, |
108 | | - ], |
109 | | - }); |
110 | | - content.push({ |
111 | | - type: 'bulletList', |
112 | | - content: links.map((link) => ({ |
113 | | - type: 'listItem', |
114 | | - content: [ |
115 | | - { |
116 | | - type: 'paragraph', |
117 | | - content: [ |
118 | | - { |
119 | | - type: 'text', |
120 | | - marks: [ |
121 | | - { |
122 | | - type: 'link', |
123 | | - attrs: { |
124 | | - href: link.url, |
125 | | - target: '_blank', |
126 | | - rel: 'noopener noreferrer', |
127 | | - }, |
128 | | - }, |
129 | | - ], |
130 | | - text: link.label, |
131 | | - }, |
132 | | - ], |
133 | | - }, |
134 | | - ], |
135 | | - })), |
136 | | - }); |
137 | | - } else if (vendorWebsite) { |
138 | | - content.push({ |
139 | | - type: 'paragraph', |
140 | | - content: [ |
141 | | - { |
142 | | - type: 'text', |
143 | | - marks: [{ type: 'italic' }], |
144 | | - text: 'Note: Automated research did not return links. Please collect documentation manually.', |
145 | | - }, |
146 | | - ], |
147 | | - }); |
148 | | - } else { |
149 | | - content.push({ |
150 | | - type: 'paragraph', |
151 | | - content: [ |
152 | | - { |
153 | | - type: 'text', |
154 | | - marks: [{ type: 'italic' }], |
155 | | - text: 'Note: No website provided for automated research.', |
156 | | - }, |
157 | | - ], |
158 | | - }); |
159 | | - } |
160 | | - |
161 | | - return JSON.stringify({ type: 'doc', content }); |
| 11 | + const { vendorName, vendorWebsite, research, frameworkChecklist } = params; |
| 12 | + |
| 13 | + const base: VendorRiskAssessmentDataV1 = research ?? { |
| 14 | + kind: 'vendorRiskAssessmentV1', |
| 15 | + vendorName, |
| 16 | + vendorWebsite, |
| 17 | + lastResearchedAt: null, |
| 18 | + riskLevel: null, |
| 19 | + securityAssessment: null, |
| 20 | + certifications: null, |
| 21 | + links: null, |
| 22 | + news: null, |
| 23 | + }; |
| 24 | + |
| 25 | + // Keep the existing “framework checklist” value for humans (rendered inside the Security Assessment card). |
| 26 | + const checklistSuffix = |
| 27 | + frameworkChecklist.length > 0 |
| 28 | + ? `\n\nFramework-specific checks:\n${frameworkChecklist.map((c) => `- ${c}`).join('\n')}` |
| 29 | + : ''; |
| 30 | + |
| 31 | + return JSON.stringify({ |
| 32 | + ...base, |
| 33 | + vendorName: base.vendorName ?? vendorName, |
| 34 | + vendorWebsite: base.vendorWebsite ?? vendorWebsite, |
| 35 | + securityAssessment: (base.securityAssessment ?? '') + checklistSuffix || null, |
| 36 | + } satisfies VendorRiskAssessmentDataV1); |
162 | 37 | } |
163 | 38 |
|
164 | 39 |
|
0 commit comments