We followed everything using playbook designer guide, our function executed successfully, however looks proxy request never execute, please refer the attached python scripts and output from app log
On our logs and action status shows success, but never passed to our proxy server.
"""Function: """
try:
# Get the function parameters:
dns_name = kwargs.get("dns_name") # text
log = logging.getLogger(__name__)
log.info("\nargs:",args,"\n\nkwargs:",kwargs)
log.info("dns_name: %s", dns_name)
# PUT YOUR FUNCTION IMPLEMENTATION CODE HERE
# yield StatusMessage("starting...")
proxies = {
"http": "http://192.x.x.x:8081",
"https": "http://192.x.x.x:8081",
}
r = requests.get("dns_name", proxies=proxies)
r1 = requests.get("http://toscrape.com", proxies=proxies)
log.info("\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@output")
-----------------------
2021-01-20 00:08:48,156 INFO [actions_component] Event: <web_marshal_url_proxy[] (id=7, workflow=web_marshal, user=
sunil@techlab.com.my) 2021-01-19 16:08:47.954000> Channel: functions.web_marshal_url_proxy
2021-01-20 00:08:48,156 DEBUG [stomp_component] Stomp message received
2021-01-20 00:08:48,157 DEBUG [client] Received heart-beat
2021-01-20 00:08:48,158 DEBUG [actions_component] success! None, <web_marshal_url_proxy[functions.web_marshal_url_proxy] (id=7, workflow=web_marshal, user=
sunil@techlab.com.my) 2021-01-19 16:08:47.954000>
2021-01-20 00:08:48,158 ERROR [action_message] FunctionResult must be a dictionary. 'NoneType' may cause the workflow to fail.
2021-01-20 00:08:48,158 DEBUG [actions_component] Message: Completed
2021-01-20 00:08:48,159 DEBUG [actions_component] Ack ID:resilient.localdomain-45699-1610428308961-3:2:385:1:1
2021-01-20 00:08:48,159 DEBUG [actions_component] Result: None
2021-01-20 00:08:48,160 DEBUG [stomp_component] ack_frame()
2021-01-20 00:08:48,160 DEBUG [client] Sending ACK frame [headers={'id': u'ID:resilient.localdomain-32976-1610428190598-13:1'}, version=1.2]
2021-01-20 00:08:48,173 DEBUG [stomp_component] Ack Sent
2021-01-20 00:08:48,174 DEBUG [stomp_component] send()
2021-01-20 00:08:48,174 DEBUG [client] Sending SEND frame [headers={'destination': u'/queue/acks.201.email_outbound', 'correlation-id': u'invid:526'}, body='{\n "message": "Comp...', version=1.2]
------------------------------
Sunil I B
------------------------------
Original Message:
Sent: Thu January 14, 2021 10:24 AM
From: Burak Karaduman
Subject: Script Execution for Artifact Rules
Hello,
We cannot install any libs for internal resilient script. The python env that you try to write a script in GUI cannot be changed from users. You should make an integration for your purpose. If you didnt, you should read the playbook designer guide,
------------------------------
Burak Karaduman
Original Message:
Sent: Thu January 14, 2021 10:15 AM
From: Sunil I B
Subject: Script Execution for Artifact Rules
We already created package and install using pip, so we need to create another package, or how to make use of existing package,
Is it possible to do like create only new python script on top of existing package, then make use of existing destination, could you please share right approach.
------------------------------
Sunil I B
Original Message:
Sent: Thu January 14, 2021 09:49 AM
From: Burak Karaduman
Subject: Script Execution for Artifact Rules
Hello,
The lib 're' is a regex library. You cannot make web requests via 're' lib. You can do it externally with using function and workflow.
------------------------------
Burak Karaduman
Original Message:
Sent: Thu January 14, 2021 08:14 AM
From: Sunil I B
Subject: Script Execution for Artifact Rules
We tried using re whitelist list still getting different error, our request is simple whenever artifact got DNS Name, then we need to send to our proxy server.
In OS level able to achieve one line or OS Level python script working fine, however not working in Resilient, any suggestion for the attached erorr or code level,
We using Menu Item Rule instead of Automatic, whenever we found DNS Name, then send to proxy server, In our proxy it will be blocked using proxy policy rules.
OS Level
http_proxy=http://<IP>:<Port> wget <URL>
OS Python Script
import re
proxies = {
"http": "http://192.168.1.24:8081",
"https": "http://192.168.1.24:8081",
}
r = re.get("http://toscrape.com", proxies=proxies
------------------------------
Sunil I B
Original Message:
Sent: Thu January 14, 2021 07:54 AM
From: Burak Karaduman
Subject: Script Execution for Artifact Rules
Hello,
You cannot import 'requests' library in resilient scripts. The lib whitelist like link in below.
https://www.ibm.com/support/knowledgecenter/SSBRUQ_39.0.0/doc/playbook/python2_and_3.html
- array
- base64
- bs4
- calendar
- collections
- datetime (equivalent to the Python 2 java.util.Date module)
- email
- enum
- hashlib
- html
- html2text
- json
- random
- re
- regex
- string
- time
- xml
In addition, the following Python built-ins are available for Python 3 scripts only:
- all()
- any()
- bytearray()
- bytes()
- classmethod
- staticmethod
- type()
The following restrictions apply to both Python 2 and 3 scripts:
- You cannot import Python libraries, including os, subprocess, sys, and threading.
- Access to the network or filesystem is not allowed for security reasons.
------------------------------
Burak Karaduman
Original Message:
Sent: Thu January 14, 2021 07:22 AM
From: Sunil I B
Subject: Script Execution for Artifact Rules
We wrote below simple script on Resilient Customization Setting Script tab for the Artifact DNS value type, however we getting error as
Script
import requests
proxies = {
"http": "http://192.168.1.24:8081",
"https": "http://192.168.1.24:8081",
}
r = requests.get(artifact.value, proxies=proxies, verify=False)
Output from Resilient
Script contain illegal import request
When we change to import re then getting permission error, please refer below screenshots for the reference
------------------------------
Sunil I B
------------------------------