# hariharan-2411/sectest architecture

> Architecture diagram of the GitHub repository hariharan-2411/sectest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hariharan-2411/sectest
- Repository: https://github.com/hariharan-2411/sectest

## Overview

#### Purpose and Entry Points
SecTest Pro is a Chrome/Brave Manifest V3 security-testing extension for authorized web-app testing. It scans page inputs, applies guarded payloads without submission, performs passive recon, tracks scope/programs, validates findings, and produces reports. The extension entry surfaces are the MV3 manifest, service worker, content script, and React popup: `src/manifest.json`, `src/pages/Background/index.js`, `src/pages/Content/index.js`, `src/pages/Popup/index.jsx`.

#### Extension Control Plane
The popup is the operator-facing orchestration layer: it manages scan/payload/recon/settings state, communicates with the active-tab content script, and persists operational data through Chrome storage. The background worker supplies extension-wide defaults, message handling, rate limiting, and enforcement boundaries. Shared configuration and browser persistence adapters isolate runtime settings from UI logic: `src/pages/Popup/Popup.jsx`, `src/pages/Background/index.js`, `src/utils/chromeStorageAdapter.js`.

#### Page Scanning and Test Execution
The content script is the only component intended to inspect or mutate the loaded target DOM. It enumerates form controls into serializable metadata, inserts reachability markers, applies payloads only to compatible text-like controls, and visually marks modified fields. Popup-to-content messages form the principal browser-side execution path; form submission, navigation, cookie mutation, and storage-value reading remain outside that path. Core paths: `src/pages/Content/index.js`, `src/utils/extraction.js`, `src/utils/payloads.js`.

#### Safety, Scope, and Audit Boundary
Testing is constrained by host/program scope, dry-run versus live mode, explicit confirmations, payload validation, and action-rate limits. Scope is also modeled as program assets and can be synchronized with the companion agent. Findings are retained rather than silently discarded, while audit/notification utilities provide traceability and user feedback. Core paths: `src/utils/scope.js`, `src/utils/programs.js`, `src/utils/validate.js`, `src/utils/notify.js`.

#### Recon, Evidence, and Finding Lifecycle
Passive recon derives page inventory, forms, storage-key names, headers, and script-change signals locally. Detection helpers identify reflection, taint/sinks, secret indicators, and differential/oracle evidence. These observations become findings, then pass through deterministic confidence scoring; noise is excluded from escalation, and report generation defaults to likely-or-better findings. The optional prose layer may explain a score but cannot alter it. Core paths: `src/utils/reconHelpers.js`, `src/utils/findings.js`, `src/utils/validate.js`, `src/utils/reportBuilder.js`.

#### AI and External Service Boundary
AI payload generation supports local Ollama and Groq through provider abstractions; a Supabase Edge Function proxies Groq-related requests. AI is advisory: deterministic validation remains authoritative for confidence and reporting. Authentication and remote persistence integrations are separated behind utility clients. Core paths: `src/utils/aiProvider.js`, `src/utils/aiModels.js`, `src/utils/supabaseClient.js`, `supabase/functions/groq-proxy/index.ts`.

#### Companion Agent and Tool Execution
The optional Node.js companion agent is a loopback HTTP service for recon tools unavailable to browser extensions. It authenticates requests, rechecks synchronized scope per request, classifies tools by risk, rate-limits execution, and invokes allow-listed binaries without a shell. Active tools require an additional environment gate. Its triage subproject is a separate runner-oriented stage for processing results. Core paths: `agent/server.js`, `agent/lib/tools.js`, `agent/lib/scope.js`, `agent/triage/runner.js`.

#### Runtime and Deployment Shape
The main runtime is React/Webpack packaged as a Chrome MV3 extension, using Chrome extension APIs and browser-tab messaging. The optional agent runs Node.js directly or in Docker and binds to loopback; it invokes installed/containerized reconnaissance binaries. Supabase hosts the optional TypeScript edge proxy, while Ollama and Groq are external AI endpoints. Build composition is defined in `webpack.config.js`, agent containerization in `agent/Dockerfile` and `agent/docker-compose.yml`.

