mirror of
https://github.com/morluto/rea.git
synced 2026-11-15 11:13:21 +00:00
refactor(errors): require a reason for every analysis cancellation (#10566)
* refactor(errors): require a reason for every analysis cancellation Add cancelledBy, the one constructor for AnalysisCancelledError. Its reason argument is required: an aborted signal, an earlier cancellation, a reason carried from an inner failure, or an OwnerCancellation when REA closed the work's owner itself. Closed adb, apktool, firmware, sqlite, gdb, web-bundle analyzer and binary-session record owners now report OwnerCancellation.ownerClosed instead of an absent reason. Firmware's predecessor wait returns its cancellation as a Result, removing an unreachable reason-less fallback. An architecture guard rejects new direct constructions, with a counted per-file baseline that can only shrink. * refactor(errors): share one aborted-signal predicate with cancelledBy * refactor(process): return a departing caller's reason from a shared startup wait * refactor(providers): build decompiler-provider cancellations with a required reason (#10587) Migrate every AnalysisCancelledError construction under src/ghidra, src/ida, src/cutter, src/jeb and src/kuna to cancelledBy and lower the guard baseline from 671 to 572. Closed Kuna target commands report OwnerCancellation.ownerClosed instead of an absent reason, and Kuna and JEB close abort their lifetimes with that typed reason. * fix(errors): read the reason of any signal-shaped cancellation source * test(ci): cover the counted-baseline comparison behind the architecture guard
This commit is contained in:
1 parent
2f4c588584
commit
85da0bd4ee
51 files changed
+900
-488
No files matched your search
@@ -13,8 +13,9 @@ import {
|
||||
import type { AnalysisError } from "../../domain/analysisErrorBase.js";
|
||||
import type { InvestigationStatistics } from "../../domain/investigationLifecycle.js";
|
||||
import {
|
||||
AnalysisCancelledError,
|
||||
AnalysisCapabilityUnavailableError,
|
||||
cancelledBy,
|
||||
OwnerCancellation,
|
||||
} from "../../domain/analysisErrorCore.js";
|
||||
import type { UnknownRegistryError } from "../../domain/unknownRegistryError.js";
|
||||
import type {
|
||||
@@ -120,7 +121,7 @@ export abstract class BinarySessionRecords {
|
||||
evidence: Evidence,
|
||||
): Result<"added" | "duplicate", AnalysisError> {
|
||||
if (this.#investigationDisposed)
|
||||
return err(new AnalysisCancelledError("record_evidence"));
|
||||
return err(cancelledBy("record_evidence", OwnerCancellation.ownerClosed));
|
||||
const recorded = this.#records.recordEvidence(evidence);
|
||||
if (recorded.ok && recorded.value === "added") this.#emitSnapshotChanged();
|
||||
return recorded;
|
||||
@@ -200,7 +201,9 @@ export abstract class BinarySessionRecords {
|
||||
bundle: unknown,
|
||||
): Result<EvidenceImportReceipt, AnalysisError> {
|
||||
if (this.#investigationDisposed)
|
||||
return err(new AnalysisCancelledError("import_evidence_bundle"));
|
||||
return err(
|
||||
cancelledBy("import_evidence_bundle", OwnerCancellation.ownerClosed),
|
||||
);
|
||||
const imported = this.#records.mergeEvidenceBundle(bundle);
|
||||
if (!imported.ok) return imported;
|
||||
this.#snapshot.refreshEvidenceMetadata(imported.value.replacements);
|
||||
@@ -266,7 +269,9 @@ export abstract class BinarySessionRecords {
|
||||
snapshot: AnalysisSnapshot,
|
||||
): Result<number, AnalysisError> {
|
||||
if (this.#investigationDisposed)
|
||||
return err(new AnalysisCancelledError("import_analysis_snapshot"));
|
||||
return err(
|
||||
cancelledBy("import_analysis_snapshot", OwnerCancellation.ownerClosed),
|
||||
);
|
||||
const active = this.activeAnalysisBinding();
|
||||
if (active !== undefined && this.#snapshotInvalidated)
|
||||
return err(
|
||||
@@ -465,7 +470,7 @@ export abstract class BinarySessionRecords {
|
||||
input: RecordUnknownInput,
|
||||
): Result<ResidualUnknown, AnalysisError> {
|
||||
if (this.#investigationDisposed)
|
||||
return err(new AnalysisCancelledError("record_unknown"));
|
||||
return err(cancelledBy("record_unknown", OwnerCancellation.ownerClosed));
|
||||
const target = this.activeAnalysisBinding()?.target;
|
||||
const recorded = this.#records.recordUnknown(input, target);
|
||||
if (recorded.ok) this.#emitSnapshotChanged();
|
||||
@@ -477,7 +482,12 @@ export abstract class BinarySessionRecords {
|
||||
input: RecordUnknownInput,
|
||||
): Result<ResidualUnknown | null, AnalysisError> {
|
||||
if (this.#investigationDisposed)
|
||||
return err(new AnalysisCancelledError("record_evidence_with_unknown"));
|
||||
return err(
|
||||
cancelledBy(
|
||||
"record_evidence_with_unknown",
|
||||
OwnerCancellation.ownerClosed,
|
||||
),
|
||||
);
|
||||
const recorded = this.#records.recordEvidenceWithUnknown(evidence, input);
|
||||
if (recorded.ok) this.#emitSnapshotChanged();
|
||||
return recorded;
|
||||
@@ -487,7 +497,7 @@ export abstract class BinarySessionRecords {
|
||||
input: UpdateUnknownInput,
|
||||
): Result<ResidualUnknown, AnalysisError> {
|
||||
if (this.#investigationDisposed)
|
||||
return err(new AnalysisCancelledError("update_unknown"));
|
||||
return err(cancelledBy("update_unknown", OwnerCancellation.ownerClosed));
|
||||
const target = this.activeAnalysisBinding()?.target;
|
||||
const updated = this.#records.updateUnknown(input, target);
|
||||
if (updated.ok) this.#emitSnapshotChanged();
|
||||
|
||||
Reference in new issue
Block a user