stix-shifter icon indicating copy to clipboard operation
stix-shifter copied to clipboard

Exception: module 'collections' has no attribute 'Mapping' for python version 3.10

Open indrajit0909 opened this issue 3 years ago • 1 comments

Describe the bug I am using python version 3.10 and when I am trying to run the test cases for connectors like aws_athena, some test cases are failing. So when I debugged the code I found that lines 46 and 49 of file stix_shifter_utils/utils/error_response.py threw exception which stated module 'collections' has no attribute 'Mapping'. Also when I am trying to run execute command for few connectors I found a similar error on line 128 for file stix_shifter_utils/stix_transmission/utils/RestApiClient.py which stated stix_shifter_utils.stix_transmission.utils.RestApiClient ERROR exception occured during requesting url: module 'collections' has no attribute 'Mapping'.

To Reproduce Steps to reproduce the behavior:

  1. Upgrade to python version 3.10
  2. Run the execute cmd for any UDP connector
  3. See error

Expected behavior The execute cmd should run successfully and the test cases should not fail

Additional context Below is the stack trace for execute command of UDP connector

2022-01-05 11:01:11,264 stix_shifter_modules.reversinglabs.stix_translation.query_translator INFO     Converting STIX2 Pattern to data source query
 2022-01-05 11:01:11,269 stix_shifter.scripts.stix_shifter INFO     Translated Queries: 
{
    "queries": [
        "{'data': 'www.cnn.com', 'dataType': 'domain'}"
    ]
}
 2022-01-05 11:01:12,507 stix_shifter_utils.stix_transmission.utils.RestApiClient ERROR    exception occured during requesting url: module 'collections' has no attribute 'Mapping'
 2022-01-05 11:01:12,507 stix_shifter_modules.reversinglabs.stix_transmission.results_connector ERROR    error when getting search results: module 'collections' has no attribute 'Mapping'
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/main.py", line 4, in <module>
    main()
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/stix_shifter/scripts/stix_shifter.py", line 299, in main
    result = transmission.results(search_id, 0, 9)
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/stix_shifter/stix_transmission/stix_transmission.py", line 56, in results
    return self.entry_point.create_results_connection(search_id, offset, length)
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/stix_shifter_utils/utils/base_entry_point.py", line 79, in wrapper_func
    return func(self, *args, **kwargs)
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/stix_shifter_utils/utils/base_entry_point.py", line 264, in create_results_connection
    return self.__results_connector.create_results_connection(search_id, offset, length)
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/stix_shifter_modules/reversinglabs/stix_transmission/results_connector.py", line 59, in create_results_connection
    self.logger.error(traceback.print_stack())
 2022-01-05 11:01:12,508 stix_shifter_modules.reversinglabs.stix_transmission.results_connector ERROR    None
 2022-01-05 11:01:12,509 stix_shifter_utils.utils.error_response ERROR    error occurred: module 'collections' has no attribute 'Mapping'
Traceback (most recent call last):
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/main.py", line 4, in <module>
    main()
  File "/Users/indrajit/Desktop/TIS/tis.stix_shifter/stix_shifter/scripts/stix_shifter.py", line 306, in main
    raise RuntimeError("Fetching results failed; see log for details")
RuntimeError: Fetching results failed; see log for details

Solution Changing collections.Mapping to collections.abc.Mapping fixes the issue. I have checked it with version 3.9 as well and the change works for it as well.

indrajit0909 avatar Jan 05 '22 05:01 indrajit0909

@indrajit0909 stix-shifter doesn't support python 3.10 yet. it will be addressed when we support 3.10.

mdazam1942 avatar Jan 05 '22 19:01 mdazam1942