### Install libguestfs-tools on Debian/Ubuntu Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Installs the libguestfs-tools system package required for VM image extraction on Linux. ```bash sudo apt-get install libguestfs-tools ``` -------------------------------- ### Sample doc8 output Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Example output from running `make doc8`, showing various style errors and their counts. ```default Scanning... Validating... docs/source/misc/licence_policy_plugin.rst:37: D002 Trailing whitespace docs/source/misc/faq.rst:45: D003 Tabulation used for indentation docs/source/misc/faq.rst:9: D001 Line too long docs/source/misc/support.rst:6: D005 No newline at end of file ======== Total files scanned = 34 Total files ignored = 0 Total accumulated errors = 326 Detailed error counts: - CheckCarriageReturn = 0 - CheckIndentationNoTab = 75 - CheckMaxLineLength = 190 - CheckNewlineEndOfFile = 13 - CheckTrailingWhitespace = 47 - CheckValidity = 1 ``` -------------------------------- ### Install ExtractCode with full capabilities Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Use the 'full' extra option to install ExtractCode with bundled binaries for 7zip and libarchive. ```bash pip install extractcode[full] ``` -------------------------------- ### Install script requirements Source: https://github.com/aboutcode-org/extractcode/blob/main/etc/scripts/README.rst Install the tools' requirements into the current virtualenv. This is needed for non-requirement-generation usages. ```bash pip install --requirement etc/scripts/requirements.txt ``` -------------------------------- ### Install ExtractCode with minimal option Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Use the minimal option to install ExtractCode without bundled binaries, requiring system-provided libarchive and 7zip. ```bash pip install extractcode ``` -------------------------------- ### Generate main pip requirements file Source: https://github.com/aboutcode-org/extractcode/blob/main/etc/scripts/README.rst Run these commands to generate the main requirements file. Start with a clean configure, then run gen_requirements.py with the path to the site-packages directory. ```bash ./configure --clean ./configure python etc/scripts/gen_requirements.py --site-packages-dir ``` -------------------------------- ### Build HTML documentation locally Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Activates the virtual environment and builds the documentation with `make docs`. The output is placed in the `docs/_build` directory. ```default source venv/bin/activate make docs ``` -------------------------------- ### Set up development environment Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Run these commands to configure and activate the development environment for ExtractCode. ```bash ./configure --dev source venv/bin/activate ``` -------------------------------- ### Clone and configure repository for development Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Clones the repository and runs the configure script to set up the development environment. On Windows, use `configure --dev` instead. ```default git clone https://github.com/aboutcode-org/.git cd your-repo ./configure --dev ``` -------------------------------- ### Open built documentation Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Opens the built HTML documentation in the default browser. ```default open docs/_build/index.html ``` -------------------------------- ### Define a reST label for cross-referencing Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Shows how to create a reST label and reference it within the same documentation using the :ref: role. ```default .. _my-reference-label: Section to cross-reference -------------------------- This is the text of the section. It refers to the section itself, see :ref:`my-reference-label`. ``` -------------------------------- ### Run ExtractCode command line tool Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Displays help information for the ExtractCode command line tool. ```bash ./extractcode -h ``` -------------------------------- ### Validate documentation style and content Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Runs doc8 and docs-check to validate the documentation style and content. ```default source venv/bin/activate make doc8 make docs-check ``` -------------------------------- ### Configure Intersphinx in conf.py Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Adds the sphinx.ext.intersphinx extension and sets the intersphinx_mapping to link to the AboutCode documentation. ```default extensions = [ 'sphinx.ext.intersphinx' ] intersphinx_mapping = {'aboutcode': ('https://aboutcode.readthedocs.io/en/latest/', None)} ``` -------------------------------- ### List Intersphinx links with python -msphinx.ext.intersphinx Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Command to display all Intersphinx links and their targets from an objects.inv file. Note that using the URL without '/en/latest/' will cause an error. ```default python -msphinx.ext.intersphinx https://aboutcode.readthedocs.io/en/latest/objects.inv ``` -------------------------------- ### Generate development pip requirements file Source: https://github.com/aboutcode-org/extractcode/blob/main/etc/scripts/README.rst Run these commands to generate the development requirements file. This must be done after the main requirements are generated. ```bash ./configure --clean ./configure --dev python etc/scripts/gen_requirements_dev.py --site-packages-dir ``` -------------------------------- ### Reference an external label with the aboutcode prefix Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Shows how to link to a label in the AboutCode documentation using the 'aboutcode' prefix. ```default For more details refer :ref:`aboutcode:doc_style_guide`. ``` -------------------------------- ### List contents of zip-slip-win.zip with 7z l Source: https://github.com/aboutcode-org/extractcode/blob/main/tests/data/archive/zipslip/README.md Shows the output of `7z l zip-slip-win.zip`, listing a benign file (good.txt) and a malicious file with a Windows-style path traversal (..\..\...\Temp\evil.txt) that would extract outside the target directory. ```bash $ 7z l zip-slip-win.zip Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2018-04-15 22:04:29 ..... 19 19 good.txt 2018-04-15 22:04:42 ..... 20 20 ..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\..\Temp\evil.txt ------------------- ----- ------------ ------------ ------------------------ 2018-04-15 22:04:42 39 39 2 files ``` -------------------------------- ### Run doc8 style tests Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Runs the doc8 style checker on the documentation. ```default make doc8 ``` -------------------------------- ### Run local checks before pull request Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Runs doc8 and check-docs locally to ensure the documentation passes CI checks. ```default make doc8 make check-docs ``` -------------------------------- ### Reference an external label without the prefix Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Shows how to link to a label from the AboutCode documentation without using the 'aboutcode' prefix, which is possible if no local label with the same name exists. ```default For more details refer :ref:`doc_style_guide`. ``` -------------------------------- ### Run unit tests Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Executes the unit test suite with verbose output and parallel execution using two workers. ```bash pytest -vvs -n 2 ``` -------------------------------- ### List contents of zip-slip.zip with 7z l Source: https://github.com/aboutcode-org/extractcode/blob/main/tests/data/archive/zipslip/README.md Shows the output of `7z l zip-slip.zip`, listing a benign file (good.txt) and a malicious file with a Unix-style path traversal (../../.../tmp/evil.txt) that would extract outside the target directory. ```bash $ 7z l zip-slip.zip Date Time Attr Size Compressed Name ------------------- ----- ------------ ------------ ------------------------ 2018-04-15 22:04:29 ..... 19 19 good.txt 2018-04-15 22:04:42 ..... 20 20 ../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../../tmp/evil.txt ------------------- ----- ------------ ------------ ------------------------ 2018-04-15 22:04:42 39 39 2 files ``` -------------------------------- ### Clean up development environment Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Removes the development environment artifacts. ```bash ./configure --clean ``` -------------------------------- ### Create permanent kernel statoverride script Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Creates /etc/kernel/postinst.d/statoverride to permanently fix kernel permissions on Ubuntu. The script is devised by Kees Cook and ensures permissions are reapplied after each kernel update. ```bash #!/bin/sh version="$1" # passing the kernel version is required [ -z "${version}" ] && exit 0 dpkg-statoverride --update --add root root 0644 /boot/vmlinuz-${version} ``` -------------------------------- ### Set executable permissions on statoverride script Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Makes the permanent kernel statoverride script executable. ```bash sudo chmod +x /etc/kernel/postinst.d/statoverride ``` -------------------------------- ### Temporary kernel permission fix for Ubuntu Source: https://github.com/aboutcode-org/extractcode/blob/main/README.rst Temporarily changes permissions on kernel files so libguestfish can read them. This fix is needed on Ubuntu only and will be reverted on kernel updates. ```bash sudo chmod 0644 /boot/vmlinuz-* for k in /boot/vmlinuz-* do sudo dpkg-statoverride --add --update root root 0644 /boot/vmlinuz-$k done ``` -------------------------------- ### Correct and Incorrect Heading Underline Lengths Source: https://github.com/aboutcode-org/extractcode/blob/main/docs/source/contribute/contrib_doc.rst Shows the correct and incorrect usage of underline lengths for section headings. Underlines shorter than the title text generate errors on sphinx-build. ```default Correct : Extra Style Checks ------------------ Incorrect : Extra Style Checks ------------------------ ```