InsightConnect Marketplace

Python 3 Script

Back to Marketplace

Python 3 Script

v2.0.2

Run a Python 3 script

Tags: python, python3, scripting, utilities


Actions
  • Run Function

Description

Python is a programming language that lets you work quickly and integrate systems more effectively. This plugin allows you to run Python 3 code. It includes Python 3.6.5 and its standard library as well as the following 3rd party libraries:

The Python 3 Script plugin also allows you to load custom modules via its connection parameters.

Key Features

  • Run a Python 3 script to securely orchestrate, automate, and respond to (almost) anything

Requirements

This plugin does not contain any requirements.

Documentation

Setup

Check out the plugin guide for more details on how to configure this plugin.

Name Type Default Required Description Enum
modules []string None False List of third-party modules to install for use in the supplied Python script None
timeout integer 60 True Timeout (in seconds) for installing third-party modules None

Technical Details

Actions

Run Function

This action is used to run a Python 3 function. Key names must line up with the parameter names expected by the function. It works the same way as the Python Script 2 plugin, see this tutorial for more guidance.

Input

An input object can be supplied as the params={} parameter for the function.

The run function should return an object, whose fields gets added to the results object, e.g.


def run(params={}):
  return { 'hello': 'world' }

This returns a string with key hello on the output object accessible at {{Step.hello}}.

Make sure you the edit the output variables so that they match the keys returned by the 'run()' function.

Name Type Default Required Description Enum
function python None False Function definition None
input object None False Input object to be passed as params={} to the run function None
Output

The default output variables are result1 and result2, both of type string. While these may work for you they're intended to be changed by the user to meet their naming and type needs.

Name Type Required Description
result2 string False Sample output result2 (delete or edit)
result1 string False Sample output result1 (delete or edit)

Make sure you the edit the output variables in the user interface so that they match the keys returned by the 'run()' function. This allows you to pass the variables to other steps using the names chosen by the user.

Example Output:


{
  "result1": "My result",
  "result2": "My result2"
}

Triggers

This plugin does not contain any triggers.

Custom Output Types

This plugin does not contain any custom output types.

Troubleshooting

This plugin does not contain any troubleshooting information.

Version History

  • 2.0.2 - Add docs_url to plugin spec with link to plugin setup guide
  • 2.0.1 - New spec and help.md format for the Extension Library
  • 2.0.0 - Add the ability to download and install third-party libraries for use while configuring the plugin Connection
  • 1.0.6 - Fix issue where undefined output exceptions were not being handled correctly
  • 1.0.5 - Add utilities plugin tag for Marketplace searchability
  • 1.0.4 - Fix issue where run action was excluded from plugin on build
  • 1.0.3 - Update to v2 Python plugin architecture | Support web server mode | Add and pin 3rd party libraries: lxml, beautifulsoup, pyyaml, maya, and records
  • 1.0.2 - SDK update
  • 1.0.1 - SSL bug fix in SDK
  • 0.1.0 - Initial plugin

Links

References

plugin_spec_version: v2
extension: plugin
products: [insightconnect]
name: python_3_script
title: Python 3 Script
vendor: rapid7
support: rapid7
status: []
description: Run a Python 3 script
version: 2.0.2
enable_cache: true
resources:
  source_url: https://github.com/rapid7/insightconnect-plugins/tree/master/python_3_script
  license_url: https://github.com/rapid7/insightconnect-plugins/blob/master/LICENSE
  docs_url: https://insightconnect.help.rapid7.com/docs/python-2-or-3-script
tags:
 - python
 - python3
 - scripting
 - utilities
hub_tags:
  use_cases: [data_utility]
  keywords: [python, python3, scripting, utilities]
  features: []

connection:
  modules:
    title: "Third-Party Modules"
    description: "List of third-party modules to install for use in the supplied Python script"
    required: false
    type: "[]string"
  timeout:
    title: "Timeout"
    description: "Timeout (in seconds) for installing third-party modules"
    required: true
    type: integer
    default: 60

actions:
  run:
    title: Run Function
    description: Run Python function
    input:
      function:
        description: Function definition. Must be named `run`. Accepts the `input`
          object as params. Returns the dict as output
        type: python
        default: def run(params={}):\n    return {}
        required: false
      input:
        description: Input object to be passed as `params={}` to the `run` function
        type: object
        required: false
    output:
      result1:
        description: Sample output result1 (delete or edit)
        type: string
        required: false
      result2:
        description: Sample output result2 (delete or edit)
        type: string
        required: false
Other plugins
Ivanti Security Controls
Rapid7   |   v1.5.0
Plugin
Get
McAfee ePO
Rapid7   |   v5.0.0
Plugin
Get
BlackBerry CylancePROTECT
Rapid7   |   v1.1.0
Plugin
Get
Fortinet FortiGate
Rapid7   |   v4.0.4
Plugin
Get
Jira
Rapid7   |   v6.0.1
Plugin
Get