Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: ValueError: substring not found #91

Open
Primusinterp opened this issue Feb 11, 2025 · 2 comments
Open

Bug: ValueError: substring not found #91

Primusinterp opened this issue Feb 11, 2025 · 2 comments

Comments

@Primusinterp
Copy link

Primusinterp commented Feb 11, 2025

Hi,

While i was running a dump, i encountered the following error:

2025-02-11 12:47:37 | powerpwn | INFO | Acquiring token with scope=https://apihub.azure.com/.default from cached refresh token.
2025-02-11 12:47:37 | powerpwn | INFO | Token for https://apihub.azure.com/.default acquired from refresh token successfully.
2025-02-11 12:47:37 | powerpwn | INFO | Token is cached in /workspace/powerdump/test/tokens.json
Traceback (most recent call last):
  File "/root/.pyenv/versions/3.11.9/bin/powerpwn", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.pyenv/versions/3.11.9/lib/python3.11/site-packages/powerpwn/main.py", line 34, in main
    run_dump_command(args)
  File "/root/.pyenv/versions/3.11.9/lib/python3.11/site-packages/powerpwn/cli/runners.py", line 117, in run_dump_command
    is_data_collected = DataCollector(token=auth.token, cache_path=scoped_cache_path).collect()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.9/lib/python3.11/site-packages/powerpwn/powerdump/collect/data_collectors/data_collector.py", line 32, in collect
    data_collector_instance.collect(self.__session, env_id, env_dumps_root_dir)
  File "/root/.pyenv/versions/3.11.9/lib/python3.11/site-packages/powerpwn/powerdump/collect/data_collectors/connections_data_collectors/connections_data_collector.py", line 47, in collect
    data_dump = connector_cls_instance.dump(data_record=data_record)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.9/lib/python3.11/site-packages/powerpwn/powerdump/collect/data_collectors/connections_data_collectors/connectors/connector_base.py", line 56, in dump
    return DataDumpWithContext(data_record=data_record, data_dump=self._dump(data_record=data_record))
                                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.9/lib/python3.11/site-packages/powerpwn/powerdump/collect/data_collectors/connections_data_collectors/connectors/shared_azureblob.py", line 90, in _dump
    last_index_for_extension = file_name.rindex(".")
                               ^^^^^^^^^^^^^^^^^^^^^
ValueError: substring not found

Tested with Python 3.10 and 3.11

As far as i understand it could very well be due some files not having a . and then the Value error is raised.

Seen this before ? 😃

@Primusinterp
Copy link
Author

By debugging i found that the error was caused by a file without any extension. This caused the Value error.

I have made a quick fix in shared_azureblob.py , that stops the script from crashing when encountering a file without an extension:

    extension = ""
    
    
    if file_name := data_record.data_record.record_name:
        if "." in file_name:
            extension = file_name.split(".")[-1]
            last_index_for_extension = file_name.rindex(".")
            data_record.data_record.record_name = file_name[:last_index_for_extension]
        else:
            extension = ""

@Primusinterp
Copy link
Author

This tanks the performance so much that the access token expires before it can finish (and the environment is of course large as well)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant