crosshair-tool 0.0.86__cp312-cp312-win_amd64.whl → 0.0.87__cp312-cp312-win_amd64.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.

Potentially problematic release.


This version of crosshair-tool might be problematic. Click here for more details.

Binary file
crosshair/__init__.py CHANGED
@@ -15,7 +15,7 @@ from crosshair.statespace import StateSpace
15
15
  from crosshair.tracers import NoTracing, ResumedTracing
16
16
  from crosshair.util import IgnoreAttempt, debug
17
17
 
18
- __version__ = "0.0.86" # Do not forget to update in setup.py!
18
+ __version__ = "0.0.87" # Do not forget to update in setup.py!
19
19
  __author__ = "Phillip Schanely"
20
20
  __license__ = "MIT"
21
21
  __status__ = "Alpha"
crosshair/_mark_stacks.h CHANGED
@@ -538,23 +538,6 @@ static const uint8_t _ch_DE_INSTRUMENT[256] = {
538
538
  #endif
539
539
  #endif
540
540
 
541
- /* Get the underlying opcode, stripping instrumentation */
542
- int _ch_Py_GetBaseOpcode(PyCodeObject *code, int i)
543
- {
544
- int opcode = _PyCode_CODE(code)[i].op.code;
545
- if (opcode == INSTRUMENTED_LINE) {
546
- opcode = code->_co_monitoring->lines[i].original_opcode;
547
- }
548
- if (opcode == INSTRUMENTED_INSTRUCTION) {
549
- opcode = code->_co_monitoring->per_instruction_opcodes[i];
550
- }
551
- int deinstrumented = _ch_DE_INSTRUMENT[opcode];
552
- if (deinstrumented) {
553
- return deinstrumented;
554
- }
555
- return _ch_PyOpcode_Deopt[opcode];
556
- }
557
-
558
541
  static int64_t *
559
542
  _ch_mark_stacks(PyCodeObject *code_obj, int len)
560
543
  {
@@ -602,14 +585,14 @@ _ch_mark_stacks(PyCodeObject *code_obj, int len)
602
585
  /* Scan instructions */
603
586
  for (i = 0; i < len;) {
604
587
  int64_t next_stack = stacks[i];
605
- opcode = _ch_Py_GetBaseOpcode(code_obj, i);
588
+ opcode = code[i].op.code;
606
589
  uint8_t trace_enabled_here = _ch_TRACABLE_INSTRUCTIONS[opcode];
607
590
  enabled_tracing[i] |= trace_enabled_here;
608
591
  int oparg = 0;
609
592
  while (opcode == EXTENDED_ARG) {
610
593
  oparg = (oparg << 8) | code[i].op.arg;
611
594
  i++;
612
- opcode = _ch_Py_GetBaseOpcode(code_obj, i);
595
+ opcode = code[i].op.code;
613
596
  stacks[i] = next_stack;
614
597
  }
615
598
  int next_i = i + _ch_PyOpcode_Caches[opcode] + 1;
crosshair/auditwall.py CHANGED
@@ -1,4 +1,5 @@
1
1
  import importlib
2
+ import inspect
2
3
  import os
3
4
  import sys
4
5
  import traceback
@@ -28,9 +29,10 @@ def reject(event: str, args: Tuple) -> None:
28
29
 
29
30
 
30
31
  def inside_module(modules: Iterable[ModuleType]) -> bool:
31
- files = {m.__file__ for m in modules}
32
- for frame, lineno in traceback.walk_stack(None):
33
- if frame.f_code.co_filename in files:
32
+ """Checks whether the current call stack is inside one of the given modules."""
33
+ for frame, _lineno in traceback.walk_stack(None):
34
+ frame_module = inspect.getmodule(frame)
35
+ if frame_module and frame_module in modules:
34
36
  return True
35
37
  return False
36
38
 
@@ -60,7 +62,7 @@ def check_msvcrt_open(event: str, args: Tuple) -> None:
60
62
  _MODULES_THAT_CAN_POPEN: Optional[Set[ModuleType]] = None
61
63
 
62
64
 
63
- def modules_with_allowed_popen():
65
+ def modules_with_allowed_subprocess():
64
66
  global _MODULES_THAT_CAN_POPEN
65
67
  if _MODULES_THAT_CAN_POPEN is None:
66
68
  allowed_module_names = ("_aix_support", "ctypes", "platform", "uuid")
@@ -74,13 +76,14 @@ def modules_with_allowed_popen():
74
76
 
75
77
 
76
78
  def check_subprocess(event: str, args: Tuple) -> None:
77
- if not inside_module(modules_with_allowed_popen()):
79
+ if not inside_module(modules_with_allowed_subprocess()):
78
80
  reject(event, args)
79
81
 
80
82
 
81
83
  _SPECIAL_HANDLERS = {
82
84
  "open": check_open,
83
85
  "subprocess.Popen": check_subprocess,
86
+ "os.posix_spawn": check_subprocess,
84
87
  "msvcrt.open_osfhandle": check_msvcrt_open,
85
88
  }
86
89
 
@@ -267,7 +267,7 @@ class SymbolicValue(CrossHairValue):
267
267
  self.snapshot = SnapshotRef(-1)
268
268
  self.python_type = typ
269
269
  if type(smtvar) is str:
270
- self.var = self.__init_var__(typ, smtvar)
270
+ self.var: Any = self.__init_var__(typ, smtvar)
271
271
  else:
272
272
  self.var = smtvar
273
273
  # TODO test that smtvar's sort matches expected?
@@ -838,19 +838,6 @@ def setup_binops():
838
838
 
839
839
  setup_binop(_, {ops.lshift, ops.rshift})
840
840
 
841
- _AND_MASKS_TO_MOD = {
842
- # It's common to use & to mask low bits. We can avoid realization by converting
843
- # these situations into mod operations.
844
- 0x01: 2,
845
- 0x03: 4,
846
- 0x07: 8,
847
- 0x0F: 16,
848
- 0x1F: 32,
849
- 0x3F: 64,
850
- 0x7F: 128,
851
- 0xFF: 256,
852
- }
853
-
854
841
  def _(op: BinFn, a: Integral, b: Integral):
855
842
  with NoTracing():
856
843
  if isinstance(b, SymbolicInt):
@@ -861,9 +848,12 @@ def setup_binops():
861
848
  b = realize(b)
862
849
  if b == 0:
863
850
  return 0
864
- mask_mod = _AND_MASKS_TO_MOD.get(b)
865
- if mask_mod and isinstance(a, SymbolicInt):
866
- if context_statespace().smt_fork(a.var >= 0, probability_true=0.75):
851
+ # It's common to use & to mask low bits. We can avoid realization by converting
852
+ # these situations into mod operations.
853
+ mask_mod = b + 1
854
+ if b > 0 and mask_mod & b == 0 and isinstance(a, SymbolicInt): # type: ignore
855
+ space = context_statespace()
856
+ if space.smt_fork(a.var >= 0, probability_true=0.75):
867
857
  return SymbolicInt(a.var % mask_mod)
868
858
  else:
869
859
  return SymbolicInt(b - ((-a.var - 1) % mask_mod))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crosshair-tool
3
- Version: 0.0.86
3
+ Version: 0.0.87
4
4
  Summary: Analyze Python code for correctness using symbolic execution.
5
5
  Home-page: https://github.com/pschanely/CrossHair
6
6
  Author: Phillip Schanely
@@ -46,7 +46,7 @@ Requires-Dist: pytest-xdist; extra == "dev"
46
46
  Requires-Dist: setuptools; extra == "dev"
47
47
  Requires-Dist: sphinx>=3.4.3; extra == "dev"
48
48
  Requires-Dist: sphinx-rtd-theme>=0.5.1; extra == "dev"
49
- Requires-Dist: wheel; extra == "dev"
49
+ Requires-Dist: rst2pdf>=0.102; extra == "dev"
50
50
  Dynamic: author
51
51
  Dynamic: author-email
52
52
  Dynamic: classifier
@@ -1,13 +1,13 @@
1
- _crosshair_tracers.cp312-win_amd64.pyd,sha256=iZgXYtjK-q0YvhQDzkPeAVIU_t0e7u3C6W4HWol5Tgs,25600
2
- crosshair/__init__.py,sha256=VCcnhptG3TKPXgwuUolY7M2GTPbrzxhS-wwP7ONhhmc,978
1
+ _crosshair_tracers.cp312-win_amd64.pyd,sha256=HmNDv0PYOXvEpK6tl7MLwK46_Ey68pf-7Y06lAzm_Xg,24576
2
+ crosshair/__init__.py,sha256=tt_dO_b86vGhi_5l7U5LXiR_mvAfXCM5Y-YtgaIRxIY,978
3
3
  crosshair/__main__.py,sha256=i4pjsZlXvtieQHJTEB0sF3e40qJjLoOm1z5rm-u70Uo,260
4
- crosshair/_mark_stacks.h,sha256=R5ZwGlth2DCk6l11hWICPcwSadvtM2VcLf5Zo_pHYa4,30068
4
+ crosshair/_mark_stacks.h,sha256=IImygydFK9qethf41gUZDjySHR3WLXs-YsqWCHK9UFg,29468
5
5
  crosshair/_preliminaries_test.py,sha256=klkzKGpyyVDGctCXdvq1xyXbGa4PRnXda1jfgE-7LLY,522
6
6
  crosshair/_tracers.h,sha256=IJNUQ01LQurzap8qCgqLcOhkRpeY1BIRKrVj-OUlIj8,2217
7
7
  crosshair/_tracers_pycompat.h,sha256=KqJHbya8zi1Z4Qrk2S6P-FfmC_Ew5LYvTxbA-V9TWPw,14878
8
8
  crosshair/_tracers_test.py,sha256=l0WYk74xtr5tlT9ID0kq11jUmw_Ai-hevNX7eZHg4RY,3734
9
9
  crosshair/abcstring.py,sha256=Jvnnm7xsHGTcZvu5mbV_eL5IVEvbNNbeCauM6f7QYEI,6794
10
- crosshair/auditwall.py,sha256=Rlz0PDjAK17ykpcqbh8tstN4MXk3w09J-E1ibIKUv7o,5162
10
+ crosshair/auditwall.py,sha256=RGnRqjUf-WokimDsEcX-3sUrra9jaqyGym2gYAulYgo,5328
11
11
  crosshair/auditwall_test.py,sha256=SKTy_7Q6xP0Den4i7HRHSaU0b37smi_Mb-arQnppFPI,2107
12
12
  crosshair/codeconfig.py,sha256=L0EmcEZlWA51sl32uBxvFPwbTmuglVDHNq8k35JkXw0,4071
13
13
  crosshair/codeconfig_test.py,sha256=n5kXtW60vG_CA0QlzLE3mS4k9caEwhB30bnhaGNh6Ww,3467
@@ -100,7 +100,7 @@ crosshair/libimpl/binascii_ch_test.py,sha256=qWAYU1Sid3muwYL8pvVoCsMQtm5t3J8jFto
100
100
  crosshair/libimpl/binascii_test.py,sha256=Yg37_B-eywcLq7EbsJZR3BUYYF6A1PGxE4qsmeBMyXg,2037
101
101
  crosshair/libimpl/binasciilib.py,sha256=kBFH5-W_q1gCTC-wusSq0cAsUsB_xOUpcW0XQbLzkSQ,5220
102
102
  crosshair/libimpl/bisectlib_test.py,sha256=rVpcalZ4g3xr_b6z1Bv2FU1N07vPZyWhU9_CPzC8sBk,776
103
- crosshair/libimpl/builtinslib.py,sha256=VrD0Uc1T7P5gdFL0yAPAma5FR13cW9DQTX4mr3uPEro,176726
103
+ crosshair/libimpl/builtinslib.py,sha256=uqSMGkTa33Fz-CLLMRFhM-Ixv_JNR5jYYmHOjUT6WFc,176599
104
104
  crosshair/libimpl/builtinslib_ch_test.py,sha256=Do8kWNgfosLfI3yzZvTZ3ceuKTF0axN1ckkNZyn4ozE,31685
105
105
  crosshair/libimpl/builtinslib_test.py,sha256=Ex-3f9n06fTaZPxO6UE_AqcoJcoHyisQWmb7fDtA3dE,93933
106
106
  crosshair/libimpl/codecslib.py,sha256=cvpCbieFRB4BdfLqmKeJzpvm35qZ0ONqtilXPmN8OWI,2754
@@ -166,9 +166,9 @@ crosshair/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
166
166
  crosshair/tools/check_help_in_doc.py,sha256=An-2EJ0_Xr-Szo431AoEgJafoFWwnPl8HoT4bi86dd8,8499
167
167
  crosshair/tools/check_init_and_setup_coincide.py,sha256=f4TvPg1Q3C_BQYtGgPfY_fqxo_ZTeU7QCy7WwQjaIlA,3621
168
168
  crosshair/tools/generate_demo_table.py,sha256=qm4ZUXjUBKkVZ3bVVK9h6dJMDKYme8zMl-7at_aG7b0,3958
169
- crosshair_tool-0.0.86.dist-info/licenses/LICENSE,sha256=qQLSJN48eqvalILMr3uzkg0p74FtK7WSwkux-0twy-s,4552
170
- crosshair_tool-0.0.86.dist-info/METADATA,sha256=0aN07P1yqUhvQxXtJiyYvOVIPj5j9EXBMQXZJo2AsGM,6862
171
- crosshair_tool-0.0.86.dist-info/WHEEL,sha256=ovhA9_Ei_7ok2fAych90j-feDV4goiAxbO7REePtvw0,101
172
- crosshair_tool-0.0.86.dist-info/entry_points.txt,sha256=u5FIPVn1jqn4Kzg5K_iNnbP6L4hQw5FWjQ0UMezG2VE,96
173
- crosshair_tool-0.0.86.dist-info/top_level.txt,sha256=2jLWtM-BWg_ZYNbNfrcds0HFZD62a6J7ZIbcgcQrRk4,29
174
- crosshair_tool-0.0.86.dist-info/RECORD,,
169
+ crosshair_tool-0.0.87.dist-info/licenses/LICENSE,sha256=qQLSJN48eqvalILMr3uzkg0p74FtK7WSwkux-0twy-s,4552
170
+ crosshair_tool-0.0.87.dist-info/METADATA,sha256=Pf0T9cCV5baDPQutBYunWoi_a4pGfhSV8-z-PBof_EU,6871
171
+ crosshair_tool-0.0.87.dist-info/WHEEL,sha256=8UP9x9puWI0P1V_d7K2oMTBqfeLNm21CTzZ_Ptr0NXU,101
172
+ crosshair_tool-0.0.87.dist-info/entry_points.txt,sha256=u5FIPVn1jqn4Kzg5K_iNnbP6L4hQw5FWjQ0UMezG2VE,96
173
+ crosshair_tool-0.0.87.dist-info/top_level.txt,sha256=2jLWtM-BWg_ZYNbNfrcds0HFZD62a6J7ZIbcgcQrRk4,29
174
+ crosshair_tool-0.0.87.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
5
5