dashingsoft / pyarmor

A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.
http://pyarmor.dashingsoft.com
Other
3.25k stars 277 forks source link

[BUG] invalid syntax (<frozen metrics_to_csv>, line 45) #1619

Closed DeboBurro closed 9 months ago

DeboBurro commented 9 months ago

Environment

Python: 3.8.10 OS: ubuntu 20.04 Pyarmor: 8.4.4 Pyarmor.cli.core: 5.4.2 pyarmor plan: basic

Reproduced steps

  1. Run a command pyarmor gen --output /root/catkin_ws/install/lib/dist/burro_launcher --assert-call $multiple_python_files
  2. immediately returned ERROR invalid syntax (<frozen metrics_to_csv>, line 45) exact command I ran:
root@485f6b0268cb:~# pyarmor gen --output /root/catkin_ws/install/lib/dist/burro_launcher --assert-call /root/catkin_ws/install/lib/burro_launcher/gps_plotter.py /root/catkin_ws/install/lib/burro_launcher/stereo_republisher.py /root/catkin_ws/install/lib/burro_launcher/ground_truth_line_detector.py /root/catkin_ws/install/lib/burro_launcher/onnx2engine.py /root/catkin_ws/install/lib/burro_launcher/gpu_monitor.py /root/catkin_ws/install/lib/burro_launcher/plotLiveBag.py /root/catkin_ws/install/lib/burro_launcher/auto_base_config.py /root/catkin_ws/install/lib/burro_launcher/resource_listener.py /root/catkin_ws/install/lib/burro_launcher/denanifier.py /root/catkin_ws/install/lib/burro_launcher/lights_manager.py /root/catkin_ws/install/lib/burro_launcher/cpu_monitor.py /root/catkin_ws/install/lib/burro_launcher/odometer.py /root/catkin_ws/install/lib/burro_launcher/plot_base_bag.py /root/catkin_ws/install/lib/burro_launcher/row_to_row_nav_manager.py /root/catkin_ws/install/lib/burro_launcher/cropdata_transfer.py /root/catkin_ws/install/lib/burro_launcher/bag_topic_sizes.py /root/catkin_ws/install/lib/burro_launcher/metrics_to_csv.py /root/catkin_ws/install/lib/burro_launcher/realsense_firmware_updater.py /root/catkin_ws/install/lib/burro_launcher/burro_topic_status.py /root/catkin_ws/install/lib/burro_launcher/fdupes.py /root/catkin_ws/install/lib/burro_launcher/transfer_maps.py /root/catkin_ws/install/lib/burro_launcher/check_load_params.py /root/catkin_ws/install/lib/burro_launcher/find_and_upload_bags.py /root/catkin_ws/install/lib/burro_launcher/bag2video.py /root/catkin_ws/install/lib/burro_launcher/merge_bags.py /root/catkin_ws/install/lib/burro_launcher/row_comparison_node.py /root/catkin_ws/install/lib/burro_launcher/diagnostic_aggregator.py /root/catkin_ws/install/lib/burro_launcher/burro_nav_manager.py /root/catkin_ws/install/lib/burro_launcher/load_burro_ros_params.py /root/catkin_ws/install/lib/burro_launcher/odom_to_tf.py /root/catkin_ws/install/lib/burro_launcher/barcode_scanner.py /root/catkin_ws/install/lib/burro_launcher/network_monitor.py /root/catkin_ws/install/lib/burro_launcher/upload_ghosts_to_airtable.py /root/catkin_ws/install/lib/burro_launcher/classifier_data_relayer.py /root/catkin_ws/install/lib/burro_launcher/bag2geo.py /root/catkin_ws/install/lib/burro_launcher/person_gradient_follower.py /root/catkin_ws/install/lib/burro_launcher/hardware_test.py /root/catkin_ws/install/lib/burro_launcher/training_data_relayer.py /root/catkin_ws/install/lib/burro_launcher/bag2img.py /root/catkin_ws/install/lib/burro_launcher/screen_fix.py /root/catkin_ws/install/lib/burro_launcher/check_for_maps.py /root/catkin_ws/install/lib/burro_launcher/gps_signal_monitor.py /root/catkin_ws/install/lib/burro_launcher/bag_matcher.py
INFO     Python 3.8.10
INFO     Pyarmor 8.4.4 (basic), 004340, BURRO
INFO     Platform linux.x86_64
INFO     search inputs ...
INFO     find script /root/catkin_ws/install/lib/burro_launcher/gps_plotter.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/stereo_republisher.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/ground_truth_line_detector.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/onnx2engine.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/gpu_monitor.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/plotLiveBag.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/auto_base_config.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/resource_listener.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/denanifier.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/lights_manager.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/cpu_monitor.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/odometer.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/plot_base_bag.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/row_to_row_nav_manager.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/cropdata_transfer.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/bag_topic_sizes.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/metrics_to_csv.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/realsense_firmware_updater.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/burro_topic_status.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/fdupes.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/transfer_maps.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/check_load_params.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/find_and_upload_bags.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/bag2video.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/merge_bags.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/row_comparison_node.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/diagnostic_aggregator.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/burro_nav_manager.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/load_burro_ros_params.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/odom_to_tf.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/barcode_scanner.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/network_monitor.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/upload_ghosts_to_airtable.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/classifier_data_relayer.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/bag2geo.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/person_gradient_follower.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/hardware_test.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/training_data_relayer.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/bag2img.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/screen_fix.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/check_for_maps.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/gps_signal_monitor.py
INFO     find script /root/catkin_ws/install/lib/burro_launcher/bag_matcher.py
INFO     find 43 top resources
ERROR    invalid syntax (<frozen metrics_to_csv>, line 45)

