scientific-method-engine 3.2.0__tar.gz → 4.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/PKG-INFO +5 -3
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/README.md +4 -2
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/pyproject.toml +1 -1
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/cli.py +2 -1
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/reports.py +3 -3
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/result_flow.py +3 -1
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/trace.py +121 -36
- scientific_method_engine-4.0.1/tests/test_continuation_budget.py +198 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_table_continuations.py +4 -2
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/.gitignore +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/LICENSE +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/__init__.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/__main__.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ClearNoReturnFunctions.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/CreateFunctions.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ExportBoundedFlow.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ExportCallEdges.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ExportFunctionFingerprints.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ExportFunctionInventory.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/MergeFallThroughFragment.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/RecoverCitedFunctions.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/RepairReturningCallers.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportCallArguments.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportCallPaths.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportCallSitesWithScalars.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportCallsToRange.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportConstantFirstArgumentCalls.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportDataBytes.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportDecompileMatches.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportDecompileWindow.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportFilePatternInMemory.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportFirstArgumentCallSummary.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportFunctionScalarConstants.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportFunctionSummary.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportInstructionContext.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportInstructionWindow.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportMemoryBlockForFileOffset.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportMemoryBlocks.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportRandomnessCandidates.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportReferences.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportScalarConstants.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportStringReferences.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/ghidra/ReportSymbolReferences.java +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/__init__.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/argument_frames.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/dispatch.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/effect_order.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/image.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/loops.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/machine.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/memory_scopes.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/pcode.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/pcode_backend.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/pe.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/relational.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/src/scientific_method_engine/x86/values.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/oracle.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_dispatch.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_effect_order.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_loops.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_memory_scopes.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_nested_frame_request.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_oracle.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_pe.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_relational_controls.py +0 -0
- {scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_x86.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: scientific-method-engine
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.1
|
|
4
4
|
Summary: Bounded instruction-derived x86 evidence reports for segmented MZ/FBOV and PE32/i386 code.
|
|
5
5
|
Project-URL: Source, https://github.com/kibertoad/refurbished-dinosaurs-toolkit/tree/main/packages/scientific-method-engine
|
|
6
6
|
Author: kibertoad
|
|
@@ -135,8 +135,10 @@ Evidenced segmented16 `indirectJumps` declarations also expose separate
|
|
|
135
135
|
`declaredContinuationPaths`. Ordinary paths retain their unresolved transfer;
|
|
136
136
|
conditional routes preserve prefix/child effects with target-choice, live-table
|
|
137
137
|
and selector assumptions. Effects summaries never mark those routes complete.
|
|
138
|
-
Concrete values/field addresses reject inconsistent rows
|
|
139
|
-
path
|
|
138
|
+
Concrete values/field addresses reject inconsistent rows. Continuations run after
|
|
139
|
+
every ordinary path on their own `continuationBudget` (paths, total and per-path steps,
|
|
140
|
+
visits, string iterations), so ordinary paths are the same with or without them. Overlap,
|
|
141
|
+
boundary and continuation limits remain explicit gaps or stops. Partial-table splits are
|
|
140
142
|
partial evidence, never complete dispatch or native-reachability claims. See the
|
|
141
143
|
[table contract](https://github.com/kibertoad/refurbished-dinosaurs-toolkit/blob/main/docs/bounded-evidence-reporters.md#evidenced-indirect-jump-tables).
|
|
142
144
|
|
|
@@ -119,8 +119,10 @@ Evidenced segmented16 `indirectJumps` declarations also expose separate
|
|
|
119
119
|
`declaredContinuationPaths`. Ordinary paths retain their unresolved transfer;
|
|
120
120
|
conditional routes preserve prefix/child effects with target-choice, live-table
|
|
121
121
|
and selector assumptions. Effects summaries never mark those routes complete.
|
|
122
|
-
Concrete values/field addresses reject inconsistent rows
|
|
123
|
-
path
|
|
122
|
+
Concrete values/field addresses reject inconsistent rows. Continuations run after
|
|
123
|
+
every ordinary path on their own `continuationBudget` (paths, total and per-path steps,
|
|
124
|
+
visits, string iterations), so ordinary paths are the same with or without them. Overlap,
|
|
125
|
+
boundary and continuation limits remain explicit gaps or stops. Partial-table splits are
|
|
124
126
|
partial evidence, never complete dispatch or native-reachability claims. See the
|
|
125
127
|
[table contract](https://github.com/kibertoad/refurbished-dinosaurs-toolkit/blob/main/docs/bounded-evidence-reporters.md#evidenced-indirect-jump-tables).
|
|
126
128
|
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scientific-method-engine"
|
|
7
7
|
# The release workflow writes the published version from the package's release tag.
|
|
8
|
-
version = "
|
|
8
|
+
version = "4.0.1"
|
|
9
9
|
description = "Bounded instruction-derived x86 evidence reports for segmented MZ/FBOV and PE32/i386 code."
|
|
10
10
|
readme = "README.md"
|
|
11
11
|
requires-python = ">=3.12"
|
|
@@ -19,7 +19,8 @@ USAGE = ("Usage: scientific-method-engine <operand|operand-candidates|target|bou
|
|
|
19
19
|
"callees compares its edges with an ExportCallEdges.java export given as ghidraCallEdges.\n"
|
|
20
20
|
"trace, arguments, effects, returns, guards, memory and allocation check relationalControls:\n"
|
|
21
21
|
"a violated control fails the report; an undecided one is reported and never counts as held.\n"
|
|
22
|
-
"Declared table continuations are separate conditional paths
|
|
22
|
+
"Declared table continuations are separate conditional paths that spend continuationBudget\n"
|
|
23
|
+
"(paths, totalSteps, maxSteps, visitLimit, stringIterations); ordinary computed transfers remain stopped.\n"
|
|
23
24
|
"Port accesses and interrupts are hardware-boundary events; portInputs supplies port reads as assumptions.\n"
|
|
24
25
|
"callModels[].preservesMemory keeps explicit, bounded pre-call byte scopes across a modeled call; other memory stays unknown.\n"
|
|
25
26
|
"Each traced path's loops record lists restart edges and what changed between iterations (loopIterationLimit).\n"
|
|
@@ -12,7 +12,7 @@ from .argument_frames import argument_frames, stack_cleanup
|
|
|
12
12
|
from .result_flow import return_flows
|
|
13
13
|
from .image import Image, integer
|
|
14
14
|
from .trace import (trace, walk, call_target, unsupported_transfer, uncovered, base_mnemonic, OVERLAP_REASON, CONTESTED_REASON,
|
|
15
|
-
RETURNS, INTERRUPTS, PORTS, PORT_INPUTS, port_width)
|
|
15
|
+
RETURNS, INTERRUPTS, PORTS, PORT_INPUTS, port_width, budget_input)
|
|
16
16
|
from .pcode_backend import interrupt_vector
|
|
17
17
|
|
|
18
18
|
|
|
@@ -217,9 +217,9 @@ def uses(image, config):
|
|
|
217
217
|
unverified = {g["site"] for g in gaps if g.get("reason") == OVERLAP_REASON} | set(contested)
|
|
218
218
|
matches, unresolved, unique = [], [], set()
|
|
219
219
|
# Trace each established entry independently; never decode a whole segment as one stream.
|
|
220
|
-
remaining =
|
|
220
|
+
remaining = budget_input(config, "totalSteps")
|
|
221
221
|
# One string iteration budget spans every traced entry, as totalSteps does.
|
|
222
|
-
string_remaining =
|
|
222
|
+
string_remaining = budget_input(config, "stringIterations")
|
|
223
223
|
entry_limit = integer(config.get("entryLimit", 64), 1, 256, "entryLimit")
|
|
224
224
|
# CFG points where value propagation stopped (or never started), with why; operands after them are inventoried below.
|
|
225
225
|
stops = {}
|
|
@@ -88,6 +88,8 @@ def return_flows(report, config):
|
|
|
88
88
|
consumer_limit = integer(config.get("returnConsumerLimit", 256), 1, 10000, "return consumer limit")
|
|
89
89
|
analysis_limit = integer(config.get("returnFlowAnalysisLimit", 1000000), 1, 10000000, "return flow analysis limit")
|
|
90
90
|
steps, capped = 0, False
|
|
91
|
+
# Gaps raised while declared-table continuations ran say nothing about an ordinary path.
|
|
92
|
+
ordinary_gaps = [g for g in report["gaps"] if g.get("route") != "declaredContinuation"]
|
|
91
93
|
for path in report["paths"]:
|
|
92
94
|
events = path["events"]
|
|
93
95
|
event_values = {}
|
|
@@ -138,7 +140,7 @@ def return_flows(report, config):
|
|
|
138
140
|
path["returnFlows"] = {"results": flows, "resultsOmitted": omitted, "resultLimit": limit,
|
|
139
141
|
"consumerLimit": consumer_limit,
|
|
140
142
|
"complete": not omitted and all(not f["consumersOmitted"] and f["consumerScanComplete"] for f in flows)
|
|
141
|
-
and path["returned"] and not
|
|
143
|
+
and path["returned"] and not ordinary_gaps,
|
|
142
144
|
"interpretation": "conditional static dependency paths; encodings are declared evidence, not live occurrence; a branch never establishes initialization, accepted contents or extent"}
|
|
143
145
|
report["returnFlowAnalysis"] = {"limit": analysis_limit, "steps": steps, "capped": capped}
|
|
144
146
|
return report
|
|
@@ -279,20 +279,55 @@ def snapshot(state):
|
|
|
279
279
|
return {name: state.reg(name).report() for name in ALIASES}
|
|
280
280
|
|
|
281
281
|
|
|
282
|
+
STRING_BUDGET_STOP = "String iteration budget exhausted"
|
|
283
|
+
# The accepted range and default of each ordinary path budget input. continuationBudget takes the
|
|
284
|
+
# same ranges under the names in CONTINUATION_BUDGET_FIELDS, except that its paths may be 0.
|
|
285
|
+
PATH_BUDGET_INPUTS = {"maxPaths": (1, 256, 64), "totalSteps": (1, 100000, 20000), "maxSteps": (1, 10000, 512),
|
|
286
|
+
"visitLimit": (1, 4096, 4), "stringIterations": (0, 65536, 4096)}
|
|
287
|
+
CONTINUATION_BUDGET_FIELDS = {"paths": "maxPaths", "totalSteps": "totalSteps", "maxSteps": "maxSteps",
|
|
288
|
+
"visitLimit": "visitLimit", "stringIterations": "stringIterations"}
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def budget_input(config, name):
|
|
292
|
+
"""Return the ordinary budget input name from config, or its default, rejecting out-of-range values."""
|
|
293
|
+
low, high, default = PATH_BUDGET_INPUTS[name]
|
|
294
|
+
return integer(config.get(name, default), low, high, name)
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def continuation_range(field):
|
|
298
|
+
low, high, _ = PATH_BUDGET_INPUTS[CONTINUATION_BUDGET_FIELDS[field]]
|
|
299
|
+
return (0 if field == "paths" else low), high
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def validate_continuation_budget(config):
|
|
303
|
+
"""Return the fields a config sets in continuationBudget, rejecting unknown keys and out-of-range values."""
|
|
304
|
+
budget = config.get("continuationBudget", {})
|
|
305
|
+
if not isinstance(budget, dict):
|
|
306
|
+
raise ValueError("continuationBudget must be an object")
|
|
307
|
+
unknown_keys = sorted(set(budget) - set(CONTINUATION_BUDGET_FIELDS))
|
|
308
|
+
if unknown_keys:
|
|
309
|
+
raise ValueError("continuationBudget accepts only " + ", ".join(CONTINUATION_BUDGET_FIELDS)
|
|
310
|
+
+ "; unknown: " + ", ".join(unknown_keys))
|
|
311
|
+
return {key: integer(value, *continuation_range(key), "continuationBudget." + key)
|
|
312
|
+
for key, value in budget.items()}
|
|
313
|
+
|
|
314
|
+
|
|
282
315
|
def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
283
316
|
"""Trace bounded paths, preserving declared-table continuations as separate conditional evidence.
|
|
284
317
|
|
|
285
318
|
Ordinary paths run first. A path stopped at a declared indirect jump is then
|
|
286
|
-
continued once per surviving table target
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
319
|
+
continued once per surviving table target. Continuations spend their own
|
|
320
|
+
continuationBudget, so ordinary paths are the same with or without them, and
|
|
321
|
+
what the ordinary paths spend never leaves the continuations without budget.
|
|
322
|
+
Callers that read only ordinary paths pass continue_declared_jumps=False.
|
|
323
|
+
Callers that never report the paths pass track_loops=False, and their paths
|
|
324
|
+
carry no ``loops`` record.
|
|
290
325
|
"""
|
|
291
326
|
entry = integer(config.get("entry"), 0, len(image.data) - 1, "entry")
|
|
292
327
|
if not any(entry in r["entries"] for r in image.regions):
|
|
293
328
|
raise ValueError("Trace entry must be an established region entry")
|
|
294
|
-
max_steps =
|
|
295
|
-
max_paths =
|
|
329
|
+
max_steps = budget_input(config, "maxSteps")
|
|
330
|
+
max_paths = budget_input(config, "maxPaths")
|
|
296
331
|
max_depth = integer(config.get("maxDepth", 8), 1, 32, "maxDepth")
|
|
297
332
|
integer(config.get("returnBytes", image.bits // 8), 2, 4, "returnBytes")
|
|
298
333
|
if config.get("returnBytes", image.bits // 8) not in ((4,) if image.flat else (2, 4)):
|
|
@@ -322,6 +357,7 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
322
357
|
for r, n in case.get("registers", {}).items():
|
|
323
358
|
if r not in ALIASES or type(n) is not int or not 0 <= n < 1 << ALIASES[r][2]:
|
|
324
359
|
raise ValueError("Invalid model register")
|
|
360
|
+
explicit_continuation_budget = validate_continuation_budget(config)
|
|
325
361
|
root = State(entry, image, config)
|
|
326
362
|
# Each path carries its own loop record; forks copy it with the rest of the state.
|
|
327
363
|
root.loops = (LoopTracker(integer(config.get("loopIterationLimit", 64), 1, 1024, "loopIterationLimit"))
|
|
@@ -335,11 +371,18 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
335
371
|
created = 1
|
|
336
372
|
total_steps = 0
|
|
337
373
|
total_string_steps = 0
|
|
338
|
-
string_limit =
|
|
339
|
-
total_limit =
|
|
374
|
+
string_limit = budget_input(config, "stringIterations")
|
|
375
|
+
total_limit = budget_input(config, "totalSteps")
|
|
340
376
|
checkpoints = set(config.get("checkpoints", []))
|
|
341
377
|
# How often one path may pass the same instruction; a loop with a known bound needs it raised.
|
|
342
|
-
visit_limit =
|
|
378
|
+
visit_limit = budget_input(config, "visitLimit")
|
|
379
|
+
# An unset field takes the value of the matching ordinary input.
|
|
380
|
+
continuation_budget = {"paths": max_paths, "totalSteps": total_limit, "maxSteps": max_steps,
|
|
381
|
+
"visitLimit": visit_limit, "stringIterations": string_limit, **explicit_continuation_budget}
|
|
382
|
+
ordinary_max_paths = max_paths
|
|
383
|
+
# Set once every ordinary path has finished. From then on every traced state is a continuation.
|
|
384
|
+
continuing = False
|
|
385
|
+
first_continuation_gap = None
|
|
343
386
|
|
|
344
387
|
def charge(n):
|
|
345
388
|
nonlocal total_string_steps
|
|
@@ -357,6 +400,9 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
357
400
|
string_effect(s, ins, count, remaining)
|
|
358
401
|
|
|
359
402
|
def finish(s, reason=None, returned=False):
|
|
403
|
+
if continuing and reason and reason.startswith(STRING_BUDGET_STOP):
|
|
404
|
+
# machine.py names no budget; a continuation's string iterations come from continuationBudget.
|
|
405
|
+
reason = "Continuation s" + reason[1:]
|
|
360
406
|
path = {"returned": returned, "stop": reason, "stopSite": None if returned else s.at, "steps": s.steps,
|
|
361
407
|
"instructionPath": s.path, "guards": s.guards, "events": s.events,
|
|
362
408
|
"registers": snapshot(s), "conditionalModels": s.conditional}
|
|
@@ -376,21 +422,6 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
376
422
|
nonlocal created, boundary_budget
|
|
377
423
|
declaration = image.indirect_jumps[s.at]
|
|
378
424
|
ins = image.decode(s.at)
|
|
379
|
-
root_entry = s.frames[-1]["entry"]
|
|
380
|
-
if root_entry not in boundary_cache:
|
|
381
|
-
if boundary_budget < 1:
|
|
382
|
-
global_gaps.append({"site": s.at, "reason": "conditional table boundary instruction limit"})
|
|
383
|
-
return
|
|
384
|
-
seen, walk_gaps, _, _, contested = walk(image, [root_entry], boundary_budget)
|
|
385
|
-
# walk drops rejected overlapping starts and contested instructions from seen,
|
|
386
|
-
# but it decoded them, so they are charged with the established ones.
|
|
387
|
-
overlapping = sum(g["reason"] == OVERLAP_REASON for g in walk_gaps)
|
|
388
|
-
boundary_budget -= max(1, len(seen) + len(contested) + overlapping)
|
|
389
|
-
# A truncated walk never saw the instructions that could contest a target start.
|
|
390
|
-
if any(g["reason"] == "instruction limit" for g in walk_gaps):
|
|
391
|
-
seen = {}
|
|
392
|
-
boundary_cache[root_entry] = seen
|
|
393
|
-
seen = boundary_cache[root_entry]
|
|
394
425
|
try:
|
|
395
426
|
value = s.get(ins, ins.operands[0], image)
|
|
396
427
|
address = s.address(ins, ins.operands[0]) if ins.operands[0].type == X86_OP_MEM else None
|
|
@@ -416,6 +447,28 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
416
447
|
if previous is not None and row["rawOffset"] not in previous:
|
|
417
448
|
continue
|
|
418
449
|
groups.setdefault(row["target"], []).append(row)
|
|
450
|
+
if not groups:
|
|
451
|
+
# No table row agrees with the operand, so no route exists to drop or to walk to.
|
|
452
|
+
return
|
|
453
|
+
if created >= max_paths:
|
|
454
|
+
# Spent or zero path budget: the routes are not followed, so no boundary walk is needed.
|
|
455
|
+
global_gaps.append({"site": s.at, "reason": "path limit"})
|
|
456
|
+
return
|
|
457
|
+
root_entry = s.frames[-1]["entry"]
|
|
458
|
+
if root_entry not in boundary_cache:
|
|
459
|
+
if boundary_budget < 1:
|
|
460
|
+
global_gaps.append({"site": s.at, "reason": "conditional table boundary instruction limit"})
|
|
461
|
+
return
|
|
462
|
+
seen, walk_gaps, _, _, contested = walk(image, [root_entry], boundary_budget)
|
|
463
|
+
# walk drops rejected overlapping starts and contested instructions from seen,
|
|
464
|
+
# but it decoded them, so they are charged with the established ones.
|
|
465
|
+
overlapping = sum(g["reason"] == OVERLAP_REASON for g in walk_gaps)
|
|
466
|
+
boundary_budget -= max(1, len(seen) + len(contested) + overlapping)
|
|
467
|
+
# A truncated walk never saw the instructions that could contest a target start.
|
|
468
|
+
if any(g["reason"] == "instruction limit" for g in walk_gaps):
|
|
469
|
+
seen = {}
|
|
470
|
+
boundary_cache[root_entry] = seen
|
|
471
|
+
seen = boundary_cache[root_entry]
|
|
419
472
|
for target, rows in groups.items():
|
|
420
473
|
if target not in seen:
|
|
421
474
|
global_gaps.append({"site": s.at, "target": target,
|
|
@@ -435,26 +488,41 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
435
488
|
{"segment": address[0].report(), "offset": address[1].report(), "segmentRegister": address[2]},
|
|
436
489
|
"meaning": "conditional target choice from source table; selector, live table contents and reachability unverified"}
|
|
437
490
|
child.declared_jump_assumptions = [*getattr(child, "declared_jump_assumptions", []), assumption]
|
|
491
|
+
if not hasattr(child, "continuation_steps"):
|
|
492
|
+
# Per-path continuation limits count from the first declared jump the path continues past.
|
|
493
|
+
child.continuation_steps, child.continuation_visits = 0, {}
|
|
438
494
|
child.event("declared-jump-continuation", **{k: v for k, v in assumption.items() if k != "site"})
|
|
439
495
|
child.at = target
|
|
440
496
|
pending.append(child)
|
|
441
497
|
created += 1
|
|
442
498
|
|
|
443
499
|
# Ordinary paths all finish before the first declared continuation runs; their gaps come first.
|
|
444
|
-
ordinary_gaps = None
|
|
445
500
|
while pending or deferred:
|
|
446
501
|
if not pending:
|
|
447
|
-
if
|
|
448
|
-
|
|
502
|
+
if not continuing:
|
|
503
|
+
# Ordinary tracing is over. Its counters are final, and continuations start on their own budget.
|
|
504
|
+
continuing = True
|
|
505
|
+
ordinary_steps, ordinary_string_steps = total_steps, total_string_steps
|
|
506
|
+
created = total_steps = total_string_steps = 0
|
|
507
|
+
max_paths = continuation_budget["paths"]
|
|
508
|
+
total_limit = continuation_budget["totalSteps"]
|
|
509
|
+
string_limit = continuation_budget["stringIterations"]
|
|
510
|
+
first_continuation_gap = len(global_gaps)
|
|
449
511
|
declared_continuations(deferred.pop(0))
|
|
450
512
|
continue
|
|
451
513
|
state = pending.pop()
|
|
452
514
|
try:
|
|
453
515
|
while True:
|
|
454
|
-
if
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
516
|
+
if continuing:
|
|
517
|
+
if state.continuation_steps >= continuation_budget["maxSteps"]:
|
|
518
|
+
raise StopPath("continuation step limit; loop progress unresolved")
|
|
519
|
+
if total_steps >= total_limit:
|
|
520
|
+
raise StopPath("continuation instruction budget exhausted")
|
|
521
|
+
else:
|
|
522
|
+
if state.steps >= max_steps:
|
|
523
|
+
raise StopPath("step limit; loop progress unresolved")
|
|
524
|
+
if total_steps >= total_limit:
|
|
525
|
+
raise StopPath("total instruction budget exhausted")
|
|
458
526
|
total_steps += 1
|
|
459
527
|
at = state.at
|
|
460
528
|
ins = image.decode(at)
|
|
@@ -465,7 +533,13 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
465
533
|
if state.loops is not None:
|
|
466
534
|
state.loops.arrive(state, at, ins)
|
|
467
535
|
state.visits[at] = state.visits.get(at, 0) + 1
|
|
468
|
-
if
|
|
536
|
+
if continuing:
|
|
537
|
+
state.continuation_steps += 1
|
|
538
|
+
state.continuation_visits[at] = state.continuation_visits.get(at, 0) + 1
|
|
539
|
+
if state.continuation_visits[at] > continuation_budget["visitLimit"]:
|
|
540
|
+
raise StopPath(f"instruction repeated more than {continuation_budget['visitLimit']} times after "
|
|
541
|
+
"the declared jump; raise continuationBudget.visitLimit or read the loop's bound")
|
|
542
|
+
elif state.visits[at] > visit_limit:
|
|
469
543
|
raise StopPath(f"instruction repeated more than {visit_limit} times; raise visitLimit or read the loop's bound")
|
|
470
544
|
if at in checkpoints:
|
|
471
545
|
state.event("checkpoint", registers=snapshot(state))
|
|
@@ -713,8 +787,19 @@ def trace(image, config, continue_declared_jumps=True, track_loops=True):
|
|
|
713
787
|
state.at = following
|
|
714
788
|
except StopPath as error:
|
|
715
789
|
finish(state, str(error))
|
|
790
|
+
if continuing:
|
|
791
|
+
# Only continuation states are traced after the switch: deferred states are popped only when
|
|
792
|
+
# pending is empty, and every state pending holds from then on descends from a continuation.
|
|
793
|
+
continuation_steps, continuation_string_steps = total_steps, total_string_steps
|
|
794
|
+
for gap in global_gaps[first_continuation_gap:]:
|
|
795
|
+
gap["route"] = "declaredContinuation"
|
|
796
|
+
else:
|
|
797
|
+
ordinary_steps, ordinary_string_steps = total_steps, total_string_steps
|
|
798
|
+
continuation_steps = continuation_string_steps = 0
|
|
716
799
|
return {"paths": outputs, "declaredContinuationPaths": conditional_outputs, "gaps": global_gaps,
|
|
717
|
-
"hardwareBoundaries": hardware_placement(outputs, conditional_outputs, global_gaps[:
|
|
718
|
-
"completeWithinModel": not global_gaps and bool(outputs) and all(p["returned"] for p in outputs),
|
|
719
|
-
"nativeReachability": "unconfirmed", "stepsUsed":
|
|
720
|
-
"
|
|
800
|
+
"hardwareBoundaries": hardware_placement(outputs, conditional_outputs, global_gaps[:first_continuation_gap]),
|
|
801
|
+
"completeWithinModel": not global_gaps[:first_continuation_gap] and bool(outputs) and all(p["returned"] for p in outputs),
|
|
802
|
+
"nativeReachability": "unconfirmed", "stepsUsed": ordinary_steps, "stringIterationsUsed": ordinary_string_steps,
|
|
803
|
+
"continuationStepsUsed": continuation_steps, "continuationStringIterationsUsed": continuation_string_steps,
|
|
804
|
+
"limits": {"steps": max_steps, "paths": ordinary_max_paths, "depth": max_depth,
|
|
805
|
+
"continuation": continuation_budget}}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""Declared-table continuations spend their own budget and never change the ordinary paths."""
|
|
2
|
+
import json
|
|
3
|
+
import unittest
|
|
4
|
+
import test_dispatch # noqa: F401 (puts the engine sources on sys.path)
|
|
5
|
+
from scientific_method_engine.x86.image import Image
|
|
6
|
+
from scientific_method_engine.x86.reports import run_report
|
|
7
|
+
from scientific_method_engine.x86.trace import trace
|
|
8
|
+
|
|
9
|
+
RETURN_ONE = bytes.fromhex("b8 01 00 c3")
|
|
10
|
+
SPIN = bytes.fromhex("eb fe")
|
|
11
|
+
COPY_TWO = bytes.fromhex("b9 02 00 fc f3 a4 c3")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def fan_out(stages, targets=(RETURN_ONE, bytes.fromhex("b8 02 00 c3"))):
|
|
15
|
+
"""Build a function whose first branch reaches a declared table jump and whose other
|
|
16
|
+
branch forks on `stages` independent unknown bytes, so ordinary routes number 2**stages."""
|
|
17
|
+
code = bytearray(bytes.fromhex("72 00"))
|
|
18
|
+
for i in range(stages):
|
|
19
|
+
address = 0x100 + i
|
|
20
|
+
code += bytes([0x80, 0x3E, address & 0xFF, address >> 8, 0x00, 0x74, 0x00])
|
|
21
|
+
code += b"\xc3"
|
|
22
|
+
dispatcher = len(code)
|
|
23
|
+
code[1] = dispatcher - 2
|
|
24
|
+
code += bytes.fromhex("ff e3")
|
|
25
|
+
starts = []
|
|
26
|
+
for target in targets:
|
|
27
|
+
starts.append(len(code))
|
|
28
|
+
code += target
|
|
29
|
+
end = len(code)
|
|
30
|
+
table = len(code)
|
|
31
|
+
for start in starts:
|
|
32
|
+
code += start.to_bytes(2, "little")
|
|
33
|
+
config = {"entry": 0, "registers": {"ds": 0x2000, "es": 0x3000, "si": 0x10, "di": 0x20},
|
|
34
|
+
"regions": [{"name": "code", "start": 0, "end": end, "segment": 4096, "ip": 0,
|
|
35
|
+
"entries": [0], "evidence": "constructed mappings"}],
|
|
36
|
+
"indirectJumps": [{"site": dispatcher, "evidence": "constructed BX consumer", "exhaustive": True,
|
|
37
|
+
"table": {"start": table, "count": len(targets), "stride": 2,
|
|
38
|
+
"evidence": "constructed words"}}]}
|
|
39
|
+
return bytes(code), config, dispatcher
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def ordinary(report):
|
|
43
|
+
"""Everything a report says about ordinary paths, including derived analyses such as returnFlows."""
|
|
44
|
+
return json.dumps({"paths": report["paths"], "stepsUsed": report["stepsUsed"],
|
|
45
|
+
"stringIterationsUsed": report["stringIterationsUsed"],
|
|
46
|
+
"completeWithinModel": report["completeWithinModel"],
|
|
47
|
+
"effectPaths": report.get("effectOrdering", {}).get("paths"),
|
|
48
|
+
"allPathsRead": report.get("effectOrdering", {}).get("allPathsRead"),
|
|
49
|
+
"gaps": [g for g in report["gaps"] if "route" not in g]}, sort_keys=True)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ContinuationBudgetTests(unittest.TestCase):
|
|
53
|
+
def test_continuations_run_after_ordinary_paths_spend_the_shared_budget(self):
|
|
54
|
+
data, config, dispatcher = fan_out(4)
|
|
55
|
+
r = run_report(data, {**config, "maxPaths": 8}, "effects")
|
|
56
|
+
self.assertEqual(len(r["paths"]), 8)
|
|
57
|
+
self.assertTrue(any(g["reason"] == "path limit" and "route" not in g for g in r["gaps"]))
|
|
58
|
+
routes = r["declaredContinuationPaths"]
|
|
59
|
+
self.assertEqual(sorted(p["registers"]["ax"]["value"] for p in routes), [1, 2])
|
|
60
|
+
self.assertTrue(all(p["returned"] and p["declaredJumpAssumptions"][0]["site"] == dispatcher for p in routes))
|
|
61
|
+
self.assertEqual(r["limits"]["paths"], 8)
|
|
62
|
+
self.assertEqual(r["limits"]["continuation"],
|
|
63
|
+
{"paths": 8, "totalSteps": 20000, "maxSteps": 512, "visitLimit": 4, "stringIterations": 4096})
|
|
64
|
+
self.assertEqual(r["continuationStepsUsed"], 4)
|
|
65
|
+
self.assertFalse(r["completeWithinModel"])
|
|
66
|
+
self.assertTrue(all(not p["effectCompleteWithinModel"] for p in r["effectOrdering"]["declaredContinuationPaths"]))
|
|
67
|
+
|
|
68
|
+
def test_ordinary_paths_are_identical_whatever_the_continuations_spend(self):
|
|
69
|
+
# Two stages leave every ordinary path returned except the one stopped at the jump.
|
|
70
|
+
for stages, max_paths in ((4, 8), (2, 64)):
|
|
71
|
+
data, config, _ = fan_out(stages)
|
|
72
|
+
config = {**config, "maxPaths": max_paths}
|
|
73
|
+
image = Image(data, config)
|
|
74
|
+
unread = trace(image, image.config, continue_declared_jumps=False)
|
|
75
|
+
for command in ("trace", "returns", "effects"):
|
|
76
|
+
baseline = run_report(data, {**config, "continuationBudget": {"paths": 0}}, command)
|
|
77
|
+
if command == "trace":
|
|
78
|
+
self.assertEqual(json.dumps(unread["paths"], sort_keys=True), json.dumps(baseline["paths"], sort_keys=True))
|
|
79
|
+
for budget in ({}, {"paths": 1}, {"paths": 256, "totalSteps": 100000, "maxSteps": 10000,
|
|
80
|
+
"visitLimit": 4096, "stringIterations": 65536},
|
|
81
|
+
{"totalSteps": 1}, {"maxSteps": 1}):
|
|
82
|
+
r = run_report(data, {**config, "continuationBudget": budget}, command)
|
|
83
|
+
self.assertEqual(ordinary(r), ordinary(baseline), (stages, command, budget))
|
|
84
|
+
|
|
85
|
+
def test_raising_the_continuation_budget_leaves_the_ordinary_report_size_alone(self):
|
|
86
|
+
data, config, _ = fan_out(6)
|
|
87
|
+
small = run_report(data, {**config, "maxPaths": 4}, "trace")
|
|
88
|
+
large = run_report(data, {**config, "maxPaths": 4, "continuationBudget": {"paths": 256}}, "trace")
|
|
89
|
+
self.assertEqual(len(large["paths"]), 4)
|
|
90
|
+
self.assertEqual(ordinary(large), ordinary(small))
|
|
91
|
+
self.assertEqual(len(large["declaredContinuationPaths"]), 2)
|
|
92
|
+
|
|
93
|
+
def test_path_limit_is_a_continuation_gap(self):
|
|
94
|
+
data, config, dispatcher = fan_out(2)
|
|
95
|
+
r = run_report(data, {**config, "continuationBudget": {"paths": 0}}, "trace")
|
|
96
|
+
self.assertFalse(r["declaredContinuationPaths"])
|
|
97
|
+
self.assertIn({"site": dispatcher, "reason": "path limit", "route": "declaredContinuation"}, r["gaps"])
|
|
98
|
+
self.assertFalse(r["completeWithinModel"])
|
|
99
|
+
r = run_report(data, {**config, "continuationBudget": {"paths": 1}}, "trace")
|
|
100
|
+
self.assertEqual(len(r["declaredContinuationPaths"]), 1)
|
|
101
|
+
self.assertIn({"site": dispatcher, "reason": "path limit", "route": "declaredContinuation"}, r["gaps"])
|
|
102
|
+
|
|
103
|
+
def test_a_spent_path_budget_leaves_one_gap_per_stopped_path(self):
|
|
104
|
+
# No boundary walk runs, so a boundary budget too small for one still leaves only the path-limit gap.
|
|
105
|
+
data, config, dispatcher = fan_out(1)
|
|
106
|
+
r = run_report(data, {**config, "instructionLimit": 1, "continuationBudget": {"paths": 0}}, "trace")
|
|
107
|
+
self.assertEqual([g for g in r["gaps"] if g.get("route")],
|
|
108
|
+
[{"site": dispatcher, "reason": "path limit", "route": "declaredContinuation"}])
|
|
109
|
+
|
|
110
|
+
def test_a_spent_path_budget_leaves_no_gap_where_no_row_matches(self):
|
|
111
|
+
# A concrete operand outside the table has no route to drop, whatever the path budget.
|
|
112
|
+
data, config, _ = fan_out(1)
|
|
113
|
+
config = {**config, "registers": {**config["registers"], "bx": 0x7777}}
|
|
114
|
+
for budget in ({}, {"paths": 0}):
|
|
115
|
+
r = run_report(data, {**config, "continuationBudget": budget}, "trace")
|
|
116
|
+
self.assertFalse(r["declaredContinuationPaths"])
|
|
117
|
+
self.assertFalse([g for g in r["gaps"] if g.get("route")], budget)
|
|
118
|
+
|
|
119
|
+
def test_forks_inside_a_continuation_spend_its_paths(self):
|
|
120
|
+
fork = bytes.fromhex("80 3e 00 02 00 74 00 c3")
|
|
121
|
+
data, config, _ = fan_out(2, targets=(fork,))
|
|
122
|
+
r = run_report(data, {**config, "continuationBudget": {"paths": 1}}, "trace")
|
|
123
|
+
self.assertEqual(len(r["declaredContinuationPaths"]), 1)
|
|
124
|
+
gaps = [g for g in r["gaps"] if g.get("route") == "declaredContinuation"]
|
|
125
|
+
self.assertEqual([g["reason"] for g in gaps], ["path limit"])
|
|
126
|
+
r = run_report(data, {**config, "continuationBudget": {"paths": 2}}, "trace")
|
|
127
|
+
self.assertEqual(len(r["declaredContinuationPaths"]), 2)
|
|
128
|
+
self.assertFalse(any(g.get("route") for g in r["gaps"]))
|
|
129
|
+
|
|
130
|
+
def test_total_and_per_path_step_limits_stop_continuations(self):
|
|
131
|
+
data, config, _ = fan_out(2)
|
|
132
|
+
r = run_report(data, {**config, "continuationBudget": {"totalSteps": 1}}, "trace")
|
|
133
|
+
# Each route needs two instructions, so the one budgeted step stops both.
|
|
134
|
+
self.assertEqual([p["stop"] for p in r["declaredContinuationPaths"]],
|
|
135
|
+
["continuation instruction budget exhausted"] * 2)
|
|
136
|
+
self.assertEqual(r["continuationStepsUsed"], 1)
|
|
137
|
+
r = run_report(data, {**config, "continuationBudget": {"maxSteps": 1}}, "trace")
|
|
138
|
+
self.assertTrue(all(p["stop"] == "continuation step limit; loop progress unresolved"
|
|
139
|
+
for p in r["declaredContinuationPaths"]))
|
|
140
|
+
self.assertFalse(any(p["returned"] for p in r["declaredContinuationPaths"]))
|
|
141
|
+
self.assertFalse(r["completeWithinModel"])
|
|
142
|
+
|
|
143
|
+
def test_continuation_steps_count_from_the_declared_jump(self):
|
|
144
|
+
# The ordinary prefix (jc, jmp bx) takes two steps; maxSteps 2 would leave a whole-path count no room.
|
|
145
|
+
data, config, _ = fan_out(2)
|
|
146
|
+
r = run_report(data, {**config, "maxSteps": 2}, "trace")
|
|
147
|
+
self.assertTrue(all(p["returned"] for p in r["declaredContinuationPaths"]))
|
|
148
|
+
self.assertTrue(all(p["steps"] == 4 for p in r["declaredContinuationPaths"]))
|
|
149
|
+
|
|
150
|
+
def test_visit_limit_counts_repeats_after_the_declared_jump(self):
|
|
151
|
+
data, config, _ = fan_out(2, targets=(SPIN,))
|
|
152
|
+
r = run_report(data, {**config, "visitLimit": 2, "continuationBudget": {"visitLimit": 3}}, "trace")
|
|
153
|
+
(route,) = r["declaredContinuationPaths"]
|
|
154
|
+
self.assertEqual(route["stop"], "instruction repeated more than 3 times after the declared jump; "
|
|
155
|
+
"raise continuationBudget.visitLimit or read the loop's bound")
|
|
156
|
+
self.assertEqual(route["instructionPath"].count(route["stopSite"]), 4)
|
|
157
|
+
self.assertFalse(r["completeWithinModel"])
|
|
158
|
+
|
|
159
|
+
def test_string_iteration_limit_stops_a_continuation(self):
|
|
160
|
+
data, config, _ = fan_out(2, targets=(COPY_TWO,))
|
|
161
|
+
r = run_report(data, config, "trace")
|
|
162
|
+
self.assertTrue(r["declaredContinuationPaths"][0]["returned"])
|
|
163
|
+
self.assertEqual(r["continuationStringIterationsUsed"], 2)
|
|
164
|
+
self.assertEqual(r["stringIterationsUsed"], 0)
|
|
165
|
+
r = run_report(data, {**config, "stringIterations": 0, "continuationBudget": {"stringIterations": 1}}, "trace")
|
|
166
|
+
(route,) = r["declaredContinuationPaths"]
|
|
167
|
+
self.assertFalse(route["returned"])
|
|
168
|
+
self.assertEqual(route["stop"], "Continuation string iteration budget exhausted; remaining effects unresolved")
|
|
169
|
+
|
|
170
|
+
def test_invalid_budgets_are_rejected(self):
|
|
171
|
+
data, config, _ = fan_out(1)
|
|
172
|
+
for budget in ([], {"path": 1}, {"paths": 257}, {"paths": -1}, {"totalSteps": 0}, {"maxSteps": 10001},
|
|
173
|
+
{"visitLimit": 0}, {"stringIterations": 65537}, {"paths": True}, {"paths": 1.5}):
|
|
174
|
+
with self.assertRaises(ValueError, msg=budget):
|
|
175
|
+
run_report(data, {**config, "continuationBudget": budget}, "trace")
|
|
176
|
+
|
|
177
|
+
def test_each_field_accepts_the_range_of_its_ordinary_input(self):
|
|
178
|
+
data, config, _ = fan_out(1)
|
|
179
|
+
|
|
180
|
+
def accepted(change):
|
|
181
|
+
try:
|
|
182
|
+
run_report(data, {**config, **change}, "trace")
|
|
183
|
+
return True
|
|
184
|
+
except ValueError:
|
|
185
|
+
return False
|
|
186
|
+
|
|
187
|
+
fields = {"paths": "maxPaths", "totalSteps": "totalSteps", "maxSteps": "maxSteps",
|
|
188
|
+
"visitLimit": "visitLimit", "stringIterations": "stringIterations"}
|
|
189
|
+
for field, ordinary in fields.items():
|
|
190
|
+
for value in (-1, 0, 1, 2, 256, 257, 4096, 4097, 10000, 10001, 65536, 65537, 100000, 100001):
|
|
191
|
+
expected = accepted({ordinary: value}) or (field == "paths" and value == 0)
|
|
192
|
+
self.assertEqual(accepted({"continuationBudget": {field: value}}), expected, (field, value))
|
|
193
|
+
self.assertFalse(accepted({"maxPaths": 0}))
|
|
194
|
+
self.assertTrue(accepted({"continuationBudget": {"paths": 0}}))
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
if __name__ == "__main__":
|
|
198
|
+
unittest.main()
|
{scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_table_continuations.py
RENAMED
|
@@ -47,7 +47,7 @@ class TableContinuationTests(unittest.TestCase):
|
|
|
47
47
|
|
|
48
48
|
def test_limits_do_not_leave_a_positive_continuation_contract(self):
|
|
49
49
|
data, config = fixture()
|
|
50
|
-
for change in ({"
|
|
50
|
+
for change in ({"continuationBudget": {"paths": 0}}, {"instructionLimit": 1}):
|
|
51
51
|
r = run_report(data, {**config, **change}, "trace")
|
|
52
52
|
self.assertFalse(any(p["returned"] for p in r["declaredContinuationPaths"]))
|
|
53
53
|
self.assertFalse(r["completeWithinModel"])
|
|
@@ -125,7 +125,9 @@ class TableContinuationTests(unittest.TestCase):
|
|
|
125
125
|
self.assertEqual([(p["returned"], p["stop"]) for p in declared["paths"]],
|
|
126
126
|
[(p["returned"], p["stop"]) for p in plain["paths"]])
|
|
127
127
|
self.assertEqual(len(declared["paths"]), 3)
|
|
128
|
-
|
|
128
|
+
# The ordinary paths spent all three paths, and the continuations still start on their own budget.
|
|
129
|
+
self.assertEqual(len(declared["declaredContinuationPaths"]), 3)
|
|
130
|
+
self.assertTrue(all(p["returned"] for p in declared["declaredContinuationPaths"]))
|
|
129
131
|
|
|
130
132
|
def test_operand_read_stays_out_of_the_stopped_ordinary_path(self):
|
|
131
133
|
data, config = fixture()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_effect_order.py
RENAMED
|
File without changes
|
|
File without changes
|
{scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_memory_scopes.py
RENAMED
|
File without changes
|
{scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_nested_frame_request.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scientific_method_engine-3.2.0 → scientific_method_engine-4.0.1}/tests/test_relational_controls.py
RENAMED
|
File without changes
|
|
File without changes
|