Skip to content

Commit 3ffe09b

Browse files
committed
fix(typescript): Fix auto-fix count calculation and improve educational resources
**Issue 1: Auto-fix count calculation (business-impact.ts:249)** - Problem: Counted entire groups instead of actual blocking issues - Fix: Now filters blocking issues individually to check if auto-fixable - Impact: Accurate auto-fix percentages in reports **Issue 2: Educational resources (educational-resources.ts:235)** - Problem: YouTube/Stack Overflow searches didn't return good results - Fix: Changed to Google Search (aggregates all sources) - Benefits: * No API key needed * No rate limits * Better results (YouTube + Stack Overflow + docs + blogs) * Smarter search algorithm - Search format: "${language} ${issue} tutorial fix" Related to TypeScript testing improvements
1 parent 6c41256 commit 3ffe09b

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

packages/agents/src/two-branch/report/business-impact.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,16 @@ export function generateBusinessImpact(issues: EnrichedIssue[], groups: IssueGro
211211

212212
const immediateRisk = blocking.length > 0 ? '🔴 High' : '🟢 Low';
213213

214-
// SESSION 13 FIX #3: Detect if most/all blocking issues are auto-fixable
215-
const blockingAutoFixableGroups = autoFixableGroups.filter(g =>
216-
blocking.some(i => i.rule === g.rule && i.tool === g.tool && i.severity === g.severity)
217-
);
218-
const autoFixableBlockingCount = blockingAutoFixableGroups.reduce((sum, g) => sum + g.count, 0);
214+
// SESSION 13 FIX #3 + TYPESCRIPT FIX: Count only blocking issues that are auto-fixable
215+
// Don't count entire group - only count the blocking issues within auto-fixable groups
216+
const autoFixableBlockingCount = blocking.filter(issue => {
217+
// Check if there's an auto-fixable group for this issue
218+
return autoFixableGroups.some(g =>
219+
g.rule === issue.rule &&
220+
g.tool === issue.tool &&
221+
g.severity === issue.severity
222+
);
223+
}).length;
219224
const autoFixPercentage = blocking.length > 0 ? (autoFixableBlockingCount / blocking.length) * 100 : 0;
220225
const mostlyAutoFixable = autoFixPercentage >= 70; // 70%+ of blocking issues are auto-fixable
221226

packages/agents/src/two-branch/report/educational-resources.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import { getCuratedResourcesForRule } from './ai-enrichment';
1414
* CVE format: CVE-YYYY-NNNNN (e.g., CVE-2021-44228)
1515
*
1616
* CVE EDUCATION LINK BUG FIX (2025-10-30):
17-
* Detects CVE IDs to generate proper NVD/MITRE links instead of generic YouTube searches
17+
* Detects CVE IDs to generate proper NVD/MITRE links instead of generic search
18+
*
19+
* TYPESCRIPT FIX (2025-11-14):
20+
* Changed to Google Search for non-CVE issues (aggregates YouTube, Stack Overflow, docs, blogs)
1821
*/
1922
function extractCVEId(ruleId: string, title: string, description?: string): string | null {
2023
const cvePattern = /CVE-\d{4}-\d{4,}/i;
@@ -230,9 +233,9 @@ export async function generateEducationalResourcesBrave(issues: EnrichedIssue[])
230233
content += `- [📋 MITRE CVE](https://cve.mitre.org/cgi-bin/cvename.cgi?name=${cveId}) - Official CVE details\n`;
231234
content += `- [🛡️ CISA Known Exploited Vulnerabilities](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) - Check if actively exploited\n`;
232235
} else {
233-
// For non-CVE issues: Use YouTube tutorial search
234-
const youtubeQuery = `${language} ${title.toLowerCase()}`.replace(/[^\w\s]/g, ' ').trim();
235-
content += `- [🎥 YouTube Tutorial](https://www.youtube.com/results?search_query=${encodeURIComponent(youtubeQuery + ' tutorial')})\n`;
236+
// For non-CVE issues: Use Google search (aggregates YouTube, Stack Overflow, docs, blogs, etc.)
237+
const searchQuery = `${language} ${title.toLowerCase()} tutorial fix`.replace(/[^\w\s]/g, ' ').trim();
238+
content += `- [🔍 Google Search](https://www.google.com/search?q=${encodeURIComponent(searchQuery)})\n`;
236239
}
237240

238241
// Add curated documentation
@@ -277,9 +280,9 @@ export async function generateEducationalResourcesBrave(issues: EnrichedIssue[])
277280
content += `- [📋 MITRE CVE](https://cve.mitre.org/cgi-bin/cvename.cgi?name=${cveId}) - Official CVE details\n`;
278281
content += `- [🛡️ CISA Known Exploited Vulnerabilities](https://www.cisa.gov/known-exploited-vulnerabilities-catalog) - Check if actively exploited\n`;
279282
} else {
280-
// For non-CVE issues: Use YouTube tutorial search
281-
const youtubeQuery = `${language} ${title.toLowerCase()}`.replace(/[^\w\s]/g, ' ').trim();
282-
content += `- [🎥 YouTube Tutorial](https://www.youtube.com/results?search_query=${encodeURIComponent(youtubeQuery + ' tutorial')})\n`;
283+
// For non-CVE issues: Use Google search (aggregates YouTube, Stack Overflow, docs, blogs, etc.)
284+
const searchQuery = `${language} ${title.toLowerCase()} tutorial fix`.replace(/[^\w\s]/g, ' ').trim();
285+
content += `- [🔍 Google Search](https://www.google.com/search?q=${encodeURIComponent(searchQuery)})\n`;
283286
}
284287

285288
// Add curated documentation

0 commit comments

Comments
 (0)