crosshair-tool 0.0.56__cp39-cp39-macosx_11_0_arm64.whl → 0.0.100__cp39-cp39-macosx_11_0_arm64.whl
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.
- _crosshair_tracers.cpython-39-darwin.so +0 -0
- crosshair/__init__.py +1 -1
- crosshair/_mark_stacks.h +51 -24
- crosshair/_tracers.h +9 -5
- crosshair/_tracers_test.py +19 -9
- crosshair/auditwall.py +9 -8
- crosshair/auditwall_test.py +31 -19
- crosshair/codeconfig.py +3 -2
- crosshair/condition_parser.py +17 -133
- crosshair/condition_parser_test.py +54 -96
- crosshair/conftest.py +1 -1
- crosshair/copyext.py +91 -22
- crosshair/copyext_test.py +33 -0
- crosshair/core.py +259 -203
- crosshair/core_and_libs.py +20 -0
- crosshair/core_regestered_types_test.py +82 -0
- crosshair/core_test.py +693 -664
- crosshair/diff_behavior.py +76 -21
- crosshair/diff_behavior_test.py +132 -23
- crosshair/dynamic_typing.py +128 -18
- crosshair/dynamic_typing_test.py +91 -4
- crosshair/enforce.py +1 -6
- crosshair/enforce_test.py +15 -23
- crosshair/examples/check_examples_test.py +2 -1
- crosshair/fnutil.py +2 -3
- crosshair/fnutil_test.py +0 -7
- crosshair/fuzz_core_test.py +70 -83
- crosshair/libimpl/arraylib.py +10 -7
- crosshair/libimpl/binascii_ch_test.py +30 -0
- crosshair/libimpl/binascii_test.py +67 -0
- crosshair/libimpl/binasciilib.py +150 -0
- crosshair/libimpl/bisectlib_test.py +5 -5
- crosshair/libimpl/builtinslib.py +1002 -682
- crosshair/libimpl/builtinslib_ch_test.py +108 -30
- crosshair/libimpl/builtinslib_test.py +431 -143
- crosshair/libimpl/codecslib.py +22 -2
- crosshair/libimpl/codecslib_test.py +41 -9
- crosshair/libimpl/collectionslib.py +44 -8
- crosshair/libimpl/collectionslib_test.py +108 -20
- crosshair/libimpl/copylib.py +1 -1
- crosshair/libimpl/copylib_test.py +18 -0
- crosshair/libimpl/datetimelib.py +84 -67
- crosshair/libimpl/datetimelib_ch_test.py +12 -7
- crosshair/libimpl/datetimelib_test.py +5 -6
- crosshair/libimpl/decimallib.py +5257 -0
- crosshair/libimpl/decimallib_ch_test.py +78 -0
- crosshair/libimpl/decimallib_test.py +76 -0
- crosshair/libimpl/encodings/_encutil.py +21 -11
- crosshair/libimpl/fractionlib.py +16 -0
- crosshair/libimpl/fractionlib_test.py +80 -0
- crosshair/libimpl/functoolslib.py +19 -7
- crosshair/libimpl/functoolslib_test.py +22 -6
- crosshair/libimpl/hashliblib.py +30 -0
- crosshair/libimpl/hashliblib_test.py +18 -0
- crosshair/libimpl/heapqlib.py +32 -5
- crosshair/libimpl/heapqlib_test.py +15 -12
- crosshair/libimpl/iolib.py +7 -4
- crosshair/libimpl/ipaddresslib.py +8 -0
- crosshair/libimpl/itertoolslib_test.py +1 -1
- crosshair/libimpl/mathlib.py +165 -2
- crosshair/libimpl/mathlib_ch_test.py +44 -0
- crosshair/libimpl/mathlib_test.py +59 -16
- crosshair/libimpl/oslib.py +7 -0
- crosshair/libimpl/pathliblib_test.py +10 -0
- crosshair/libimpl/randomlib.py +1 -0
- crosshair/libimpl/randomlib_test.py +6 -4
- crosshair/libimpl/relib.py +180 -59
- crosshair/libimpl/relib_ch_test.py +26 -2
- crosshair/libimpl/relib_test.py +77 -14
- crosshair/libimpl/timelib.py +35 -13
- crosshair/libimpl/timelib_test.py +13 -3
- crosshair/libimpl/typeslib.py +15 -0
- crosshair/libimpl/typeslib_test.py +36 -0
- crosshair/libimpl/unicodedatalib_test.py +3 -3
- crosshair/libimpl/weakreflib.py +13 -0
- crosshair/libimpl/weakreflib_test.py +69 -0
- crosshair/libimpl/zliblib.py +15 -0
- crosshair/libimpl/zliblib_test.py +13 -0
- crosshair/lsp_server.py +21 -10
- crosshair/main.py +48 -28
- crosshair/main_test.py +59 -14
- crosshair/objectproxy.py +39 -14
- crosshair/objectproxy_test.py +27 -13
- crosshair/opcode_intercept.py +212 -24
- crosshair/opcode_intercept_test.py +172 -18
- crosshair/options.py +0 -1
- crosshair/patch_equivalence_test.py +5 -21
- crosshair/path_cover.py +7 -5
- crosshair/path_search.py +6 -4
- crosshair/path_search_test.py +1 -2
- crosshair/pathing_oracle.py +53 -10
- crosshair/pathing_oracle_test.py +21 -0
- crosshair/pure_importer_test.py +5 -21
- crosshair/register_contract.py +16 -6
- crosshair/register_contract_test.py +2 -14
- crosshair/simplestructs.py +154 -85
- crosshair/simplestructs_test.py +16 -2
- crosshair/smtlib.py +24 -0
- crosshair/smtlib_test.py +14 -0
- crosshair/statespace.py +319 -196
- crosshair/statespace_test.py +45 -0
- crosshair/stubs_parser.py +0 -2
- crosshair/test_util.py +87 -25
- crosshair/test_util_test.py +26 -0
- crosshair/tools/check_init_and_setup_coincide.py +0 -3
- crosshair/tools/generate_demo_table.py +2 -2
- crosshair/tracers.py +141 -49
- crosshair/type_repo.py +11 -4
- crosshair/unicode_categories.py +1 -0
- crosshair/util.py +158 -76
- crosshair/util_test.py +13 -20
- crosshair/watcher.py +4 -4
- crosshair/z3util.py +1 -1
- {crosshair_tool-0.0.56.dist-info → crosshair_tool-0.0.100.dist-info}/METADATA +45 -36
- crosshair_tool-0.0.100.dist-info/RECORD +176 -0
- {crosshair_tool-0.0.56.dist-info → crosshair_tool-0.0.100.dist-info}/WHEEL +2 -1
- crosshair/examples/hypothesis/__init__.py +0 -2
- crosshair/examples/hypothesis/bugs_detected/simple_strategies.py +0 -74
- crosshair_tool-0.0.56.dist-info/RECORD +0 -152
- /crosshair/{examples/hypothesis/bugs_detected/__init__.py → py.typed} +0 -0
- {crosshair_tool-0.0.56.dist-info → crosshair_tool-0.0.100.dist-info}/entry_points.txt +0 -0
- {crosshair_tool-0.0.56.dist-info → crosshair_tool-0.0.100.dist-info/licenses}/LICENSE +0 -0
- {crosshair_tool-0.0.56.dist-info → crosshair_tool-0.0.100.dist-info}/top_level.txt +0 -0
crosshair/core_and_libs.py
CHANGED
|
@@ -11,6 +11,7 @@ from crosshair import opcode_intercept
|
|
|
11
11
|
from crosshair.core import (
|
|
12
12
|
AnalysisMessage,
|
|
13
13
|
MessageType,
|
|
14
|
+
_reset_all_registrations,
|
|
14
15
|
analyze_any,
|
|
15
16
|
analyze_class,
|
|
16
17
|
analyze_function,
|
|
@@ -23,23 +24,32 @@ from crosshair.core import (
|
|
|
23
24
|
# Modules with registrations:
|
|
24
25
|
from crosshair.libimpl import (
|
|
25
26
|
arraylib,
|
|
27
|
+
binasciilib,
|
|
26
28
|
builtinslib,
|
|
27
29
|
codecslib,
|
|
28
30
|
collectionslib,
|
|
29
31
|
copylib,
|
|
30
32
|
datetimelib,
|
|
33
|
+
decimallib,
|
|
34
|
+
fractionlib,
|
|
31
35
|
functoolslib,
|
|
36
|
+
hashliblib,
|
|
32
37
|
heapqlib,
|
|
33
38
|
importliblib,
|
|
34
39
|
iolib,
|
|
40
|
+
ipaddresslib,
|
|
35
41
|
itertoolslib,
|
|
36
42
|
jsonlib,
|
|
37
43
|
mathlib,
|
|
44
|
+
oslib,
|
|
38
45
|
randomlib,
|
|
39
46
|
relib,
|
|
40
47
|
timelib,
|
|
48
|
+
typeslib,
|
|
41
49
|
unicodedatalib,
|
|
42
50
|
urlliblib,
|
|
51
|
+
weakreflib,
|
|
52
|
+
zliblib,
|
|
43
53
|
)
|
|
44
54
|
from crosshair.options import AnalysisKind, AnalysisOptions
|
|
45
55
|
from crosshair.tracers import NoTracing, ResumedTracing
|
|
@@ -71,25 +81,35 @@ __all__ = [
|
|
|
71
81
|
|
|
72
82
|
|
|
73
83
|
def _make_registrations():
|
|
84
|
+
_reset_all_registrations()
|
|
74
85
|
arraylib.make_registrations()
|
|
86
|
+
binasciilib.make_registrations()
|
|
75
87
|
builtinslib.make_registrations()
|
|
76
88
|
codecslib.make_registrations()
|
|
77
89
|
collectionslib.make_registrations()
|
|
78
90
|
copylib.make_registrations()
|
|
79
91
|
datetimelib.make_registrations()
|
|
92
|
+
decimallib.make_registrations()
|
|
80
93
|
functoolslib.make_registrations()
|
|
94
|
+
fractionlib.make_registrations()
|
|
95
|
+
hashliblib.make_registrations()
|
|
81
96
|
heapqlib.make_registrations()
|
|
82
97
|
jsonlib.make_registrations()
|
|
83
98
|
importliblib.make_registrations()
|
|
84
99
|
iolib.make_registrations()
|
|
100
|
+
ipaddresslib.make_registrations()
|
|
85
101
|
itertoolslib.make_registrations()
|
|
86
102
|
mathlib.make_registrations()
|
|
103
|
+
oslib.make_registrations()
|
|
87
104
|
randomlib.make_registrations()
|
|
88
105
|
relib.make_registrations()
|
|
89
106
|
timelib.make_registrations()
|
|
107
|
+
typeslib.make_registrations()
|
|
90
108
|
unicodedatalib.make_registrations()
|
|
91
109
|
urlliblib.make_registrations()
|
|
92
110
|
opcode_intercept.make_registrations()
|
|
111
|
+
weakreflib.make_registrations()
|
|
112
|
+
zliblib.make_registrations()
|
|
93
113
|
|
|
94
114
|
plugin_entries = entry_points(group="crosshair.plugin")
|
|
95
115
|
for plugin_entry in plugin_entries:
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import collections
|
|
2
|
+
import re
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from typing import (
|
|
5
|
+
Any,
|
|
6
|
+
BinaryIO,
|
|
7
|
+
Callable,
|
|
8
|
+
Final,
|
|
9
|
+
List,
|
|
10
|
+
NamedTuple,
|
|
11
|
+
NoReturn,
|
|
12
|
+
SupportsBytes,
|
|
13
|
+
SupportsComplex,
|
|
14
|
+
Union,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
import pytest # type: ignore
|
|
18
|
+
import typing_inspect # type: ignore
|
|
19
|
+
|
|
20
|
+
from crosshair.core import _SIMPLE_PROXIES, proxy_for_type
|
|
21
|
+
from crosshair.dynamic_typing import origin_of
|
|
22
|
+
from crosshair.tracers import ResumedTracing
|
|
23
|
+
from crosshair.util import CrosshairUnsupported, debug, name_of_type
|
|
24
|
+
|
|
25
|
+
"""
|
|
26
|
+
Tests that the builtin and standard library types behave like their
|
|
27
|
+
counterparts.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
possible_args = [
|
|
32
|
+
(),
|
|
33
|
+
(Any,),
|
|
34
|
+
(Any, Any),
|
|
35
|
+
(Any, Any, Any),
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
untested_types = {
|
|
39
|
+
# These types won't check at runtime:
|
|
40
|
+
Union,
|
|
41
|
+
NoReturn,
|
|
42
|
+
Final,
|
|
43
|
+
BinaryIO,
|
|
44
|
+
SupportsBytes,
|
|
45
|
+
SupportsComplex,
|
|
46
|
+
# Callable actually works ok but can throw IgnoreAttempt
|
|
47
|
+
collections.abc.Callable,
|
|
48
|
+
# TODO: make a symbolic NamedTuple that intercepts attribute access:
|
|
49
|
+
NamedTuple,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
comparisons: List = []
|
|
54
|
+
for typ, creator in _SIMPLE_PROXIES.items():
|
|
55
|
+
if typ in untested_types:
|
|
56
|
+
continue
|
|
57
|
+
name = name_of_type(typ)
|
|
58
|
+
comparisons.append(pytest.param(typ, creator, id=name))
|
|
59
|
+
if typing_inspect.is_generic_type(typ) and hasattr(typ, "__getitem__"):
|
|
60
|
+
for nargs in range(1, 3):
|
|
61
|
+
type_args = tuple([Any for _ in range(nargs)])
|
|
62
|
+
try:
|
|
63
|
+
typ_paramed = typ.__getitem__(type_args)
|
|
64
|
+
except TypeError:
|
|
65
|
+
pass
|
|
66
|
+
else:
|
|
67
|
+
comparisons.append(
|
|
68
|
+
pytest.param(typ_paramed, creator, id=name + "_with_{nargs}_args")
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@pytest.mark.parametrize("typ,creator", comparisons)
|
|
73
|
+
def test_patch(typ: type, creator: Callable, space):
|
|
74
|
+
debug("Patch test:", typ, creator)
|
|
75
|
+
try:
|
|
76
|
+
proxy = proxy_for_type(typ, "x")
|
|
77
|
+
except CrosshairUnsupported:
|
|
78
|
+
debug("Ignored pass - CrossHair explicitly does not support this type")
|
|
79
|
+
return
|
|
80
|
+
origin = origin_of(typ)
|
|
81
|
+
with ResumedTracing():
|
|
82
|
+
assert isinstance(proxy, origin)
|