Current ThreatQ Version Filter
 

Virtual Python 3.6 Environments

Python 3 ThreatQ custom connectors require a Python 3.6 environment.  The following steps will walk you through how to install a virtual Python 3.6 environment in ThreatQ version 5 as well custom connector command differences. 

Deploying a Virtual Python 3.6 Environment in TQv5

Run the following commands to create a virtual environment:

Replace the <environment> with the name of your environment.  

mkdir /opt/tqvenv/
sudo yum install -y python36 python36-libs python36-devel python36-pip
python3.6 -m venv /opt/tqvenv/<environment_name>
source /opt/tqvenv/<environment_name>/bin/activate
pip install --upgrade pip
pip install setuptools==59.6.0
pip install threatqsdk threatqcc

Activating the Virtual Environment

You must first activate your environment before running the pip install command to install a custom connector from the ThreatQ Download Repository.

source /opt/tqvenv/<environment_name>/bin/activate 

PIP Installation

The pip installation command remains the same.

pip install /tmp/<whl_file_name>-<version>-py3-none-any.whl

pip install /tmp/tq_conn_ms_sentinel-1.3-py3-none-any.whl

You must first activate the virtual environment before running the pip install command.  

Integration Drivers

Custom Connectors in a virtual python 3 environment will have an additional pathway added to driver execution command.  These pathways must be included in order to successfully execute the driver within the virtual environment.

Python 3.6 Virtual Environment Execute Driver Example:

/opt/tqvenv/<environment_name>/bin/<driver-name> -c /var/log/tq_labs/ -ll /etc/tq_labs/ -v3

CRON 

Custom Connector CRON jobs in a virtual python 3 environment must have an additional pathway added to the command.

Python 3.6 Virtual Environment CRON Example

0 */1 * * * /opt/tqvenv/<environment_name>/bin/<driver-name> -c /etc/tq_labs/ -ll /var/log/tq_labs/ -v