-
Notifications
You must be signed in to change notification settings - Fork 851
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: plug security issue partition system files via include (#3908)
#### Summary A recent security review showed that it was possible to partition arbitrary local files in cases where the filetype supports an "include" functionality that brings in the content of files external to the partitioned file. This affects `rst` and `org` files. #### Fix This PR fixes the above issue by passing the parameter `sandbox=True` in all cases where `pypandoc.convert_file` is called. Note I also added the parameter to a call to this method in the ODT code. I haven't investigated whether there was a security issue with ODT files, but it seems better to use pandoc in sandbox mode given the security issues we know about. #### Testing To verify that the tests that are added with this PR find the relevant issue: - Remove the `sandbox=True` text from `unstructured/file_utils/file_conversion.py` line 17. - Run the tests `test_unstructured.partition.test_rst.test_rst_wont_include_external_files` and `test_unstructured.partition.test_org.test_org_wont_include_external_files`. Both should fail due to the partitioning containing the word "wombat", which only appears in a file external to the partitioned file. - Add the parameter back in, and the tests pass.
- Loading branch information
Showing
10 changed files
with
114 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#+INCLUDE: "file_we_dont_want_imported" | ||
|
||
* Example Docs | ||
|
||
The sample docs directory contains the following files: | ||
|
||
- ~example-10k.html~ - A 10-K SEC filing in HTML format | ||
- ~layout-parser-paper.pdf~ - A PDF copy of the layout parser paper | ||
- ~factbook.xml~ / ~factbook.xsl~ - Example XML/XLS files that you | ||
can use to test stylesheets | ||
|
||
These documents can be used to test out the parsers in the library. In | ||
addition, here are instructions for pulling in some sample docs that are | ||
too big to store in the repo. | ||
|
||
** XBRL 10-K | ||
|
||
You can get an example 10-K in inline XBRL format using the following | ||
~curl~. Note, you need to have the user agent set in the header or the | ||
SEC site will reject your request. | ||
|
||
#+BEGIN_SRC bash | ||
|
||
curl -O \ | ||
-A '${organization} ${email}' | ||
https://www.sec.gov/Archives/edgar/data/311094/000117184321001344/0001171843-21-001344.txt | ||
#+END_SRC | ||
|
||
You can parse this document using the HTML parser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.. include:: file_we_dont_want_imported | ||
|
||
Example Docs | ||
------------ | ||
|
||
The sample docs directory contains the following files: | ||
|
||
- ``example-10k.html`` - A 10-K SEC filing in HTML format | ||
- ``layout-parser-paper.pdf`` - A PDF copy of the layout parser paper | ||
- ``factbook.xml``/``factbook.xsl`` - Example XML/XLS files that you | ||
can use to test stylesheets | ||
|
||
These documents can be used to test out the parsers in the library. In | ||
addition, here are instructions for pulling in some sample docs that are | ||
too big to store in the repo. | ||
|
||
XBRL 10-K | ||
^^^^^^^^^ | ||
|
||
You can get an example 10-K in inline XBRL format using the following | ||
``curl``. Note, you need to have the user agent set in the header or the | ||
SEC site will reject your request. | ||
|
||
.. code:: bash | ||
curl -O \ | ||
-A '${organization} ${email}' | ||
https://www.sec.gov/Archives/edgar/data/311094/000117184321001344/0001171843-21-001344.txt | ||
You can parse this document using the HTML parser. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
wombat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.16.19" # pragma: no cover | ||
__version__ = "0.16.20" # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters