Prerelease cleanup (#46)

* feat: Add const_bound_vars tracking to prevent false positives in ownership checks

* feat: Introduce field interner and typed bounded vars for enhanced type tracking

* feat: Add typed_call_receivers and typed_bounded_dto_fields for enhanced type tracking

* feat: Centralize method name extraction with bare_method_name helper

* feat: Implement Phase-6 hierarchy fan-out for runtime virtual dispatch

* feat: Enhance C++ taint tracking with additional container operations and inline method resolution

* feat: Introduce field-sensitive points-to analysis for enhanced resource tracking

* feat: Implement Pointer-Phase 6 subscript handling for enhanced container analysis

* test: Add comprehensive tests for JavaScript control flow constructs and lattice operations

* docs: Update advanced analysis documentation with field-sensitive points-to and hierarchy fan-out details

* test: Add comprehensive tests for lattice algebra laws and SSA edge cases

* feat: Add destructured session user handling and safe user ID access patterns

* feat: Implement row-population reverse-walk for enhanced authorization checks

* feat: Enhance authorization checks with local alias chain for self-actor types

* feat: Introduce ActiveRecord query safety checks and enhance snippet extraction

* feat: Implement chained method call inner-gate rebinding for SSRF prevention

* feat: Add observability and error modules, enhance debug functionality, and implement theme context

* feat: Remove Auth Analysis page and update navigation to redirect to Explorer

* feat: Optimize SSA lowering by sharing results between taint engine and artifact extractor

* feat: Optimize SSA lowering by sharing results between taint engine and artifact extractor

* feat: Reset path-safe-suppressed spans before lowering to maintain analysis integrity

* fix(ssa): ungate debug_assert_bfs_ordering for release-tests build

The helper at src/ssa/lower.rs was gated `#[cfg(debug_assertions)]` while
the unit test at the bottom of the file was gated only `#[cfg(test)]`.
Since `cfg(test)` is set in release builds with `--tests` but
`cfg(debug_assertions)` is not, `cargo build --release --tests` failed
with E0425. Removing the gate fixes the build; the body is `debug_assert!`
only, so the helper is free in release. Also drop the gate at the call
site to avoid a `dead_code` warning when the lib is built without
`--tests`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* test(closure-capture): flip JS/TS fixtures to required-finding

The JS and TS closure-capture fixtures pinned the old broken behaviour
via `forbidden_findings: [{ "id_prefix": "taint-" }]`. The engine now
correctly traces taint through the closure boundary (env source captured
by an arrow function, sunk via `child_process.exec` inside the body), so
the formerly-forbidden finding is a true positive.

Match the Python sibling's shape — `required_findings` with
`id_prefix` + `min_count` plus a small `noise_budget` — and rewrite the
companion READMEs and the phase8_fragility_tests doc-comments from
"known gap" to "regression guard".

Verified:
- cargo test --release --test phase8_fragility_tests → 8/8 pass
- cargo test --release --lib bfs_assertion → pass
- corpus benchmark F1 = 0.9976 (TP=205, FP=1, FN=0) — unchanged

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* feat: Add OWASP mapping and baseline mutation hooks for enhanced security analysis

* feat: Introduce health module and enhance health score computation with calibration tests

* feat: Add expectations configuration and cleanup .gitignore for log files

* feat: Implement theme selection and enhance settings panel for triage sync

* feat: Suppress false positives for strcpy calls with literal sources in AST

* feat: Update analyse_function_ssa to return body CFG for accurate analysis

* feat: Add bug report and feature request templates for improved issue tracking

* feat: removed dev scripts

* feat: update README.md for clarity and consistency in fixture descriptions

* feat: removed dev docs

* feat: clean up error handling and UI elements for improved user experience

* feat: adjust button sizes in HeaderBar for better UI consistency

* feat: enhance taint analysis with additional context for sanitizer and taint findings

* cargo fmt

* prettier

* refactor: simplify conditional checks and improve code readability in AST and screenshot capture scripts

* feat: add script to frame PNG screenshots with brand gradient

* feat: add fuzzing support with new targets and CI workflows

* refactor: streamline match expressions and improve formatting in CLI and output handling

* feat: enhance configuration display with detailed output options

* feat: stage demo configuration for improved CLI screenshot output

* feat: expose merge_configs function for user-configurable settings

* refactor: simplify code structure and improve readability in config handling

* refactor: improve descriptions for vulnerability patterns in various languages

* feat: update MIT License section with additional usage details and copyright information

* feat: update screenshots

* refactor: update build process and paths for frontend assets

* feat: add cross-file taint fuzzing target and supporting dictionary

* refactor: clean up formatting and comments in fuzz configuration and example files

* refactor: remove outdated comments and clean up CI configuration files

* chore: update changelog dates and improve formatting in documentation

* refactor: update Cargo.toml and CI configuration for improved packaging and build process

* refactor: enhance quote-stripping logic to prevent panics and add regression tests

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Eli Peter 2026-04-29 00:58:38 -04:00 committed by GitHub
parent 79c29b394d
commit 82f18184b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
348 changed files with 48731 additions and 2925 deletions

View file

@ -3,13 +3,57 @@ const CSRF_HEADER = 'X-Nyx-CSRF';
let csrfTokenPromise: Promise<string> | null = null;
export class ApiError extends Error {
/**
* Stable machine-readable code (matches backend `ApiError`'s `code` field).
* Falls back to a synthetic value when the response wasn't structured
* `network` for fetch failures, `http_<status>` for plain-text responses.
*/
public code: string;
public detail?: unknown;
constructor(
public status: number,
status: number,
message: string,
code?: string,
detail?: unknown,
) {
super(message);
this.name = 'ApiError';
this.status = status;
this.code = code ?? `http_${status}`;
this.detail = detail;
}
public status: number;
/** True when the failure was a network/abort, not an HTTP response. */
isNetwork(): boolean {
return this.status === 0;
}
}
/** Build an ApiError from a non-OK Response, parsing a JSON error body if present. */
async function errorFromResponse(res: Response): Promise<ApiError> {
const text = await res.text().catch(() => '');
if (text) {
try {
const parsed = JSON.parse(text) as {
error?: unknown;
code?: unknown;
detail?: unknown;
};
const msg =
typeof parsed.error === 'string' && parsed.error.length > 0
? parsed.error
: res.statusText || `HTTP ${res.status}`;
const code = typeof parsed.code === 'string' ? parsed.code : undefined;
return new ApiError(res.status, msg, code, parsed.detail);
} catch {
// Plain-text body — use as-is.
return new ApiError(res.status, text);
}
}
return new ApiError(res.status, res.statusText || `HTTP ${res.status}`);
}
async function getCsrfToken(): Promise<string> {
@ -17,10 +61,7 @@ async function getCsrfToken(): Promise<string> {
csrfTokenPromise = fetch(`${BASE}/session`)
.then(async (res) => {
if (!res.ok) {
throw new ApiError(
res.status,
await res.text().catch(() => res.statusText),
);
throw await errorFromResponse(res);
}
const text = await res.text();
@ -31,7 +72,7 @@ async function getCsrfToken(): Promise<string> {
typeof payload.csrf_token !== 'string' ||
payload.csrf_token.length === 0
) {
throw new ApiError(500, 'Missing CSRF token');
throw new ApiError(500, 'Missing CSRF token', 'missing_csrf_token');
}
return payload.csrf_token;
@ -67,14 +108,23 @@ async function request<T>(path: string, opts: RequestInit = {}): Promise<T> {
if (opts.body) {
headers['Content-Type'] = 'application/json';
}
const res = await fetch(url, {
...rest,
headers,
});
let res: Response;
try {
res = await fetch(url, {
...rest,
headers,
});
} catch (err) {
if (err instanceof DOMException && err.name === 'AbortError') {
throw err;
}
const message =
err instanceof Error ? err.message : 'Network request failed';
throw new ApiError(0, message, 'network');
}
if (!res.ok) {
const text = await res.text().catch(() => res.statusText);
throw new ApiError(res.status, text);
throw await errorFromResponse(res);
}
// Handle empty responses
@ -99,6 +149,26 @@ export function apiPost<T>(
});
}
export function apiDelete<T>(path: string, signal?: AbortSignal): Promise<T> {
return request<T>(path, { method: 'DELETE', signal });
export function apiPut<T>(
path: string,
body?: unknown,
signal?: AbortSignal,
): Promise<T> {
return request<T>(path, {
method: 'PUT',
body: body != null ? JSON.stringify(body) : undefined,
signal,
});
}
export function apiDelete<T>(
path: string,
body?: unknown,
signal?: AbortSignal,
): Promise<T> {
return request<T>(path, {
method: 'DELETE',
body: body != null ? JSON.stringify(body) : undefined,
signal,
});
}

View file

@ -0,0 +1,23 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { apiDelete, apiPost } from '../client';
export function usePinBaseline() {
const qc = useQueryClient();
return useMutation({
mutationFn: (scanId: string) =>
apiPost<void>('/overview/baseline', { scan_id: scanId }),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['overview'] });
},
});
}
export function useUnpinBaseline() {
const qc = useQueryClient();
return useMutation({
mutationFn: () => apiDelete<void>('/overview/baseline'),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['overview'] });
},
});
}

