IBM QRadar SOAR

IBM QRadar SOAR

Join this online user 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.

 View Only
  • 1.  Error handling and keystore question

    Posted 04/11/19 11:59 AM
      |   view attached
    Hi all,

    I am wrapping up a function I have create and had a few questions:

    1. Does Resilient not come configured with a keystore? I ask b/c the function I've created needs to stored user credentials and I'd rather not have them store in plaintext within the app.conf file. Reading the function documentation I see you can insert keystore values (ex. ^integration_password) and "run res-keyring" to put a value in the keystore for "integration_password". However after doing this and trying to run resilient-circuits I get the below error. 
    2. Is it expected that stacktraces are shown to users when errors occur within a function or should a more user friendly error be shown? If its the later how would I go about doing that. I've attached a screenshot of what I am looking at. From the function documentation and other examples I've seen on git I yield a FunctionError(). 

    -bash-4.2$ vi .resilient/app.config

    -bash-4.2$ res-keyring

    Configuration file: /home/resadmin/.resilient/app.config

    Secrets are stored with 'keyring.backends.chainer'

    [cyber_triage] password: <not set>

    Enter new value (or <ENTER> to leave unchanged): test

    Confirm new value: test

    Value set.

    [cyber_triage] api_key: <not set>

    Enter new value (or <ENTER> to leave unchanged):

    Done.

    -bash-4.2$ resilient-circuits run

    Traceback (most recent call last):

    File "/usr/local/bin/resilient-circuits", line 11, in <module>

    sys.exit(main())

    File "/usr/local/lib/python2.7/site-packages/resilient_circuits/bin/resilient_circuits_cmd.py", line 611, in main

    config_file=args.config_file)

    File "/usr/local/lib/python2.7/site-packages/resilient_circuits/bin/resilient_circuits_cmd.py", line 88, in run

    app.run(**kwargs)

    File "/usr/local/lib/python2.7/site-packages/resilient_circuits/app.py", line 311, in run

    application = App(*args, **kwargs)

    File "/usr/local/lib/python2.7/site-packages/resilient_circuits/app.py", line 171, in __init__

    self.do_initialization()

    File "/usr/local/lib/python2.7/site-packages/resilient_circuits/app.py", line 174, in do_initialization

    self.opts = AppArgumentParser(config_file=self.config_file).parse_args()

    File "/usr/local/lib/python2.7/site-packages/resilient_circuits/app.py", line 145, in parse_args

    parse_parameters(opts)

    File "/usr/local/lib/python2.7/site-packages/resilient/co3argparse.py", line 272, in parse_parameters

    return _parse_parameters(names, options)

    File "/usr/local/lib/python2.7/site-packages/resilient/co3argparse.py", line 280, in _parse_parameters

    val = _parse_parameters(names + (key,), val)

    File "/usr/local/lib/python2.7/site-packages/resilient/co3argparse.py", line 289, in _parse_parameters

    val = keyring.get_password(service, val)

    File "/usr/local/lib/python2.7/site-packages/keyring/core.py", line 57, in get_password

    return _keyring_backend.get_password(service_name, username)

    File "/usr/local/lib/python2.7/site-packages/keyring/backends/fail.py", line 24, in get_password

    raise RuntimeError(msg)

    RuntimeError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https://pypi.org/project/keyring for details.

    -bash-4.2$



    ------------------------------
    Chris Ray
    ------------------------------


  • 2.  RE: Error handling and keystore question

    Posted 04/11/19 12:53 PM
    Hi Chris,

    The Resilient Python package does not come with a keyring, this is dependent on your OS. A compatible one must be installed. 

    Based on Resilient currently it is a limation to print out the stack trace, but below is an example of the suggested way to raise a <g class="gr_ gr_264 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="264" data-gr-id="264">FunctionError</g>().
    try:
        # Get the function parameters:
        incident_id = kwargs.get("incident_id")  # number
        task_id = kwargs.get("task_id")  # number
    
        if incident_id is None and task_id is None:
            raise FunctionError("Error: incident_id or task_id must be specified.")
    
        # Body of function code #
    
    except:
        yield FunctionError()


    ------------------------------
    Brian Walsh
    ------------------------------



  • 3.  RE: Error handling and keystore question

    Posted 04/11/19 01:11 PM
    Brian,

    Thanks for the speedy reply. Is there any documentation on the compatible keyrings and how to configure them to work with resilient? If so can you point me in the right direction. 

    Thanks!
    Chris

    ------------------------------
    Chris Ray
    ------------------------------



  • 4.  RE: Error handling and keystore question

    Posted 04/11/19 04:12 PM
    Sorry, we have not officially validated any keyring backend packages. We are aware of this and have plans to provide more guidance in the future.

    ------------------------------
    Brian Walsh
    ------------------------------



  • 5.  RE: Error handling and keystore question

    Posted 04/12/19 06:45 AM
    It looks like you have a back end installed from the output you pasted previously.

    Secrets are stored with 'keyring.backends.chainer'

    Res-keyring can be used to store passwords but they are stored in a file on the OS unlike other backends.

    If you want to try this approach you can uninstall the current backend you have installed and then take a look at this document that provides some steps you might need to undertake to get res-keyring storing passwords correctly.

    ------------------------------
    BEN WILLIAMS
    ------------------------------



  • 6.  RE: Error handling and keystore question

    Posted 04/12/19 07:09 AM
    That did the trick. Thanks Ben!

    ------------------------------
    Chris Ray
    ------------------------------