Expected results

no pyarmor.error.log is generated

Actual results

root@eff93fd1bd71:~# cat pyarmor.error.log 
50 MainProcess 2023-12-04 16:41:59,657
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/__main__.py", line 718, in main
    main_entry(sys.argv[1:])
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/__main__.py", line 706, in main_entry
    return args.func(ctx, args)
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/__main__.py", line 236, in cmd_gen
    builder.process(options)
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/generate.py", line 157, in process
    self._obfuscate_scripts()
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/generate.py", line 120, in _obfuscate_scripts
    code = Pytransform3.generate_obfuscated_script(self.ctx, r)
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/core/__init__.py", line 103, in generate_obfuscated_script
    return m.generate_obfuscated_script(ctx, res)
  File "<maker>", line 675, in generate_obfuscated_script
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/__init__.py", line 16, in process
    return meth(self, res, *args, **kwargs)
  File "<maker>", line 474, in process
  File "/usr/local/lib/python3.8/dist-packages/pyarmor/cli/resource.py", line 139, in reparse
    self.mtree = ast.parse(''.join(lines), self.frozenname, 'exec')
  File "/usr/lib/python3.8/ast.py", line 47, in parse
    return compile(source, filename, mode, flags,
  File "<frozen metrics_to_csv>", line 45
    print 'output: {}'.format(output_file_path)

pyarmor registration log

INFO     Python 3.8.10
INFO     Pyarmor 8.4.4 (trial), 000000, non-profits
INFO     Platform linux.x86_64
INFO     register "/root/catkin_ws/src/pyarmor-regfile-4340.zip"
INFO     update license token
INFO     This license registration information:

License Type    : pyarmor-basic
License No.     : pyarmor-vax-004340
License To      : Burro
License Product : BURRO

BCC Mode        : No
RFT Mode        : No

Notes

Additional info

  1. When obfuscating all the other modules, they don't have this error, but the burro_launcher module.
DeboBurro commented 9 months ago

issue identified. if there is python2 syntax in the script, pyarmor 8 doesn't support it anymore. we were using pyarmor 7 so we didn't find this incompatibility. we converted all the python 2 syntax into python 3 ( or ignore those python2 scripts) and the issue is resolved