IBM Security SOAR

Expand all | Collapse all

Using resilient-circuit codegen --reload to recreate your Python package

  • 1.  Using resilient-circuit codegen --reload to recreate your Python package

    Posted Thu November 29, 2018 03:48 PM
    When you first create a Resilient Python package containing your function,
    use resilient-circuits codegen as follows:

    $ resilient-circuits codegen --p <package_name> --function <function_name>

    In Resilient V31 and greater, resilient-circuits codegen --reload
    capability is available to allow easier re-creation of an existing
    package.

    To re-create an existing package "as is" with no new components, create
    a new export file from within the Resilient UI. If the export file is
    in the Downloads directory, simply enter the command:

    $ resilient codegen --reload <package_name>

    To re-create an existing package and add new components to it, use the
    codegen --reload command and add your new components to the command
    line without specifying the components you added the last time you
    created the package. The following example reloads your package with
    all previous components and adds a new rule:

    $ resilient codegen --reload <package_name> --rule "Cisco Add Domain"

    The resilient-circuits codegen --reload command saves the existing customize.py as
    customize-yyymmdd-hhmmss.bak in the util directory of the package.

    NOTE: The --exportfile parameter is needed only if the most recently created
    export file (.res) in Downloads is not the intended file or the export
    file you want is in a different location.

    NOTE: You cannot reload a package generated with a version of
    Resilient Circuits prior to V31. If you wish to use reload, you need
    to rename your customize.py then generate a new package using
    Resilient Circuits V31. You can then use reload for the new package.

    NOTE: To determine if your package has reload capability look at top of the
    package's customize.py file located in the package/util directory. If
    the customize.py file contains the following function:

    def codegen_reload_data():

    then --reload is supported. The codegen_reload_data function contains
    a list of all components included in the package.

    ------------------------------
    AnnMarie Norcross
    ------------------------------


  • 2.  RE: Using resilient-circuit codegen --reload to recreate your Python package

    Posted Tue December 04, 2018 04:18 PM
    It should be noted that the $ resilient-circuits codegen --reload
    capability is available starting in V30.0.111 of resilient-circuits.  It will soon be available in the V31 resilient-circuits release as well.

    Also, there were 2 instances where $ resilient should be $ resilient-circuits  in my previous message.

    ------------------------------
    AnnMarie Norcross
    ------------------------------



  • 3.  RE: Using resilient-circuit codegen --reload to recreate your Python package

    Posted Wed June 30, 2021 03:26 PM
    Hi AnnMarie, Thank you for writing this very informative post. I stumbled across this when trying to troubleshoot why 'resilient-sdk codegen --reload' was failing for me.

    'resilient-sdk codegen --reload' FAILED
    ERROR: Function: 'get_incidents' not found in this export.​

    it seems that my only "export" is from many weeks prior (when just beginning development) and contains a reference to a function and message destination that no longer exist in my package. I'm wondering how to re-export or remove these references?

    I see the values for the old function and message destination hardcoded/spliced into the codegen_reload_data() method.. is there a way to overwrite these automatically with all of the new message destinations, functions, workflows, etc.? 

    def codegen_reload_data():
        """
        Parameters required reload codegen for the xdr_int package
        """
        return {
            "package": u"xdr_int",
            "message_destinations": [u"xdr_dest"],
            "functions": [u"get_incidents"],
            "workflows": [],​

    Thanks for any insight you may have.

    FYI I'm 40.2.1939 for circuits, sdk and lib. However, I did upgrade from v38 during development if this may have caused any strange behavior.

    ------------------------------
    Tom Prenderville
    ------------------------------