View file

@ -1,5 +1,5 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { apiPost, apiDelete } from '../client';
import { apiPost, apiPut, apiDelete } from '../client';
import type { LabelEntryView, TerminatorView, ProfileView } from '../types';
// --- Sources ---
@ -18,6 +18,7 @@ export function useAddSource() {
apiPost<LabelEntryView>('/config/sources', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'sources'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -25,9 +26,11 @@ export function useAddSource() {
export function useDeleteSource() {
const qc = useQueryClient();
return useMutation({
mutationFn: (body: AddLabelBody) => apiDelete<void>('/config/sources'),
mutationFn: (body: AddLabelBody) =>
apiDelete<void>('/config/sources', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'sources'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -41,6 +44,7 @@ export function useAddSink() {
apiPost<LabelEntryView>('/config/sinks', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'sinks'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -48,9 +52,10 @@ export function useAddSink() {
export function useDeleteSink() {
const qc = useQueryClient();
return useMutation({
mutationFn: (body: AddLabelBody) => apiDelete<void>('/config/sinks'),
mutationFn: (body: AddLabelBody) => apiDelete<void>('/config/sinks', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'sinks'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -64,6 +69,7 @@ export function useAddSanitizer() {
apiPost<LabelEntryView>('/config/sanitizers', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'sanitizers'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -71,9 +77,11 @@ export function useAddSanitizer() {
export function useDeleteSanitizer() {
const qc = useQueryClient();
return useMutation({
mutationFn: (body: AddLabelBody) => apiDelete<void>('/config/sanitizers'),
mutationFn: (body: AddLabelBody) =>
apiDelete<void>('/config/sanitizers', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'sanitizers'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -92,6 +100,7 @@ export function useAddTerminator() {
apiPost<TerminatorView>('/config/terminators', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'terminators'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -100,9 +109,10 @@ export function useDeleteTerminator() {
const qc = useQueryClient();
return useMutation({
mutationFn: (body: AddTerminatorBody) =>
apiDelete<void>('/config/terminators'),
apiDelete<void>('/config/terminators', body),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config', 'terminators'] });
qc.invalidateQueries({ queryKey: ['rules'] });
},
});
}
@ -143,6 +153,21 @@ export function useActivateProfile() {
});
}
// --- Raw nyx.local TOML ---
export function useSaveRawConfig() {
const qc = useQueryClient();
return useMutation({
mutationFn: (content: string) =>
apiPut<{ status: string; path: string; bytes: number }>('/config/raw', {
content,
}),
onSuccess: () => {
qc.invalidateQueries({ queryKey: ['config'] });
},
});
}
// --- Triage Sync ---
export function useToggleTriageSync() {

View file

@ -9,6 +9,19 @@ export function useConfig() {
});
}
export interface RawConfigView {
path: string;
exists: boolean;
content: string;
}
export function useRawConfig() {
return useQuery({
queryKey: ['config', 'raw'],
queryFn: ({ signal }) => apiGet<RawConfigView>('/config/raw', signal),
});
}
export function useSources() {
return useQuery({
queryKey: ['config', 'sources'],

View file

@ -9,6 +9,9 @@ import type {
SymexView,
CallGraphView,
FuncSummaryView,
PointerView,
TypeFactsView,
AuthAnalysisView,
} from '../types';
export function useDebugFunctions(file: string | null) {
@ -109,3 +112,39 @@ export function useDebugSummaries(
apiGet<FuncSummaryView[]>(`/debug/summaries?${params}`, signal),
});
}
export function useDebugPointer(file: string | null, fn_name: string | null) {
return useQuery({
queryKey: ['debug', 'pointer', file, fn_name],
queryFn: ({ signal }) =>
apiGet<PointerView>(
`/debug/pointer?file=${encodeURIComponent(file!)}&function=${encodeURIComponent(fn_name!)}`,
signal,
),
enabled: !!file && !!fn_name,
});
}
export function useDebugTypeFacts(file: string | null, fn_name: string | null) {
return useQuery({
queryKey: ['debug', 'type-facts', file, fn_name],
queryFn: ({ signal }) =>
apiGet<TypeFactsView>(
`/debug/type-facts?file=${encodeURIComponent(file!)}&function=${encodeURIComponent(fn_name!)}`,
signal,
),
enabled: !!file && !!fn_name,
});
}
export function useDebugAuth(file: string | null) {
return useQuery({
queryKey: ['debug', 'auth', file],
queryFn: ({ signal }) =>
apiGet<AuthAnalysisView>(
`/debug/auth?file=${encodeURIComponent(file!)}`,
signal,
),
enabled: !!file,
});
}

View file

@ -228,6 +228,120 @@ export interface OverviewResponse {
noisy_rules: NoisyRule[];
recent_scans: ScanSummary[];
insights: Insight[];
// Tier 1
health?: HealthScore;
posture?: PostureSummary;
backlog?: BacklogStats;
weighted_top_files?: WeightedFile[];
confidence_distribution?: ConfidenceDistribution;
// Tier 2
scanner_quality?: ScannerQuality;
issue_categories?: IssueCategoryBucket[];
hot_sinks?: HotSink[];
owasp_buckets?: OwaspBucket[];
cross_file_ratio?: number;
// Tier 3
baseline?: BaselineInfo;
language_health?: LanguageHealth[];
suppression_hygiene?: SuppressionHygiene;
}
export interface HealthComponent {
label: string;
score: number;
weight: number;
detail: string;
}
export interface HealthScore {
score: number;
grade: string;
components: HealthComponent[];
}
export interface PostureSummary {
trend: 'improving' | 'regressing' | 'stable' | 'unknown' | string;
severity: 'success' | 'warning' | 'danger' | 'info' | string;
message: string;
reintroduced_count: number;
}
export interface BacklogStats {
oldest_open_days?: number;
median_age_days?: number;
stale_count: number;
age_buckets: OverviewCount[];
}
export interface WeightedFile {
name: string;
score: number;
high: number;
medium: number;
low: number;
total: number;
}
export interface ConfidenceDistribution {
high: number;
medium: number;
low: number;
none: number;
}
export interface ScannerQuality {
files_scanned: number;
files_skipped: number;
parse_success_rate: number;
functions_analyzed: number;
call_edges: number;
unresolved_calls: number;
call_resolution_rate: number;
symex_verified_rate: number;
symex_breakdown: Record<string, number>;
}
export interface IssueCategoryBucket {
label: string;
count: number;
}
export interface HotSink {
callee: string;
count: number;
}
export interface OwaspBucket {
code: string;
label: string;
count: number;
}
export interface LanguageHealth {
language: string;
findings: number;
high: number;
medium: number;
low: number;
}
export interface SuppressionHygiene {
fingerprint_level: number;
rule_level: number;
file_level: number;
rule_in_file_level: number;
blanket_rate: number;
}
export interface BaselineInfo {
scan_id: string;
started_at?: string;
baseline_total: number;
drift_new: number;
drift_fixed: number;
}
// Rules types
@ -361,7 +475,15 @@ export interface TreeEntry {
export interface SymbolEntry {
name: string;
/// Legacy display kind (`"function"` | `"method"`) used by existing
/// CSS classes. Prefer `func_kind` for new logic.
kind: string;
/// Structural FuncKind slug: `"fn"` | `"method"` | `"closure"` |
/// `"ctor"` | `"getter"` | `"setter"` | `"toplevel"`.
func_kind: string;
/// Enclosing container (class / impl / module / outer function).
/// Empty for free top-level functions.
container: string;
line?: number;
finding_count: number;
namespace?: string;
@ -393,6 +515,10 @@ export interface ScanLogEntry {
export interface FunctionInfo {
name: string;
namespace: string;
/// Enclosing container (class / impl / module / outer function).
container: string;
/// Structural FuncKind slug: `"fn"` | `"method"` | `"closure"` | etc.
func_kind: string;
param_count: number;
line: number;
source_caps: string[];
@ -580,6 +706,10 @@ export interface FuncSummaryView {
file_path: string;
lang: string;
namespace: string;
/// Enclosing container (class / impl / module / outer function).
container: string;
/// Structural FuncKind slug: `"fn"` | `"method"` | `"closure"` | etc.
func_kind: string;
arity?: number;
param_count: number;
source_caps: string[];
@ -591,3 +721,124 @@ export interface FuncSummaryView {
callees: string[];
ssa_summary?: SsaSummaryView;
}
// ── Pointer (field-sensitive Steensgaard) ─────────────────────────────────
export interface PointerLocationView {
id: number;
kind: 'Top' | 'Alloc' | 'Param' | 'SelfParam' | 'Field';
display: string;
parent?: number;
field?: string;
}
export interface PointerValueView {
ssa_value: number;
var_name?: string;
points_to: number[];
is_top: boolean;
}
export interface PointerFieldEntryView {
/// `null` means the implicit receiver.
param_index: number | null;
field: string;
}
export interface PointerView {
locations: PointerLocationView[];
values: PointerValueView[];
field_reads: PointerFieldEntryView[];
field_writes: PointerFieldEntryView[];
location_count: number;
}
// ── Type Facts (standalone) ────────────────────────────────────────────────
export interface DtoFieldView {
name: string;
kind: string;
}
export interface DtoFactView {
class_name: string;
fields: DtoFieldView[];
}
export interface TypeFactDetailView {
ssa_value: number;
var_name?: string;
line: number;
kind: string;
nullable: boolean;
container?: string;
dto?: DtoFactView;
}
export interface TypeFactsView {
facts: TypeFactDetailView[];
total_values: number;
unknown_count: number;
}
// ── Auth Analysis ──────────────────────────────────────────────────────────
export interface AuthValueRefView {
source_kind: string;
name: string;
base?: string;
field?: string;
index?: string;
line: number;
}
export interface AuthCheckView {
kind: string;
callee: string;
line: number;
subjects: AuthValueRefView[];
args: string[];
condition_text?: string;
}
export interface AuthOperationView {
kind: string;
sink_class?: string;
callee: string;
line: number;
text: string;
subjects: AuthValueRefView[];
}
export interface AuthCallSiteView {
name: string;
line: number;
args: string[];
}
export interface AuthUnitView {
kind: string;
name?: string;
line: number;
params: string[];
auth_checks: AuthCheckView[];
operations: AuthOperationView[];
call_sites: AuthCallSiteView[];
self_actor_vars: string[];
typed_bounded_vars: string[];
authorized_sql_vars: string[];
const_bound_vars: string[];
}
export interface AuthRouteView {
framework: string;
method: string;
path: string;
middleware: string[];
handler_params: string[];
line: number;
unit_idx: number;
}
export interface AuthAnalysisView {
routes: AuthRouteView[];
units: AuthUnitView[];
enabled: boolean;
}