Skip to content

Commit 33d0333

Browse files
authored
[codex] Add local-first vulnerability research (#93)
* Add local-first vulnerability research * Refresh GitNexus index metadata * Address local research review feedback * Address vulnerability research review feedback
1 parent b788104 commit 33d0333

18 files changed

Lines changed: 1018 additions & 299 deletions

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Canonical entities must enforce EF max-length caps and FK `Guid` validity at the
8989
<!-- gitnexus:start -->
9090
# GitNexus — Code Intelligence
9191

92-
This project is indexed by GitNexus as **PatchHound** (11164 symbols, 92808 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
92+
This project is indexed by GitNexus as **PatchHound** (11435 symbols, 97109 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
9393

9494
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
9595

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ Canonical entities must enforce EF max-length caps and FK `Guid` validity at the
8989
<!-- gitnexus:start -->
9090
# GitNexus — Code Intelligence
9191

92-
This project is indexed by GitNexus as **PatchHound** (11164 symbols, 92808 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
92+
This project is indexed by GitNexus as **PatchHound** (11435 symbols, 97109 relationships, 300 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.
9393

9494
> If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first.
9595

frontend/src/api/ai-settings.schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const saveTenantAiProfileSchema = z.object({
4747
apiVersion: z.string(),
4848
keepAlive: z.string(),
4949
allowExternalResearch: z.boolean(),
50-
webResearchMode: z.enum(['Disabled', 'ProviderNative', 'PatchHoundManaged']),
50+
webResearchMode: z.enum(['Disabled', 'ProviderNative', 'PatchHoundManaged', 'LocalVulnerabilityIntel']),
5151
includeCitations: z.boolean(),
5252
maxResearchSources: z.number().int().positive(),
5353
allowedDomains: z.string(),

frontend/src/components/features/settings/TenantAiSettingsPage.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ function AiProfileEditorPage({
893893
<div className="space-y-1">
894894
<span className="text-sm font-medium text-foreground">Allow external web research</span>
895895
<p className="text-sm text-muted-foreground">
896-
Use recent external context when supported by the provider or by PatchHound-managed research.
896+
Use recent external context when supported by the provider or by PatchHound-managed research. Vulnerability assessments always use local PatchHound intel first.
897897
</p>
898898
</div>
899899
</label>
@@ -917,9 +917,19 @@ function AiProfileEditorPage({
917917
{draft.providerType === 'OpenAi' ? (
918918
<SelectItem value="ProviderNative">Provider native</SelectItem>
919919
) : null}
920+
<SelectItem value="LocalVulnerabilityIntel">Local vulnerability intel</SelectItem>
920921
<SelectItem value="PatchHoundManaged">PatchHound managed</SelectItem>
921922
</SelectContent>
922923
</Select>
924+
{draft.webResearchMode === 'PatchHoundManaged' ? (
925+
<p className="mt-2 text-xs leading-5 text-muted-foreground">
926+
PatchHound-managed external research sends search queries and fetched public pages through the configured research service.
927+
</p>
928+
) : draft.webResearchMode === 'LocalVulnerabilityIntel' ? (
929+
<p className="mt-2 text-xs leading-5 text-muted-foreground">
930+
Local vulnerability intel uses PatchHound and NVD cache data only. It does not perform external HTTP research.
931+
</p>
932+
) : null}
923933
</Field>
924934

925935
<Field label="Max research sources" tooltip="Upper bound for external sources added to the research context.">

src/PatchHound.Api/appsettings.Development.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,8 @@
1010
},
1111
"ConnectionStrings": {
1212
"PatchHound": ""
13+
},
14+
"AiResearch": {
15+
"JinaSearchProvider": "Google"
1316
}
1417
}

src/PatchHound.Api/appsettings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"Frontend": {
2828
"Origin": "http://localhost:5173"
2929
},
30+
"AiResearch": {
31+
"JinaSearchProvider": "Google"
32+
},
3033
"FeatureManagement": {
3134
"Workflows": true,
3235
"AuthenticatedScans": true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace PatchHound.Core.Enums;
2+
3+
public enum AiResearchProviderKind
4+
{
5+
ExternalWebSearch = 0,
6+
LocalVulnerabilityIntel = 1,
7+
}

src/PatchHound.Core/Enums/TenantAiWebResearchMode.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ public enum TenantAiWebResearchMode
55
Disabled = 0,
66
ProviderNative = 1,
77
PatchHoundManaged = 2,
8+
LocalVulnerabilityIntel = 3,
89
}
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
using PatchHound.Core.Enums;
2+
13
namespace PatchHound.Core.Models;
24

35
public record AiWebResearchRequest(
46
string Query,
57
IReadOnlyList<string> AllowedDomains,
68
int MaxSources,
7-
bool IncludeCitations
9+
bool IncludeCitations,
10+
IReadOnlyList<Guid>? VulnerabilityIds = null,
11+
IReadOnlyList<AiResearchProviderKind>? Providers = null
812
);

src/PatchHound.Infrastructure/DependencyInjection.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,11 @@ void ConfigureDbContext(IServiceProvider sp, DbContextOptionsBuilder options) =>
128128
services.AddScoped<ExecutiveDashboardBriefingService>();
129129
services.AddScoped<IRiskChangeBriefAiSummaryService, RiskChangeBriefAiSummaryService>();
130130
services.AddScoped<ITenantAiConfigurationResolver, TenantAiConfigurationResolver>();
131+
services.Configure<AiResearchOptions>(configuration.GetSection(AiResearchOptions.SectionName));
132+
services.AddScoped<LocalVulnerabilityIntelResearchProvider>();
133+
services.AddScoped<ITenantAiResearchService, TenantAiResearchService>();
131134
services
132-
.AddHttpClient<ITenantAiResearchService, TenantAiResearchService>()
135+
.AddHttpClient<ExternalWebSearchResearchProvider>()
133136
.AddExternalHttpPolicies(maxConnectionsPerServer: 2);
134137
services.AddScoped<ISetupService, SetupService>();
135138
services.AddScoped<EnvironmentalSeverityCalculator>();

0 commit comments

Comments
 (0)