Skip to content

Commit

Permalink
Rapid7 Insight Agent - 17408 - Initial updates for fedramp compliance…
Browse files Browse the repository at this point in the history
… | Updated SDK to the latest version (#2727)
  • Loading branch information
igorski-r7 authored and ablakley-r7 committed Aug 27, 2024
1 parent c9bc248 commit 9b43246
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion plugins/rapid7_insight_agent/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"spec": "598d31d2610a89f081d49f3dc1d10976",
"spec": "f59d87215ea0009e75b43538d52e2546",
"manifest": "681189443bca37d2d249637d7a37d0a0",
"setup": "f3957c38946f523d42c3e0f39d443645",
"schemas": [
Expand Down
8 changes: 4 additions & 4 deletions plugins/rapid7_insight_agent/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Using the Insight Agent plugin from InsightConnect, you can quarantine, unquaran

# Supported Product Versions

* Rapid7 Insight Agent 2024-08-02
* Rapid7 Insight Agent 2024-08-23

# Documentation

Expand Down Expand Up @@ -454,12 +454,12 @@ Example output:


## Troubleshooting
- If the actions `Get Agent Details` and `Get All Agents by IP` return a `next cursor` value, it is an indication that more pages of data are available to be reviewed. In this instance, it is recommended to run the action multiple times and pass the `next cursor` value, recording all agents found.

If the actions `Get Agent Details` and `Get All Agents by IP` return a `next cursor` value, it is an indication that more pages of data are available to be reviewed. In this instance, it is recommended to run the action multiple times and pass the `next cursor` value, recording all agents found.

# Version History

* 3.0.0 - Update `Get Agent Details` and `Get All Agents by IP` to return the next page token if more pages are available to search | Update `Get Agent Details` to return agent location details
* 3.0.0 - Update `Get Agent Details` and `Get All Agents by IP` to return the next page token if more pages are available to search | Update `Get Agent Details` to return agent location details | Initial updates for fedramp compliance | Updated SDK to the latest version
* 2.1.2 - Improve logging | Update SDK
* 2.1.1 - `Get All Agents by IP Address`: Fixed issue where action failed when agent did not have a primary address, and extended output to include agent location details | `Get Agent Details`: Extended output to include agent's public IP address and location
* 2.1.0 - Updated SDK to the latest version | New action added `Get All Agents by IP Address`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Connection(insightconnect_plugin_runtime.Connection):
def __init__(self):
super(self.__class__, self).__init__(input=ConnectionSchema())

def connect(self, params):
def connect(self, params={}) -> None:
"""
Entry point for connection to the API
Expand All @@ -19,11 +19,10 @@ def connect(self, params):
"""
self.logger.info("Connect: Connecting...")

api_key = params.get(Input.API_KEY).get("secretKey")
api_key = params.get(Input.API_KEY, {}).get("secretKey")
region_string = params.get(Input.REGION)

self.api = ApiConnection(api_key, region_string, self.logger)

self.logger.info("Setup Complete")

def test(self):
Expand All @@ -33,11 +32,11 @@ def test(self):
:return: dict
"""
try:
success = self.api.connection_test()
self.api.connection_test()
return {"success": True}
except Exception as error:
raise ConnectionTestException(
cause="Connection Test Failed.",
assistance="Please check that your Region and API key are correct.",
data=error,
) from error
return {"success": success}
6 changes: 4 additions & 2 deletions plugins/rapid7_insight_agent/plugin.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ title: Rapid7 Insight Agent
description: Using the Insight Agent plugin from InsightConnect, you can quarantine, unquarantine and monitor potentially malicious IPs, addresses, hostnames, and devices across your organization
version: 3.0.0
connection_version: 2
supported_versions: ["Rapid7 Insight Agent 2024-08-02"]
supported_versions: ["Rapid7 Insight Agent 2024-08-23"]
vendor: rapid7
support: rapid7
status: []
cloud_ready: true
fedramp_ready: true
sdk:
type: slim
version: 6.1.0
Expand All @@ -20,12 +21,13 @@ key_features:
requirements:
- "[Platform API Key](https://docs.rapid7.com/insight/managing-platform-api-keys/)"
- "Administrator access to InsightIDR"
troubleshooting: "If the actions `Get Agent Details` and `Get All Agents by IP` return a `next cursor` value, it is an indication that more pages of data are available to be reviewed. In this instance, it is recommended to run the action multiple times and pass the `next cursor` value, recording all agents found."
links:
- "[Rapid7 Insight Agent](https://docs.rapid7.com/insight-agent/overview/)"
references:
- "[Manage Platform API Keys](https://docs.rapid7.com/insight/managing-platform-api-keys/)"
version_history:
- "3.0.0 - Update `Get Agent Details` and `Get All Agents by IP` to return the next page token if more pages are available to search | Update `Get Agent Details` to return agent location details"
- "3.0.0 - Update `Get Agent Details` and `Get All Agents by IP` to return the next page token if more pages are available to search | Update `Get Agent Details` to return agent location details | Initial updates for fedramp compliance | Updated SDK to the latest version"
- "2.1.2 - Improve logging | Update SDK"
- "2.1.1 - `Get All Agents by IP Address`: Fixed issue where action failed when agent did not have a primary address, and extended output to include agent location details | `Get Agent Details`: Extended output to include agent's public IP address and location"
- "2.1.0 - Updated SDK to the latest version | New action added `Get All Agents by IP Address`"
Expand Down
2 changes: 1 addition & 1 deletion plugins/rapid7_insight_agent/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# List third-party dependencies here, separated by newlines.
# All dependencies must be version-pinned, eg. requests==1.2.0
# See: https://pip.pypa.io/en/stable/user_guide/#requirements-files
parameterized==0.8.1
parameterized==0.8.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from jsonschema import validate

sys.path.append(os.path.abspath("../"))
from util import Util

from icon_rapid7_insight_agent.actions.check_agent_status.action import CheckAgentStatus
from icon_rapid7_insight_agent.actions.check_agent_status.schema import Input

from util import Util


@patch("requests.sessions.Session.post", side_effect=Util.mocked_request)
class TestCheckAgentStatus(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from typing import Any, Dict
from unittest import TestCase

from util import Util

from icon_rapid7_insight_agent.actions.get_agent_details import GetAgentDetails
from icon_rapid7_insight_agent.actions.get_agent_details.schema import Input

from util import Util


@patch("requests.sessions.Session.post", side_effect=Util.mocked_request)
class TestGetAgentDetails(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
from unittest import TestCase
from unittest.mock import MagicMock, patch

from icon_rapid7_insight_agent.actions.get_all_agents_by_ip import GetAllAgentsByIp
from icon_rapid7_insight_agent.actions.get_all_agents_by_ip.schema import Input, Output
from insightconnect_plugin_runtime.exceptions import PluginException
from jsonschema import validate
from parameterized import parameterized

from util import Util

from icon_rapid7_insight_agent.actions.get_all_agents_by_ip import GetAllAgentsByIp
from icon_rapid7_insight_agent.actions.get_all_agents_by_ip.schema import Input, Output


class TestGetAllAgentsByIp(TestCase):
def setUp(self) -> None:
Expand All @@ -34,7 +34,7 @@ def test_get_all_agents_by_ip(
def test_get_all_agents_by_ip_exception(self, mock_request: MagicMock) -> None:
with self.assertRaises(PluginException) as context:
self.action.run({Input.IP_ADDRESS: "BadIP"})
self.assertEqual(context.exception.cause, f"Invalid input IP address: 'BadIP'")
self.assertEqual(context.exception.cause, "Invalid input IP address: 'BadIP'")
self.assertEqual(
context.exception.assistance,
"Please ensure that the input is a valid IPv4 or IPv6 address.",
Expand Down
6 changes: 3 additions & 3 deletions plugins/rapid7_insight_agent/unit_test/test_quarantine.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
sys.path.append(os.path.abspath("../"))
from typing import Any, Dict

from icon_rapid7_insight_agent.actions.quarantine.action import Quarantine
from icon_rapid7_insight_agent.actions.quarantine.schema import Input
from jsonschema import validate

from util import Util

from icon_rapid7_insight_agent.actions.quarantine.action import Quarantine
from icon_rapid7_insight_agent.actions.quarantine.schema import Input


@patch("requests.sessions.Session.post", side_effect=Util.mocked_request)
class TestQuarantine(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
sys.path.append(os.path.abspath("../"))
from typing import Any, Dict, List

from icon_rapid7_insight_agent.actions.quarantine_multiple.action import QuarantineMultiple
from icon_rapid7_insight_agent.actions.quarantine_multiple.schema import Input
from insightconnect_plugin_runtime.exceptions import PluginException
from jsonschema import validate

from util import Util

from icon_rapid7_insight_agent.actions.quarantine_multiple.action import QuarantineMultiple
from icon_rapid7_insight_agent.actions.quarantine_multiple.schema import Input


@patch("requests.sessions.Session.post", side_effect=Util.mocked_request)
class TestQuarantineMultiple(TestCase):
Expand Down
9 changes: 7 additions & 2 deletions plugins/rapid7_insight_agent/unit_test/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import os.path
import sys

sys.path.append(os.path.abspath("../"))
from icon_rapid7_insight_agent.connection import Connection
from icon_rapid7_insight_agent.connection.schema import Input

sys.path.append(os.path.abspath("../"))

DEFAULT_ENCODING = "utf-8"


class Util:
@staticmethod
Expand All @@ -24,7 +27,9 @@ def default_connector(action):

@staticmethod
def load_json(filename):
with open((os.path.join(os.path.dirname(os.path.realpath(__file__)), filename))) as file:
with open(
(os.path.join(os.path.dirname(os.path.realpath(__file__)), filename)), encoding=DEFAULT_ENCODING
) as file:
return json.loads(file.read())

@staticmethod
Expand Down

0 comments on commit 9b43246

Please sign in to comment.