IBM QRadar SOAR

IBM QRadar

Join this online topic group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#Security
#QRadar
#SecuringhybridcloudandAI
 View Only
  • 1.  Read from app.config

    Posted 10/15/19 04:53 AM
    Edited by Lucian Sipos 10/15/19 05:34 AM
    Hi all

    I would like to know how to read from the app.config (.resilient folder) directly from my function code.
    I have this last one, the config.py file and the section/options added in the app.config.

    What I have to put in my code ?
    Right now I use this:

    configuration_parameters = {'param1': self.options.get('param1'),
    'param2': self.options.get('param2')}
    Below I use this logic:

    for i, url in enumerate(configuration_parameters.values()):
    if "abc" in url:
    do_things()


    Is this right ? I am asking because I have an error* which, basically, says that the function in my workflow can't retrieve params.

    *Error:
    FunctionException_: <Traceback (most recent call last): File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/my_function/components/my_function.py", line 159, in _my_function my_function(configuration_parameters) File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/my_function/components/my_function.py", line 56, in above_code if "abc" in url: TypeError: argument of type 'NoneType' is not iterable > File "/opt/rh/python27/root/usr/lib/python2.7/site-packages/circuits/core/manager.py", line 855, in processTask raise value.extract()

    Thanks​

    ------------------------------
    Bruce Wayne
    ------------------------------


  • 2.  RE: Read from app.config
    Best Answer

    Posted 10/15/19 09:39 AM
    Edited by Lucian Sipos 10/15/19 10:09 AM
    The native way to read app.config values is to do:

    # __init__ method:

    super(FunctionComponent, self).__init__(opts)
    self.options = opts.get("your_package_name", {})
    # _function_name_here_function method:

    your_package_name_config = self.opts.get("your_package_name")
    username = your_package_name_config.get("username")
    password = your_package_name_config.get("password")
    api_ip = your_package_name_config.get("api_ip")

    Where in your app.config you have something like:
    [your_package_name]
    username="admin"
    password="12345"
    api_ip="http://123.456.789.100:443"

    See a simple example of writing the app.config section via the config.py here.
    ------------------------------
    Jared Fagel
    Cyber Security Analyst Intern
    Public Utility
    ------------------------------



  • 3.  RE: Read from app.config

    Posted 10/15/19 09:50 AM
    Edited by Lucian Sipos 10/15/19 10:08 AM
    In app.config the values are all inside double quotes ?

    Edit: No..

    ------------------------------
    Bruce Wayne
    ------------------------------



  • 4.  RE: Read from app.config

    Posted 10/15/19 11:09 AM
    They can be in quotes (optional). For example, if you have content with spaces, not having quotes would not work.

    ------------------------------
    Jared Fagel
    Cyber Security Analyst Intern
    Public Utility
    ------------------------------