certora-cli-alpha-master 20241218.18.41.295142__py3-none-macosx_10_9_universal2.whl → 20241219.2.15.305705__py3-none-macosx_10_9_universal2.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env python3
2
2
 
3
+ import atexit
3
4
  import shutil
4
5
  import subprocess
5
6
  import argparse
@@ -31,7 +32,7 @@ def parse_args() -> argparse.Namespace:
31
32
  )
32
33
  )
33
34
  parser.add_argument(
34
- "--file_to_mutant",
35
+ "--file_to_mutate",
35
36
  "-f",
36
37
  type=Path,
37
38
  required=True,
@@ -74,27 +75,12 @@ def parse_args() -> argparse.Namespace:
74
75
  return parser.parse_args()
75
76
 
76
77
 
77
- def restore_source(backup_file: Path, file_to_mutant: Path) -> None:
78
- """
79
- Restore the original source file from the backup.
80
-
81
- Args:
82
- backup_file (Path): Path to the backup file.
83
- file_to_mutant (Path): Path to the original source file.
84
- """
85
- rust_mutator_logger.info(f"Restoring the original '{file_to_mutant}' from '{backup_file}'...")
86
- if Util.restore_backup(backup_file):
87
- rust_mutator_logger.info(f"Original '{file_to_mutant}' restored successfully.")
88
- else:
89
- rust_mutator_logger.warning(f"No backup file '{backup_file}' found. Skipping restoration.")
90
-
91
-
92
- def clean_temp_files(file_to_mutant: Path) -> None:
78
+ def clean_temp_files(file_to_mutate: Path) -> None:
93
79
  """
94
80
  Remove temporary mutant output files matching the pattern '.um.mutant_output.*'.
95
81
 
96
82
  Args:
97
- file_to_mutant (Path): Path to the original source file.
83
+ file_to_mutate (Path): Path to the original source file.
98
84
  """
99
85
  temp_files = Path().rglob(".um.mutant_output.*")
100
86
 
@@ -103,7 +89,7 @@ def clean_temp_files(file_to_mutant: Path) -> None:
103
89
  temp_file.unlink()
104
90
  rust_mutator_logger.info(f"Removed: {temp_file}")
105
91
 
106
- backup_file = next(Path().rglob(f"{file_to_mutant}.um.backup.*"), None)
92
+ backup_file = next(Path().rglob(f"{file_to_mutate}.um.backup.*"), None)
107
93
  if backup_file:
108
94
  backup_file.unlink()
109
95
  rust_mutator_logger.info(f"Removed: {backup_file}")
@@ -148,22 +134,22 @@ def uniform_selection(mutants: List[Path], num_select: int, seed: int) -> List[P
148
134
  return shuffled_mutants[:num_select]
149
135
 
150
136
 
151
- def validate_source_file(file_to_mutant: Path) -> None:
137
+ def validate_source_file(file_to_mutate: Path) -> None:
152
138
  """
153
139
  Validate that the source file exists and has a .rs extension.
154
140
 
155
141
  Args:
156
- file_to_mutant (Path): Path to the Rust source file.
142
+ file_to_mutate (Path): Path to the Rust source file.
157
143
 
158
144
  Raises:
159
145
  Util.CertoraUserInputError: If validation fails.
160
146
  """
161
- if not file_to_mutant.exists():
162
- raise Util.CertoraUserInputError(f"Source file '{file_to_mutant}' does not exist.")
163
- if not file_to_mutant.is_file():
164
- raise Util.CertoraUserInputError(f"Source file '{file_to_mutant}' is not a file.")
165
- if file_to_mutant.suffix != ".rs":
166
- raise Util.CertoraUserInputError(f"Source file '{file_to_mutant}' does not have a .rs extension.")
147
+ if not file_to_mutate.exists():
148
+ raise Util.CertoraUserInputError(f"Source file '{file_to_mutate}' does not exist.")
149
+ if not file_to_mutate.is_file():
150
+ raise Util.CertoraUserInputError(f"Source file '{file_to_mutate}' is not a file.")
151
+ if file_to_mutate.suffix != ".rs":
152
+ raise Util.CertoraUserInputError(f"Source file '{file_to_mutate}' does not have a .rs extension.")
167
153
 
168
154
 
169
155
  def validate_mutant_dir(mutants_location: Path) -> None:
@@ -186,13 +172,13 @@ def validate_mutant_dir(mutants_location: Path) -> None:
186
172
  rust_mutator_logger.info(f"Mutant directory '{mutants_location}' created successfully.")
187
173
 
188
174
 
189
- def validate_mutant_count(file_to_mutant: Path, mutants_location: Path, num_mutants: int, seed: int) -> None:
175
+ def validate_mutant_count(file_to_mutate: Path, mutants_location: Path, num_mutants: int, seed: int) -> None:
190
176
  """
191
177
  Validate the number of mutants generated is less than or equal to the specified limit. If the number of mutants
192
178
  exceeds the limit, select uniformly based on the seed and delete the rest.
193
179
 
194
180
  Args:
195
- file_to_mutant (Path): Path to the original Rust source file.
181
+ file_to_mutate (Path): Path to the original Rust source file.
196
182
  mutants_location (Path): Directory containing generated mutants.
197
183
  num_mutants (int): Upper bound on the number of mutants to generate.
198
184
  seed (int, optional): Seed value for random selection.
@@ -201,7 +187,7 @@ def validate_mutant_count(file_to_mutant: Path, mutants_location: Path, num_muta
201
187
  Util.CertoraUserInputError: If no mutants are generated.
202
188
  """
203
189
  # Define the regex pattern to extract the mutant number
204
- pattern = re.compile(rf"{re.escape(file_to_mutant.stem)}\.mutant\.(\d+)\.rs$")
190
+ pattern = re.compile(rf"{re.escape(file_to_mutate.stem)}\.mutant\.(\d+)\.rs$")
205
191
 
206
192
  # Gather all mutants matching the pattern
207
193
  mutants = [mutant for mutant in mutants_location.iterdir() if pattern.match(mutant.name)]
@@ -233,7 +219,7 @@ def validate_mutant_count(file_to_mutant: Path, mutants_location: Path, num_muta
233
219
  for mutant, mutant_number in numbered_mutants:
234
220
  if not 0 <= mutant_number < num_mutants:
235
221
  for i in range(num_mutants):
236
- new_file_name = mutant.with_name(f"{file_to_mutant.stem}.mutant.{i}.rs")
222
+ new_file_name = mutant.with_name(f"{file_to_mutate.stem}.mutant.{i}.rs")
237
223
  if new_file_name.exists():
238
224
  continue
239
225
  mutant.rename(new_file_name)
@@ -251,12 +237,12 @@ def validate_mutate_command() -> None:
251
237
  raise Util.CertoraUserInputError("universalmutator command 'mutate' not found in PATH.")
252
238
 
253
239
 
254
- def run_mutate(file_to_mutant: Path, mutants_location: Path, build_command: str) -> None:
240
+ def run_mutate(file_to_mutate: Path, mutants_location: Path, build_command: str) -> None:
255
241
  """
256
242
  Execute the universalmutator command to generate mutants, displaying a progress bar.
257
243
 
258
244
  Args:
259
- file_to_mutant (Path): Path to the Rust source file.
245
+ file_to_mutate (Path): Path to the Rust source file.
260
246
  mutants_location (Path): Directory to store generated mutants.
261
247
  build_command (str): Command to execute for each mutant to verify compilation.
262
248
 
@@ -265,7 +251,7 @@ def run_mutate(file_to_mutant: Path, mutants_location: Path, build_command: str)
265
251
  """
266
252
  mutate_command = [
267
253
  "mutate",
268
- str(file_to_mutant),
254
+ str(file_to_mutate),
269
255
  "rust",
270
256
  "--mutantDir",
271
257
  str(mutants_location),
@@ -287,7 +273,7 @@ def run_mutate(file_to_mutant: Path, mutants_location: Path, build_command: str)
287
273
  total_mutants = None
288
274
  mutant_pattern = re.compile(r"^PROCESSING MUTANT: (\d+):")
289
275
  total_pattern = re.compile(r"^(\d+) MUTANTS GENERATED BY RULES")
290
- valid_mutant_pattern = re.compile(rf"VALID \[written to {mutants_location.stem}/{file_to_mutant.stem}\.mutant\.\d+\.rs\]")
276
+ valid_mutant_pattern = re.compile(rf"VALID \[written to {mutants_location.stem}/{file_to_mutate.stem}\.mutant\.\d+\.rs\]")
291
277
 
292
278
  progress_bar = None
293
279
 
@@ -306,7 +292,7 @@ def run_mutate(file_to_mutant: Path, mutants_location: Path, build_command: str)
306
292
  if total_match:
307
293
  total_mutants = int(total_match.group(1))
308
294
  progress_bar = tqdm(total=total_mutants, desc="Mutants Generated", unit="mutant")
309
- rust_mutator_logger.info(f"Total mutants to generate: {total_mutants}")
295
+ rust_mutator_logger.info(f"Total mutants generated: {total_mutants}")
310
296
  continue
311
297
 
312
298
  # Update progress bar for each processed mutant
@@ -340,7 +326,7 @@ def run_mutate(file_to_mutant: Path, mutants_location: Path, build_command: str)
340
326
  process.terminate()
341
327
 
342
328
  def run_universal_mutator(
343
- file_to_mutant: Path,
329
+ file_to_mutate: Path,
344
330
  build_script: str,
345
331
  mutants_location: Path,
346
332
  num_mutants: int = NUM_MUTANTS,
@@ -351,7 +337,7 @@ def run_universal_mutator(
351
337
  Generate mutants for the specified source file and ensure the original file remains unchanged.
352
338
 
353
339
  Args:
354
- file_to_mutant (Path): Path to the Rust source file.
340
+ file_to_mutate (Path): Path to the Rust source file.
355
341
  build_script (str): Command to execute for each mutant to verify compilation.
356
342
  mutants_location (Path): Directory to store generated mutants.
357
343
  num_mutants (int): Upper bound on the number of mutants to generate (default: {NUM_MUTANTS}).
@@ -365,7 +351,10 @@ def run_universal_mutator(
365
351
  backup_file = None
366
352
  build_command = f"cp MUTATE & python3 {build_script}"
367
353
 
354
+ atexit.register(clean_temp_files, file_to_mutate)
355
+
368
356
  try:
357
+
369
358
  # Set up the logger
370
359
  setup_logger(debug)
371
360
 
@@ -373,38 +362,37 @@ def run_universal_mutator(
373
362
  validate_mutate_command()
374
363
 
375
364
  # Validate source file
376
- validate_source_file(file_to_mutant)
365
+ validate_source_file(file_to_mutate)
377
366
 
378
367
  # Backup the original source file
379
- rust_mutator_logger.info(f"Backing up '{file_to_mutant}' ...")
380
- backup_file = Util.create_backup(file_to_mutant)
368
+ rust_mutator_logger.info(f"Backing up '{file_to_mutate}' ...")
369
+ backup_file = Util.create_backup(file_to_mutate)
370
+
381
371
  if backup_file:
382
- rust_mutator_logger.info(f"Backing up '{file_to_mutant}' to '{backup_file} succeeded")
372
+ atexit.register(Util.restore_backup, backup_file)
373
+ rust_mutator_logger.info(f"Backing up '{file_to_mutate}' to '{backup_file} succeeded")
383
374
  else:
384
- rust_mutator_logger.warning(f"Backing up '{file_to_mutant}' to '{backup_file} failed")
375
+ rust_mutator_logger.warning(f"Backing up '{file_to_mutate}' to '{backup_file} failed")
385
376
 
386
377
  # Validate or create mutant directory
387
378
  validate_mutant_dir(mutants_location)
388
379
 
389
380
  # Run the mutation command
390
- run_mutate(file_to_mutant, mutants_location, build_command)
381
+ run_mutate(file_to_mutate, mutants_location, build_command)
391
382
 
392
383
  # Make sure the number of mutants generated is less than or equal to the specified limit
393
- validate_mutant_count(file_to_mutant, mutants_location, num_mutants, seed)
394
-
384
+ validate_mutant_count(file_to_mutate, mutants_location, num_mutants, seed)
395
385
  finally:
396
- # Restore the original source file
397
386
  if backup_file:
398
387
  Util.restore_backup(backup_file)
399
- # Clean up temporary files
400
- clean_temp_files(file_to_mutant)
388
+ clean_temp_files(file_to_mutate)
401
389
 
402
390
 
403
391
  if __name__ == "__main__":
404
392
  # Parse command-line arguments
405
393
  args = parse_args()
406
394
  run_universal_mutator(
407
- args.file_to_mutant,
395
+ args.file_to_mutate,
408
396
  args.build_script,
409
397
  args.mutants_location,
410
398
  args.num_mutants,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: certora-cli-alpha-master
3
- Version: 20241218.18.41.295142
3
+ Version: 20241219.2.15.305705
4
4
  Summary: Runner for the Certora Prover
5
5
  Home-page: https://pypi.org/project/certora-cli-alpha-master
6
6
  Author: Certora
@@ -23,4 +23,4 @@ Requires-Dist: StrEnum
23
23
  Requires-Dist: tomli
24
24
  Requires-Dist: universalmutator
25
25
 
26
- Commit 1731e84. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
26
+ Commit 2b6a3e9. Build and Run scripts for executing the Certora Prover on Solidity smart contracts.
@@ -5,7 +5,7 @@ certora_cli/certoraEqCheck.py,sha256=5LtN9GNBSYR_kYghDBeNNL4yWshPw9PNpe0stLtuIxQ
5
5
  certora_cli/certoraMutate.py,sha256=BUK_keaunrcCYgLiwHfIkDSjIHM_KoGwwnIiuojc-ug,2643
6
6
  certora_cli/certoraRun.py,sha256=rnczNnSoYRuUKOkIN7_0cRxjiVDK0x4NJxOT4KNkYdg,11884
7
7
  certora_cli/certoraSolanaProver.py,sha256=3Vb05zd5PqkU5CmCNzYvmYfbC-hsmU6Tt390msjQlOc,5898
8
- certora_cli/rustMutator.py,sha256=wSE_4qDegDhItxHw7dtcFzDMgYCTsVxW4yFGxYRHlQc,14418
8
+ certora_cli/rustMutator.py,sha256=ezpwwzr-OCK78PsBPVf5fC__GWaESvIbaAI7yjJ8Hs0,13862
9
9
  certora_cli/EVMVerifier/__init__.py,sha256=AJxj90KAGh1JqAsxKqDBTL2rFbqgtkhDfW_XmxSHft0,159
10
10
  certora_cli/EVMVerifier/certoraBuild.py,sha256=TqPfOSjcuY0zWJYTx1d401zJdIbnLyECa9T5koXRKzM,203842
11
11
  certora_cli/EVMVerifier/certoraBuildCacheManager.py,sha256=ZSVCsdTkFFtawuNJ8VK3wJOb01Uyu5e8viPQ8wTziSQ,12563
@@ -54,12 +54,12 @@ certora_cli/Shared/certoraAttrUtil.py,sha256=IbIIvTbtPzmPSSrK7VIWZNitkz1iwvW_e0g
54
54
  certora_cli/Shared/certoraLogging.py,sha256=5Lx-XWKl7GnwnWi7KlwTLIfsEvUvCTZ8KeyfNyi_6RU,13323
55
55
  certora_cli/Shared/certoraUtils.py,sha256=8EGXrxfIxu34VTx46QeTx6tTYLdwpTLT9ulVQijmD9Y,53624
56
56
  certora_cli/Shared/certoraValidateFuncs.py,sha256=OOjPAkcfrURZDD4oDjOMBFTvY6wwQSXboXzu-47AUbY,36871
57
- certora_jars/CERTORA-CLI-VERSION-METADATA.json,sha256=DrrqXNEBJJa8U1U9k16qWHnJMAZV0a0hx4JWZKxAu8w,170
58
- certora_jars/Typechecker.jar,sha256=Nbdtgt77N04vGuYGxoaW-QSO-ih0BQt3JRY0_WRbqKM,16754390
57
+ certora_jars/CERTORA-CLI-VERSION-METADATA.json,sha256=gP6anWYKHdPDbrP814Uu2PErb4SX2QzMt60JHE6Rm_Q,168
58
+ certora_jars/Typechecker.jar,sha256=N496KbB3IKV8AXUPhQrcch3v316bHnAQdpb7JLjjm6g,16755362
59
59
  certora_jars/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
60
- certora_cli_alpha_master-20241218.18.41.295142.dist-info/LICENSE,sha256=VeEBJLgfzZqyAUfjLoKUztf7KJBBUjtZ1ap99eQubOo,1065
61
- certora_cli_alpha_master-20241218.18.41.295142.dist-info/METADATA,sha256=YYn3btj02cVMOLsVZuqWpb9vdnlbflzBaG-OQ_bMkyE,838
62
- certora_cli_alpha_master-20241218.18.41.295142.dist-info/WHEEL,sha256=N3Zagyg8u7FcZiPCx4UnuNyRRYq7IQpu24eWYyuhGOQ,110
63
- certora_cli_alpha_master-20241218.18.41.295142.dist-info/entry_points.txt,sha256=Y90wInBDlKPSU3YnuTn3JqAsSgPRTDHc8lf6BfKILjY,261
64
- certora_cli_alpha_master-20241218.18.41.295142.dist-info/top_level.txt,sha256=8C77w3JLanY0-NW45vpJsjRssyCqVP-qmPiN9FjWiX4,38
65
- certora_cli_alpha_master-20241218.18.41.295142.dist-info/RECORD,,
60
+ certora_cli_alpha_master-20241219.2.15.305705.dist-info/LICENSE,sha256=VeEBJLgfzZqyAUfjLoKUztf7KJBBUjtZ1ap99eQubOo,1065
61
+ certora_cli_alpha_master-20241219.2.15.305705.dist-info/METADATA,sha256=tqMEjgF-IkX9nSa7A0KKgDXtNpYSeVnc_0gXdDLLg1E,837
62
+ certora_cli_alpha_master-20241219.2.15.305705.dist-info/WHEEL,sha256=N3Zagyg8u7FcZiPCx4UnuNyRRYq7IQpu24eWYyuhGOQ,110
63
+ certora_cli_alpha_master-20241219.2.15.305705.dist-info/entry_points.txt,sha256=Y90wInBDlKPSU3YnuTn3JqAsSgPRTDHc8lf6BfKILjY,261
64
+ certora_cli_alpha_master-20241219.2.15.305705.dist-info/top_level.txt,sha256=8C77w3JLanY0-NW45vpJsjRssyCqVP-qmPiN9FjWiX4,38
65
+ certora_cli_alpha_master-20241219.2.15.305705.dist-info/RECORD,,
@@ -1 +1 @@
1
- {"name": "certora-cli-alpha-master", "tag": "", "branch": "master", "commit": "1731e84", "timestamp": "20241218.18.41.295142", "version": "20241218.18.41.295142+1731e84"}
1
+ {"name": "certora-cli-alpha-master", "tag": "", "branch": "master", "commit": "2b6a3e9", "timestamp": "20241219.2.15.305705", "version": "20241219.2.15.305705+2b6a3e9"}
Binary file