Dependency Errors - QR Code Analyzes with Custom Action

Hi,

Im currently working on a way to analyze malicious QR Codes, so i develop a simple script that takes as input a list of base64 of the images and try to return possible links to further submit for analyses in the GTI.
The script makes use of the dependency "OpenCV" specially the module "CV2" that interprets the QRCodes, but unfortunately its give me errors of imports.
Is there any limitation regarding the use or installation this dependency.

 

025-07-10,09:38:43,000 INFO] Collecting managers.
[2025-07-10,09:38:43,000 INFO] Collecting dependencies.
[2025-07-10,09:38:43,000 INFO] Sending remote task package.
[2025-07-10,09:38:44,000 INFO] Waiting for remote task 86 to complete.
[2025-07-10,09:38:46,000 INFO] Remote task 86 has finished.
[2025-07-10,09:38:46,000 INFO] Decrypting results for task 86
[2025-07-10,09:38:46,000 INFO] Task 86 has failed with error message: Traceback (most recent call last):
  File "/opt/SiemplifyAgent/Integrations/COMPANY_NAME_V18.0/Tasks/Task-RUN_ACTION-86 [Action: QRCode Scan]/QRCode Scan.py", line 2, in <module>
    import cv2
  File "/opt/SiemplifyAgent/Integrations/COMPANY_NAME_V18.0/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/SiemplifyAgent/Integrations/COMPANY_NAME_V18.0/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Traceback (most recent call last):
  File "/opt/SiemplifyAgent/Integrations/COMPANY_NAME_V18.0/Tasks/Task-RUN_ACTION-86 [Action: QRCode Scan]/QRCode Scan.py", line 2, in <module>
    import cv2
  File "/opt/SiemplifyAgent/Integrations/COMPANY_NAME_V18.0/lib/python3.11/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/SiemplifyAgent/Integrations/COMPANY_NAME_V18.0/lib/python3.11/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
[2025-07-10,09:38:46,000 INFO] Deleting task 86
[2025-07-10,09:38:46,000 INFO] =========== End Remote Running of QRCode Scan , Agent: d3194067.... ============

 

 Any information would be helpful

0 2 454
2 REPLIES 2

The Script mention above

import base64
import cv2
import numpy as np
from SiemplifyAction import SiemplifyAction
from ScriptResult import EXECUTION_STATE_COMPLETED, EXECUTION_STATE_FAILED

SCRIPT_NAME = "QRCODE Analyses"

def decode_qrcodes(base64_strings):
    results = []
    for b64 in base64_strings:
        try:
            base64_data = b64.strip().replace('\n', '').replace(' ', '')
            image_data = base64.b64decode(base64_data)
            nparr = np.frombuffer(image_data, np.uint8)
            img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)

            if img is None:
                continue 

            qr_detector = cv2.QRCodeDetector()
            data = qr_detector.detectAndDecode(img)

            if data:
                results.append(data)
        except Exception as e:
            continue  
    return results

def main():
    siemplify = SiemplifyAction()
    siemplify.script_name = SCRIPT_NAME
    
    input_qrcode_base64 = siemplify.extract_action_param("QRCODE_Base64", print_value=True)
    
    qrcode_list = [b64 for b64 in input_qrcode_base64.split(",") if b64.strip()]
    
    decoded_results = decode_qrcodes(qrcode_list)
    
    if decoded_results:
        result = ",".join(decoded_results)
        print(result)
        output_message = f"Found {len(decoded_results)} QR Code(s): {result}"
        status = EXECUTION_STATE_COMPLETED
    else:
        result = ""
        output_message = "Not found any valid QR Codes"
        status = EXECUTION_STATE_FAILED

    siemplify.LOGGER.info(f"Status: {status}\nOutput: {output_message}")
    siemplify.end(output_message, result, status)

if __name__ == "__main__":
    main()

 

Hello,

 

First, great use case. Second I'm not aware of any restrictions. You would have to add your libraries dependency to your custom integration but you probably did this per documentation. It is possible the library is not available in our Python distribution. I'll follow up with this in more detail and get back on this question.