Troubleshooting Tip: How to fix code snippet action failure
Description
This article describes the steps to overcome failures for the code snippet connector action due to the following error:
'This connector restricts certain modules: cPickle, ctypes, glob, http, imp, importlib, inspect, io, marshal, multiprocessing, os, pathlib, pickle, shelve, shutil, socket, subprocess, sys, tempfile. Remove these imports from the code and retry.'
Scope
FortiSOAR.
Solution
These modules have been restricted in newer versions of the code-snippet connector as a security enhancement, as they could be leveraged to manipulate application resources, execute unauthorized operations, access sensitive data, or otherwise impact the security and integrity of the application.
If it is required to be enabled for Admin Teams:
Take a backup of the existing file using the following:
sudo cp -a /opt/cyops/configs/integrations/connectors/code-snippet_2_2_1/constants.py /opt/cyops/configs/integrations/connectors/code-snippet_2_2_1/constants.py_bkpEdit the file using:
sudo vi /opt/cyops/configs/integrations/connectors/code-snippet_2_2_1/constants.pyComment on the modules that need to be allowed from the PERMANENTLY_BLACKLISTED_MODULES dictionary, save the file using 'ESC' followed by ':wq' and execute the following:
sudo rm -rvf /opt/cyops/configs/integrations/connectors/code-snippet_2_2_1/__pycache__Â
sudo systemctl restart uwsgi
Use this to limit access to these modules across users. The instance can be configured with a private configuration.Â
Related documents:
Connectors Guide (This link goes to the Introduction to Connectors section.)
