Add modular browser-based AI threat message detection dashboard#2
Add modular browser-based AI threat message detection dashboard#2
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c12f0d26e8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return { | ||
| riskScore: 0, | ||
| category: 'Safe', | ||
| threatLevel: 'LOW', | ||
| confidence: 0, | ||
| indicators: [] | ||
| }; |
There was a problem hiding this comment.
Include layer scores in empty analysis result
When the input is blank, analyze() returns an object without layers, but UIController.renderResult() always reads result.layers.keywordScore; clicking Analyze Message on an empty/whitespace textarea therefore throws a runtime TypeError and breaks rendering for that run. Keep the return shape consistent (or guard the UI read) so empty input does not crash the dashboard.
Useful? React with 👍 / 👎.
| const ThreatAnalysisEngine = (() => { | ||
| const keywordSignals = [ | ||
| { pattern: /\bkill|shoot|stab|murder\b/gi, weight: 18, type: 'Violence verb' }, | ||
| { pattern: /\bbomb|explode|detonate|blast\b/gi, weight: 24, type: 'Explosive reference' }, |
There was a problem hiding this comment.
Scope keyword regexes to whole words
This alternation applies word boundaries only to the first and last branch, so tokens like bomb can match inside benign words (for example, bombastic), which inflates risk scoring and creates false alerts. The same pattern shape appears in several signal regexes, so wrapping alternatives (e.g., \b(?:...)\b) is needed to preserve detection accuracy.
Useful? React with 👍 / 👎.
Motivation
Description
index.htmlwith panels for input, results, explainability, recent scans, sample messages, and a status badge.style.csswith dark palette, accent colors, risk meter, and responsive layout.analysisEngine.jsimplementing a multi-layer scoring engine (keyword signals, context analysis, behavioral indicators, safety offsets, aggregation, classification, and confidence calculation) with detailed indicator objects for explainability.uiController.jsandmain.jsto wire UI updates, render explainability and history, support debounced real-time analysis, sample scenarios, and a simulated1sAI processing delay.Testing
Codex Task