Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Palo Alto Cortex XDR | Get Incidents trigger patch #2906

Closed
wants to merge 41 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bf71011
Updated armorblox plugin with the review comments. (#1721)
SamhithaTatipalli Jun 15, 2023
0d84890
run black linter, fix unit tests and validators (#1857)
llaszuk-r7 Jul 5, 2023
d272a27
SOAR-17026-Bumping requirements of requests (#2565)
rbowden-r7 May 31, 2024
6999af0
[Soar 17409] - Microsoft Teams - Adding fedramp true flag (#2805)
rbowden-r7 Sep 20, 2024
d7cb870
SOAR-1709-adding execute permissons to the bin file of teams (#2825)
rbowden-r7 Sep 25, 2024
44fa1d9
SOAR-17409-Bumping SDK to latest (#2830)
rbowden-r7 Sep 26, 2024
21062eb
Advanced Regex - 17800 - Initial updates for fedramp compliance | Upd…
igorski-r7 Oct 2, 2024
a6d5eab
[SOAR-17793] Abnormal Security - Case ID issue (#2751)
rmurray-r7 Oct 4, 2024
6e02773
[SOAR-17871] azure_blob_storage SDK bump, snyk vulnerability (#2844)
lcwiklinski-r7 Oct 9, 2024
04c461b
Basename - 17801 - Initial updates for fedramp compliance | Updated S…
igorski-r7 Oct 9, 2024
a1d36fa
Sleep - 17805 - Initial updates for fedramp compliance | Updated SDK …
igorski-r7 Oct 9, 2024
3a57598
Subnet - 17807 - Initial updates for fedramp compliance | Updated SDK…
igorski-r7 Oct 9, 2024
fb4afa2
Subnet - 17807 - Added fedramp flag (#2851)
igorski-r7 Oct 9, 2024
78639f3
HTML - 16968 - Initial updates for fedramp compliance | Updated SDK t…
igorski-r7 Oct 10, 2024
e97f71e
ExtractIt - 17802 - Initial updates for fedramp compliance | Updated …
igorski-r7 Oct 10, 2024
9080bd2
Hashit - 17803 - Initial updates for fedramp compliance | Updated SDK…
igorski-r7 Oct 10, 2024
fdfdf94
Math - 17804 - Initial updates for fedramp compliance | Updated SDK t…
igorski-r7 Oct 10, 2024
8ec0a30
[SOAR-17883] rapid7_insightcloudsec, SDK bump, adding a new functiona…
lcwiklinski-r7 Oct 11, 2024
5358733
Python 3 Script - 17899 - Action Run: Added timeout optional paramete…
igorski-r7 Oct 14, 2024
88509f2
Subnet - 17807 - Updated checksum (#2864)
igorski-r7 Oct 14, 2024
83ec101
Bump SDK Carbonblackcloud (#2869)
nmccullagh-r7 Oct 15, 2024
1df1d02
Addressing snyk vulns, SDK Bump (#2867)
rmurray-r7 Oct 15, 2024
5f8d4e1
[SOAR-17934] Snyk Vulnerabilities in pdf_reader (#2866)
rmurray-r7 Oct 15, 2024
78bfbdd
Python 3 Script - 17899 - Bumped SDK version (#2871)
igorski-r7 Oct 15, 2024
dc18361
Python 3 Script - 17899 - Updated timeout error message (#2875)
igorski-r7 Oct 16, 2024
67c6776
Palo Alto | Unit Tests (#2838)
cmcnally-r7 Oct 16, 2024
f2c9234
remove armorblocks (#2882)
nmccullagh-r7 Oct 18, 2024
079b10c
bump gha python version (#2880)
nmccullagh-r7 Oct 18, 2024
31142e2
[SOAR-17915] Salesforce | Return 500 for 'retry your request' error (…
cmcnally-r7 Oct 22, 2024
95dca85
[Carbon Black Cloud] Observability Window Restraint (#2877)
nmccullagh-r7 Oct 23, 2024
4f74e86
InsightVM Cloud - 840 - Added optional asset and vulnerability criter…
igorski-r7 Oct 23, 2024
d3c4a20
[SOAR-17996] rdap Snyk Vulnerability and SDK Bump (#2886)
rmurray-r7 Oct 23, 2024
79366dc
[SOAR-17997] urlscan Snyk vulnerability and SDK Bump (#2887)
rmurray-r7 Oct 24, 2024
da3201b
InsightVM Cloud - 840 - Updated size parameter description (#2893)
igorski-r7 Oct 24, 2024
0b53f03
[SOAR-18010] Zscaler Snyk and SDK bump (#2895)
rmurray-r7 Oct 25, 2024
62fb78e
Palo Alto Cortex XDR | Updates (#2889)
cmcnally-r7 Oct 25, 2024
6fc3c0a
WHOIS - 18012 - Action Address: Fixed issue with result parsing (#2899)
igorski-r7 Oct 28, 2024
72388c1
Palo Alto Cortex XDR | Undo change to list split for get incidents tr…
cmcnally-r7 Oct 28, 2024
31f5891
[SOAR-18019] Hybrid Analysis - Snyk & SDK Bump (#2901)
rmurray-r7 Oct 28, 2024
f7977ac
[SOAR-18015] Devo - Snyk and SDK Bump (#2900)
rmurray-r7 Oct 28, 2024
4a3f263
Implement potential trigger patch
cmcnally-r7 Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/html/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"spec": "f5482a1cef5e1328c18792ff5c50d80d",
"manifest": "ff24d95d8572ec0b30dc435956525e48",
"setup": "e17dd73a961bd7a3bbdabe362a23d382",
"spec": "1c682e5751de39f77df69ff820118640",
"manifest": "f8496c6f37c90b1549c58634683b21a8",
"setup": "8f8d60fa7c130285701aae5de46f6632",
"schemas": [
{
"identifier": "docx/schema.py",
4 changes: 2 additions & 2 deletions plugins/html/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.0.1
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-slim-plugin:6.1.3

LABEL organization=rapid7
LABEL sdk=python
LABEL type=plugin

RUN apt-get update && apt-get install -y pandoc texlive lmodern --no-install-recommends
RUN apt-get update && apt-get install -y texlive lmodern --no-install-recommends

WORKDIR /python/src

2 changes: 1 addition & 1 deletion plugins/html/bin/icon_html
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ from sys import argv

Name = "HTML"
Vendor = "rapid7"
Version = "1.2.6"
Version = "1.2.7"
Description = "Hypertext Markup Language (HTML) is the standard markup language for documents designed to be displayed in a web browser. This plugin provides the ability to convert an HTML document into a variety of formats using [pypandoc](https://pypi.python.org/pypi/pypandoc). Supported formats are: DOCX, EPUB, Markdown, PDF, HTML5, Plain Text"


3 changes: 2 additions & 1 deletion plugins/html/help.md
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ Hypertext Markup Language (HTML) is the standard markup language for documents d

# Supported Product Versions

* 2023-08-30
* 2024-09-30

# Documentation

@@ -271,6 +271,7 @@ Example output:

# Version History

* 1.2.7 - Initial updates for fedramp compliance | Updated SDK to the latest version
* 1.2.6 - SDK Bump | Addressing Snyk vulnerabilities | Fixing Unit Tests | Dockerfile USER permission updated
* 1.2.5 - Update requirements for pypandoc
* 1.2.4 - Actions modified in order to implement PluginExceptions
25 changes: 6 additions & 19 deletions plugins/html/icon_html/actions/docx/action.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import insightconnect_plugin_runtime
import base64
import pypandoc
import re

from insightconnect_plugin_runtime.exceptions import PluginException
from .schema import DocxInput, DocxOutput, Output, Input, Component
from icon_html.util.api import HTMLConverter
from icon_html.util.strategies import ConvertToDocx


class Docx(insightconnect_plugin_runtime.Action):
@@ -14,18 +11,8 @@ def __init__(self):
)

def run(self, params={}):
temp_file = "temp_html_2_docx.docx"
tag_parser = "(?i)<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>" # noqa: W605
doc = params.get(Input.DOC)
tags = re.findall(tag_parser, doc)

if not tags:
raise PluginException(cause="Invalid input.", assistance="Input must be of type HTML.")
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
document = params.get(Input.DOC, "")
# END INPUT BINDING - DO NOT REMOVE

try:
pypandoc.convert_text(doc, "docx", outputfile=temp_file, format="html")
except RuntimeError as error:
raise PluginException(cause="Error converting doc file. ", assistance="Check stack trace log.", data=error)
with open(temp_file, "rb") as output:
# Reading the output and sending it in base64
return {Output.DOCX: base64.b64encode(output.read()).decode("utf-8")}
return {Output.DOCX: HTMLConverter(ConvertToDocx()).convert(document)}
25 changes: 6 additions & 19 deletions plugins/html/icon_html/actions/epub/action.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import insightconnect_plugin_runtime
import base64
import pypandoc
import re

from insightconnect_plugin_runtime.exceptions import PluginException
from .schema import EpubInput, EpubOutput, Input, Output, Component
from icon_html.util.api import HTMLConverter
from icon_html.util.strategies import ConvertToEpub


class Epub(insightconnect_plugin_runtime.Action):
@@ -14,18 +11,8 @@ def __init__(self):
)

def run(self, params={}):
temp_file = "temp_html_3_epub.epub"
tag_parser = "(?i)<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>" # noqa: W605
doc = params.get(Input.DOC)
tags = re.findall(tag_parser, doc)

if not tags:
raise PluginException(cause="Invalid input.", assistance="Input must be of type HTML.")
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
document = params.get(Input.DOC, "")
# END INPUT BINDING - DO NOT REMOVE

try:
pypandoc.convert_text(doc, "epub", outputfile=temp_file, format="html")
except RuntimeError as error:
raise PluginException(cause="Error converting doc file. ", assistance="Check stack trace log.", data=error)
with open(temp_file, "rb") as output:
# Reading the output and sending it in base64
return {Output.EPUB: base64.b64encode(output.read()).decode("utf-8")}
return {Output.EPUB: HTMLConverter(ConvertToEpub()).convert(document)}
30 changes: 12 additions & 18 deletions plugins/html/icon_html/actions/html5/action.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import insightconnect_plugin_runtime
from insightconnect_plugin_runtime.exceptions import PluginException
import pypandoc
import base64
import re
from .schema import Html5Input, Html5Output, Input, Output, Component
from icon_html.util.api import HTMLConverter
from icon_html.util.helpers import encode_to_base64
from icon_html.util.strategies import ConvertToHTML, ConvertToHTML5


class Html5(insightconnect_plugin_runtime.Action):
@@ -16,18 +15,13 @@ def __init__(self):
)

def run(self, params={}):
tag_parser = "(?i)<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>" # noqa: W605
doc = params.get(Input.DOC)
tags = re.findall(tag_parser, doc)
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
document = params.get(Input.DOC, "")
# END INPUT BINDING - DO NOT REMOVE

if not tags:
raise PluginException(cause="Invalid input.", assistance="Input must be of type HTML.")

try:
output = pypandoc.convert_text(doc, "html", format="md")
new_output = pypandoc.convert_text(output, "html5", format="md")
except RuntimeError as error:
raise PluginException(cause="Error converting doc file. ", assistance="Check stack trace log.", data=error)

file_ = base64.b64encode(new_output.encode("utf-8")).decode()
return {Output.HTML5_CONTENTS: output, Output.HTML5_FILE: file_}
converted_html = HTMLConverter(ConvertToHTML()).convert(document)
converted_html5 = HTMLConverter(ConvertToHTML5()).convert(converted_html)
return {
Output.HTML5_CONTENTS: converted_html,
Output.HTML5_FILE: encode_to_base64(converted_html5),
}
27 changes: 11 additions & 16 deletions plugins/html/icon_html/actions/markdown/action.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import insightconnect_plugin_runtime
import pypandoc
import base64
import re
from .schema import MarkdownInput, MarkdownOutput, Input, Output, Component
from insightconnect_plugin_runtime.exceptions import PluginException
from icon_html.util.api import HTMLConverter
from icon_html.util.strategies import ConvertToMarkdown
from icon_html.util.helpers import encode_to_base64


class Markdown(insightconnect_plugin_runtime.Action):
@@ -16,16 +15,12 @@ def __init__(self):
)

def run(self, params={}):
tag_parser = "(?i)<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>" # noqa: W605
doc = params.get(Input.DOC)
tags = re.findall(tag_parser, doc)
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
document = params.get(Input.DOC, "")
# END INPUT BINDING - DO NOT REMOVE

if not tags:
raise PluginException(cause="Invalid input.", assistance="Input must be of type HTML.")

try:
output = pypandoc.convert_text(doc, "md", format="html")
except RuntimeError as error:
raise PluginException(cause="Error converting doc file. ", assistance="Check stack trace log.", data=error)
file_ = base64.b64encode(output.encode("ascii")).decode()
return {Output.MARKDOWN_CONTENTS: output, Output.MARKDOWN_FILE: file_}
converted_markdown = HTMLConverter(ConvertToMarkdown()).convert(document)
return {
Output.MARKDOWN_CONTENTS: converted_markdown,
Output.MARKDOWN_FILE: encode_to_base64(converted_markdown),
}
25 changes: 6 additions & 19 deletions plugins/html/icon_html/actions/pdf/action.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import insightconnect_plugin_runtime
import base64

from insightconnect_plugin_runtime.exceptions import PluginException
import pypandoc
import re
from .schema import PdfInput, PdfOutput, Input, Output, Component
from icon_html.util.api import HTMLConverter
from icon_html.util.strategies import ConvertToPDF


class Pdf(insightconnect_plugin_runtime.Action):
@@ -14,18 +11,8 @@ def __init__(self):
)

def run(self, params={}):
temp_file = "temp_html_2_pdf.pdf"
tag_parser = "(?i)<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>" # noqa: W605
doc = params.get(Input.DOC)
tags = re.findall(tag_parser, doc)

if not tags:
raise PluginException(cause="Invalid input.", assistance="Input must be of type HTML.")
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
document = params.get(Input.DOC, "")
# END INPUT BINDING - DO NOT REMOVE

try:
pypandoc.convert_text(doc, "pdf", outputfile=temp_file, format="html")
except RuntimeError as error:
raise PluginException(cause="Error converting doc file. ", assistance="Check stack trace log.", data=error)
with open(temp_file, "rb") as output:
# Reading the output and sending it in base64
return {Output.PDF: base64.b64encode(output.read()).decode("utf-8")}
return {Output.PDF: HTMLConverter(ConvertToPDF()).convert(document)}
20 changes: 11 additions & 9 deletions plugins/html/icon_html/actions/text/action.py
Original file line number Diff line number Diff line change
@@ -12,14 +12,16 @@ def __init__(self):
)

def run(self, params={}):
in_text = params.get(Input.DOC)
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
document = params.get(Input.DOC, "")
remove_scripts = params.get(Input.REMOVE_SCRIPTS, False)
if in_text: # BeautifulSoup will bomb on null text
soup = BeautifulSoup(in_text, features="html.parser")
if remove_scripts:
for script in soup(["script", "style"]): # remove all javascript and stylesheet code
script.extract()
output = soup.get_text()
return {Output.TEXT: output}
else:
# END INPUT BINDING - DO NOT REMOVE

if not document:
return {Output.TEXT: ""}

soup = BeautifulSoup(document, features="html.parser")
if remove_scripts:
for script in soup(["script", "style"]): # remove all javascript and stylesheet code
script.extract()
return {Output.TEXT: soup.get_text()}
27 changes: 17 additions & 10 deletions plugins/html/icon_html/actions/validate/action.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import requests
from .schema import ValidateOutput, ValidateInput, Input, Output, Component
from insightconnect_plugin_runtime.exceptions import PluginException
from icon_html.util.constants import REQUESTS_TIMEOUT


class Validate(insightconnect_plugin_runtime.Action):
@@ -14,18 +15,24 @@ def __init__(self):
)

def run(self, params={}):
# Configure requests
# START INPUT BINDING - DO NOT REMOVE - ANY INPUTS BELOW WILL UPDATE WITH YOUR PLUGIN SPEC AFTER REGENERATION
html_contents = params.get(Input.HTML_CONTENTS, "").encode()
# END INPUT BINDING - DO NOT REMOVE

headers = {"Content-Type": "text/html; charset=utf-8"}
api_call = "https://validator.w3.org/nu/?out=json"
html_data = params.get(Input.HTML_CONTENTS).encode()
try:
response = requests.post(api_call, headers=headers, data=html_data, timeout=10)
msgs = response.json()["messages"]
if len(msgs) == 0:
response = requests.post(
"https://validator.w3.org/nu/?out=json",
headers={"Content-Type": "text/html; charset=utf-8"},
data=html_contents,
timeout=REQUESTS_TIMEOUT,
)
messages = response.json()["messages"]
if not messages:
self.logger.info("Run: No response from web service, can't determine validity")
return {Output.VALIDATED: False}
status = msgs[0]["type"]
status = messages[0]["type"]
return {Output.VALIDATED: (not status == "error")}
except requests.exceptions.RequestException:
return PluginException(cause="Error validating input. ", assistance="Please check logs.")
except requests.exceptions.RequestException as error:
raise PluginException(cause="Error validating input.", assistance="Please check logs.", data=error)
except Exception as error:
raise PluginException(preset=PluginException.Preset.UNKNOWN, data=error)
7 changes: 6 additions & 1 deletion plugins/html/icon_html/connection/connection.py
Original file line number Diff line number Diff line change
@@ -2,11 +2,16 @@
from .schema import ConnectionSchema

# Custom imports below
from typing import Dict, Any


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:
pass

@staticmethod
def test() -> Dict[str, Any]:
return {"success": True}
24 changes: 24 additions & 0 deletions plugins/html/icon_html/util/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import re

from icon_html.util.constants import HTML_TAG_PARSER
from icon_html.util.strategies import HTMLConverterStrategy
from insightconnect_plugin_runtime.exceptions import PluginException


class HTMLConverter:
"""HTMLConverter context"""

def __init__(self, strategy: HTMLConverterStrategy) -> None:
self._strategy = strategy

def convert(self, input_html_string: str) -> str:
self._validate_input_html(input_html_string)
try:
return self._strategy.convert(input_html_string)
except Exception as error:
raise PluginException(cause="Error converting doc file. ", assistance="Check stack trace log.", data=error)

@staticmethod
def _validate_input_html(input_html_string: str) -> None:
if not re.findall(HTML_TAG_PARSER, input_html_string):
raise PluginException(cause="Invalid input.", assistance="Input must be of type HTML.")
3 changes: 3 additions & 0 deletions plugins/html/icon_html/util/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REQUESTS_TIMEOUT = 10
DEFAULT_ENCODING = "utf-8"
HTML_TAG_PARSER = "(?i)<\/?\w+((\s+\w+(\s*=\s*(?:\".*?\"|'.*?'|[^'\">\s]+))?)+\s*|\s*)\/?>"
24 changes: 24 additions & 0 deletions plugins/html/icon_html/util/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import base64
from typing import Union

import pypandoc

from icon_html.util.constants import DEFAULT_ENCODING


def encode_to_base64(content: Union[str, bytes]) -> str:
if isinstance(content, str):
content = content.encode(DEFAULT_ENCODING)
return base64.b64encode(content).decode(DEFAULT_ENCODING)


def read_file_content(filename: str) -> str:
with open(filename, "rb") as file_:
return encode_to_base64(file_.read())


def convert_with_temporary_file(
input_html_string: str, to_format: str, from_format: str, temporary_filename: str, *args, **kwargs
) -> str:
pypandoc.convert_text(input_html_string, to_format, from_format, outputfile=temporary_filename, *args, **kwargs)
return read_file_content(temporary_filename)
Loading