Main entry points: [`src/pages/Content/index.js`](https://github.com/hariharan-2411/sectest/blob/main/src/pages/Content/index.js) (Content Script), [`src/pages/Popup/index.jsx`](https://github.com/hariharan-2411/sectest/blob/main/src/pages/Popup/index.jsx) (React Popup), [`src/utils/scope.js`](https://github.com/hariharan-2411/sectest/blob/main/src/utils/scope.js) (Scope & Programs), [`src/utils/validate.js`](https://github.com/hariharan-2411/sectest/blob/main/src/utils/validate.js) (Deterministic Validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_extension["Chrome MV3 Extension"]
  node_manifest["MV3 Manifest<br/>extension entry<br/>[manifest.json]"]
  node_popup["React Popup<br/>operator console<br/>[index.jsx]"]
  node_background["Background Worker<br/>service worker<br/>[index.js]"]
  node_storage[("Chrome Storage Adapter<br/>persistence adapter")]
  node_content["Content Script<br/>target DOM executor<br/>[index.js]"]
  node_extraction["Control Extraction<br/>DOM metadata<br/>[extraction.js]"]
  node_payloads["Guarded Payloads<br/>payload library<br/>[payloads.js]"]
  node_webpack["Extension Build<br/>Webpack packaging<br/>[webpack.config.js]"]
end

subgraph group_evidence["Evidence Pipeline"]
  node_scope{{"Scope & Programs<br/>authorization boundary<br/>[scope.js]"}}
  node_recon["Passive Recon<br/>page inventory<br/>[reconHelpers.js]"]
  node_findings[("Findings Lifecycle<br/>evidence store<br/>[findings.js]")]
  node_validation{{"Deterministic Validation<br/>confidence scorer<br/>[validate.js]"}}
  node_reports["Report Builder<br/>report generator<br/>[reportBuilder.js]"]
  node_notify["Audit & Notifications<br/>traceability<br/>[notify.js]"]
end

subgraph group_external["Optional Remote Services"]
  node_ai["AI Provider Layer<br/>advisory payload AI<br/>[aiProvider.js]"]
  node_supabase["Supabase Client<br/>remote client<br/>[supabaseClient.js]"]
  node_groqproxy["Groq Edge Proxy<br/>Supabase Edge Function<br/>[index.ts]"]
end

subgraph group_agent["Companion Agent"]
  node_agentserver["Loopback Agent Server<br/>Node HTTP service<br/>[server.js]"]
  node_agenttools{{"Allow-listed Tool Runner<br/>recon executor<br/>[tools.js]"}}
  node_agentscope["Agent Scope Guard<br/>per-request scope<br/>[scope.js]"]
  node_triage["Triage Runner<br/>result processing stage<br/>[runner.js]"]
end

node_manifest -->|"registers"| node_background
node_manifest -->|"injects"| node_content
node_webpack -->|"packages"| node_manifest
node_popup -->|"extension messages"| node_background
node_popup -->|"active-tab commands"| node_content
node_popup -->|"persists state"| node_storage
node_background -->|"enforces defaults"| node_scope
node_content -->|"enumerates controls"| node_extraction
node_content -->|"uses"| node_payloads
node_scope -->|"authorizes testing"| node_content
node_content -->|"supplies page signals"| node_recon
node_recon -->|"creates observations"| node_findings
node_content -->|"records test evidence"| node_findings
node_findings -->|"scores"| node_validation
node_validation -->|"filters reportable findings"| node_reports
node_validation -->|"emits audit feedback"| node_notify
node_popup -.->|"requests suggestions"| node_ai
node_ai -.->|"remote provider access"| node_supabase
node_supabase -->|"invokes"| node_groqproxy
node_ai -.->|"advises candidates"| node_payloads
node_popup -.->|"optional loopback requests"| node_agentserver
node_scope -.->|"synchronizes programs"| node_agentscope
node_agentserver -->|"rechecks scope"| node_agentscope
node_agentserver -->|"authorizes execution"| node_agenttools
node_agenttools -->|"produces results"| node_triage

click node_manifest "https://github.com/hariharan-2411/sectest/blob/main/src/manifest.json"
click node_popup "https://github.com/hariharan-2411/sectest/blob/main/src/pages/Popup/index.jsx"
click node_background "https://github.com/hariharan-2411/sectest/blob/main/src/pages/Background/index.js"
click node_storage "https://github.com/hariharan-2411/sectest/blob/main/src/utils/chromeStorageAdapter.js"
click node_content "https://github.com/hariharan-2411/sectest/blob/main/src/pages/Content/index.js"
click node_extraction "https://github.com/hariharan-2411/sectest/blob/main/src/utils/extraction.js"
click node_payloads "https://github.com/hariharan-2411/sectest/blob/main/src/utils/payloads.js"
click node_scope "https://github.com/hariharan-2411/sectest/blob/main/src/utils/scope.js"
click node_recon "https://github.com/hariharan-2411/sectest/blob/main/src/utils/reconHelpers.js"
click node_findings "https://github.com/hariharan-2411/sectest/blob/main/src/utils/findings.js"
click node_validation "https://github.com/hariharan-2411/sectest/blob/main/src/utils/validate.js"
click node_reports "https://github.com/hariharan-2411/sectest/blob/main/src/utils/reportBuilder.js"
click node_notify "https://github.com/hariharan-2411/sectest/blob/main/src/utils/notify.js"
click node_ai "https://github.com/hariharan-2411/sectest/blob/main/src/utils/aiProvider.js"
click node_supabase "https://github.com/hariharan-2411/sectest/blob/main/src/utils/supabaseClient.js"
click node_groqproxy "https://github.com/hariharan-2411/sectest/blob/main/supabase/functions/groq-proxy/index.ts"
click node_agentserver "https://github.com/hariharan-2411/sectest/blob/main/agent/server.js"
click node_agenttools "https://github.com/hariharan-2411/sectest/blob/main/agent/lib/tools.js"
click node_agentscope "https://github.com/hariharan-2411/sectest/blob/main/agent/lib/scope.js"
click node_triage "https://github.com/hariharan-2411/sectest/blob/main/agent/triage/runner.js"
click node_webpack "https://github.com/hariharan-2411/sectest/blob/main/webpack.config.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_manifest,node_popup,node_background,node_storage,node_content,node_extraction,node_payloads,node_webpack toneBlue
class node_scope,node_recon,node_findings,node_validation,node_reports,node_notify toneAmber
class node_ai,node_supabase,node_groqproxy toneMint
class node_agentserver,node_agenttools,node_agentscope,node_triage toneRose
```

## Components

### Chrome MV3 Extension

Browser-side operator interface and guarded page testing.

- [MV3 Manifest](https://github.com/hariharan-2411/sectest/blob/main/src/manifest.json): extension entry · `src/manifest.json`
- [React Popup](https://github.com/hariharan-2411/sectest/blob/main/src/pages/Popup/index.jsx): operator console · Manages scan, payload, recon, settings, and active-tab commands. · `src/pages/Popup/index.jsx`
- [Background Worker](https://github.com/hariharan-2411/sectest/blob/main/src/pages/Background/index.js): service worker · Applies extension-wide messaging, defaults, and rate limits. · `src/pages/Background/index.js`
- [Chrome Storage Adapter](https://github.com/hariharan-2411/sectest/blob/main/src/utils/chromeStorageAdapter.js): persistence adapter · `src/utils/chromeStorageAdapter.js`
- [Content Script](https://github.com/hariharan-2411/sectest/blob/main/src/pages/Content/index.js): target DOM executor · Only browser component permitted to inspect or alter target-page DOM. · `src/pages/Content/index.js`
- [Control Extraction](https://github.com/hariharan-2411/sectest/blob/main/src/utils/extraction.js): DOM metadata · Serializes compatible form-control metadata for the popup. · `src/utils/extraction.js`
- [Guarded Payloads](https://github.com/hariharan-2411/sectest/blob/main/src/utils/payloads.js): payload library · Applies payloads only to compatible text-like controls without submission. · `src/utils/payloads.js`
- [Extension Build](https://github.com/hariharan-2411/sectest/blob/main/webpack.config.js): Webpack packaging · `webpack.config.js`

### Evidence Pipeline

Local recon, validation, and reporting.

- [Scope & Programs](https://github.com/hariharan-2411/sectest/blob/main/src/utils/scope.js): authorization boundary · Models allowed hosts and program assets. · `src/utils/scope.js`
- [Passive Recon](https://github.com/hariharan-2411/sectest/blob/main/src/utils/reconHelpers.js): page inventory · Collects local page, form, header, key-name, and script-change observations. · `src/utils/reconHelpers.js`
- [Findings Lifecycle](https://github.com/hariharan-2411/sectest/blob/main/src/utils/findings.js): evidence store · Retains observations for deterministic confidence evaluation. · `src/utils/findings.js`
- [Deterministic Validation](https://github.com/hariharan-2411/sectest/blob/main/src/utils/validate.js): confidence scorer · Enforces confirmations, payload checks, noise exclusion, and authoritative scoring. · `src/utils/validate.js`
- [Report Builder](https://github.com/hariharan-2411/sectest/blob/main/src/utils/reportBuilder.js): report generator · Defaults output to likely-or-better findings. · `src/utils/reportBuilder.js`
- [Audit & Notifications](https://github.com/hariharan-2411/sectest/blob/main/src/utils/notify.js): traceability · `src/utils/notify.js`

### Optional Remote Services

Advisory AI and remote integration boundary.

- [AI Provider Layer](https://github.com/hariharan-2411/sectest/blob/main/src/utils/aiProvider.js): advisory payload AI · Selects local Ollama or Groq providers without controlling validation. · `src/utils/aiProvider.js`
- [Supabase Client](https://github.com/hariharan-2411/sectest/blob/main/src/utils/supabaseClient.js): remote client · `src/utils/supabaseClient.js`
- [Groq Edge Proxy](https://github.com/hariharan-2411/sectest/blob/main/supabase/functions/groq-proxy/index.ts): Supabase Edge Function · Proxies Groq-related requests. · `supabase/functions/groq-proxy/index.ts`

### Companion Agent

Loopback-only tooling for browser-inaccessible reconnaissance.

- [Loopback Agent Server](https://github.com/hariharan-2411/sectest/blob/main/agent/server.js): Node HTTP service · Authenticates requests and rechecks synchronized scope before tool execution. · `agent/server.js`
- [Allow-listed Tool Runner](https://github.com/hariharan-2411/sectest/blob/main/agent/lib/tools.js): recon executor · Risk-classifies and rate-limits shell-free binary invocation; active tools need an environment gate. · `agent/lib/tools.js`
- [Agent Scope Guard](https://github.com/hariharan-2411/sectest/blob/main/agent/lib/scope.js): per-request scope · `agent/lib/scope.js`
- [Triage Runner](https://github.com/hariharan-2411/sectest/blob/main/agent/triage/runner.js): result processing stage · Separate runner-oriented processing for agent results. · `agent/triage/runner.js`

## Connections

- MV3 Manifest → Background Worker: registers
- MV3 Manifest → Content Script: injects
- Extension Build → MV3 Manifest: packages
- React Popup → Background Worker: extension messages
- React Popup → Content Script: active-tab commands
- React Popup → Chrome Storage Adapter: persists state
- Background Worker → Scope & Programs: enforces defaults
- Content Script → Control Extraction: enumerates controls
- Content Script → Guarded Payloads: uses
- Scope & Programs → Content Script: authorizes testing
- Content Script → Passive Recon: supplies page signals
- Passive Recon → Findings Lifecycle: creates observations
- Content Script → Findings Lifecycle: records test evidence
- Findings Lifecycle → Deterministic Validation: scores
- Deterministic Validation → Report Builder: filters reportable findings
- Deterministic Validation → Audit & Notifications: emits audit feedback
- React Popup → AI Provider Layer: requests suggestions
- AI Provider Layer → Supabase Client: remote provider access
- Supabase Client → Groq Edge Proxy: invokes
- AI Provider Layer → Guarded Payloads: advises candidates · Generated candidates remain subject to deterministic checks.
- React Popup → Loopback Agent Server: optional loopback requests
- Scope & Programs → Agent Scope Guard: synchronizes programs
- Loopback Agent Server → Agent Scope Guard: rechecks scope
- Loopback Agent Server → Allow-listed Tool Runner: authorizes execution
- Allow-listed Tool Runner → Triage Runner: produces results
