Skip to content

Commit 2cf8117

Browse files
PDF Reader - Addressed snyk vulnerability (#3655)
* PDF Reader - Addressed snyk vulnerability * Update requirements.txt * Update requirements.txt * Update requirements.txt * updated version history * Bumping SDK to the latest version
1 parent a7a5dfb commit 2cf8117

File tree

14 files changed

+65
-42
lines changed

14 files changed

+65
-42
lines changed

plugins/pdf_reader/.CHECKSUM

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
2-
"spec": "6707025dd71169a10c0706a231ec7776",
3-
"manifest": "f5c84efadfe43ca2b0dadc3b529f45f4",
4-
"setup": "fee7b2e1a9cb71901995eb67a195d7eb",
2+
"spec": "4a73afeeb3f51a38671eb7c25941b8c9",
3+
"manifest": "db2aed4fc1a423a31f969d0ca0158e76",
4+
"setup": "9e2ee9d110e8ed975296579b81f5d548",
55
"schemas": [
66
{
77
"identifier": "extract_text/schema.py",
8-
"hash": "35e1f75bab710442b0852a659f2a3a55"
8+
"hash": "e9e14996e00954b0d1cbddaf98d9684f"
99
},
1010
{
1111
"identifier": "connection/schema.py",
12-
"hash": "bd524b567f9638ba1c6f7e0c9e45ff2e"
12+
"hash": "2a983a9b7aa5dd290ed28e0eb7e0c9c6"
1313
}
1414
]
1515
}

plugins/pdf_reader/Dockerfile

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,34 @@
1-
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-plugin:6.1.4
1+
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-plugin:6.4.1 AS builder
2+
3+
WORKDIR /python/src
4+
5+
ADD ./plugin.spec.yaml /plugin.spec.yaml
6+
ADD ./requirements.txt /python/src/requirements.txt
7+
ADD . /python/src
8+
9+
10+
11+
RUN pip install .
12+
RUN pip uninstall -y setuptools
13+
14+
FROM --platform=linux/amd64 rapid7/insightconnect-python-3-plugin:6.4.1
215

316
LABEL organization=rapid7
417
LABEL sdk=python
518

619
WORKDIR /python/src
720

8-
ADD ./plugin.spec.yaml /plugin.spec.yaml
9-
ADD ./requirements.txt /python/src/requirements.txt
21+
COPY --from=builder /python/src /python/src
22+
COPY --from=builder /plugin.spec.yaml /plugin.spec.yaml
23+
1024

1125
RUN if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
1226

13-
ADD . /python/src
27+
ENV PYTHONPATH="/python/src:${PYTHONPATH}"
1428

15-
RUN python setup.py build && python setup.py install
29+
RUN rm -rf /root/.cache;
1630

1731
# User to run plugin code. The two supported users are: root, nobody
1832
USER nobody
1933

20-
ENTRYPOINT ["/usr/local/bin/komand_pdf_reader"]
34+
ENTRYPOINT ["python", "/python/src/bin/komand_pdf_reader"]

plugins/pdf_reader/bin/komand_pdf_reader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from sys import argv
66

77
Name = "PDF Reader"
88
Vendor = "rapid7"
9-
Version = "1.0.4"
9+
Version = "1.0.5"
1010
Description = "PDF Reader is a plugin for extracting text from a PDF file. This plugin utilizes a Python package called [pdfplumber](https://pypi.org/project/pdfplumber/)"
1111

1212

plugins/pdf_reader/help.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# Description
22

3-
PDF Reader is a plugin for extracting text from a PDF file.
4-
5-
This plugin utilizes a Python package called [pdfplumber](https://pypi.org/project/pdfplumber/)
3+
PDF Reader is a plugin for extracting text from a PDF file. This plugin utilizes a Python package called [pdfplumber](https://pypi.org/project/pdfplumber/)
64

75
# Key Features
86

@@ -75,6 +73,7 @@ Example output:
7573

7674
# Version History
7775

76+
* 1.0.5 - Updated dependencies | Updated SDK to the latest version (6.4.1)
7877
* 1.0.4 - Bumping requirements.txt | SDK Bump
7978
* 1.0.3 - Updated version of Pillow used. Updated to use latest SDK and refreshed with latest tooling.
8079
* 1.0.2 - Fix extracting text from PDF in Extract Text action | Update to use the `insightconnect-python-3-38-plugin:4` Docker image | Code refactor | Add input example in plugin spec and help.md
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
22

33
from .extract_text.action import ExtractText
4-

plugins/pdf_reader/komand_pdf_reader/actions/extract_text/action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Custom imports below
55
from insightconnect_plugin_runtime.exceptions import PluginException
66
import pdfplumber
7-
from pdfminer.pdfparser import PDFSyntaxError
7+
from pdfplumber.utils.exceptions import PdfminerException
88
import base64
99
import io
1010

@@ -29,7 +29,7 @@ def run(self, params={}):
2929
pdf_text += page[1].extract_text().replace("\n", " ")
3030
finally:
3131
pdf_file.close()
32-
except PDFSyntaxError:
32+
except PdfminerException:
3333
raise PluginException(
3434
cause="The provided content is not in PDF file format.",
3535
assistance="Please check that the input is correct and try again.",

plugins/pdf_reader/komand_pdf_reader/actions/extract_text/schema.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class Output:
1616

1717

1818
class ExtractTextInput(insightconnect_plugin_runtime.Input):
19-
schema = json.loads(r"""
19+
schema = json.loads(
20+
r"""
2021
{
2122
"type": "object",
2223
"title": "Variables",
@@ -35,14 +36,16 @@ class ExtractTextInput(insightconnect_plugin_runtime.Input):
3536
],
3637
"definitions": {}
3738
}
38-
""")
39+
"""
40+
)
3941

4042
def __init__(self):
4143
super(self.__class__, self).__init__(self.schema)
4244

4345

4446
class ExtractTextOutput(insightconnect_plugin_runtime.Output):
45-
schema = json.loads(r"""
47+
schema = json.loads(
48+
r"""
4649
{
4750
"type": "object",
4851
"title": "Variables",
@@ -56,7 +59,8 @@ class ExtractTextOutput(insightconnect_plugin_runtime.Output):
5659
},
5760
"definitions": {}
5861
}
59-
""")
62+
"""
63+
)
6064

6165
def __init__(self):
6266
super(self.__class__, self).__init__(self.schema)

plugins/pdf_reader/komand_pdf_reader/connection/schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ class Input:
88

99

1010
class ConnectionSchema(insightconnect_plugin_runtime.Input):
11-
schema = json.loads(r"""
11+
schema = json.loads(
12+
r"""
1213
{}
13-
""")
14+
"""
15+
)
1416

1517
def __init__(self):
1618
super(self.__class__, self).__init__(self.schema)
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
2-
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
2-

0 commit comments

Comments
 (0)