+
Skip to content

PolicyError when trying to run formatchecker #56

Open
@jowagner

Description

@jowagner

I installed into a fresh Python environment on openSUSE Leap 15.4:

virtualenv -p /usr/bin/python3.9 venv-acl
source venv-acl/bin/activate
git clone git@github.com:acl-org/aclpubcheck.git
cd aclpubcheck/
pip install -e .

and get the following error when trying to run the formatchecker on my PDF:

cp -dpi ~/Downloads/absa-camera-ready-2023-05-25-T-1701.pdf ./
$ python3 aclpubcheck/formatchecker.py --paper_type long absa-camera-ready-2023-05-25-T-1701.pdf            
Checking absa-camera-ready-2023-05-25-T-1701.pdf
Traceback (most recent call last):
  File "/redacted/aclpubcheck/aclpubcheck/formatchecker.py", line 495, in <module>
    main()
  File "/redacted/aclpubcheck/aclpubcheck/formatchecker.py", line 492, in main
    worker(submission, args.paper_type)
  File "/redacted/aclpubcheck/aclpubcheck/formatchecker.py", line 455, in worker
    return Formatter().format_check(submission=pdf_path, paper_type=paper_type)
  File "/redacted/aclpubcheck/aclpubcheck/formatchecker.py", line 80, in format_check
    self.check_page_margin(output_dir)
  File "/redacted/aclpubcheck/aclpubcheck/formatchecker.py", line 284, in check_page_margin
    im = self.pdf.pages[page].to_image(resolution=150)
  File "/redacted/venv-acl/lib/python3.9/site-packages/pdfplumber/page.py", line 431, in to_image
    return PageImage(self, resolution=resolution or DEFAULT_RESOLUTION)
  File "/redacted/venv-acl/lib/python3.9/site-packages/pdfplumber/display.py", line 95, in __init__
    self.original = get_page_image(
  File "/redacted/venv-acl/lib/python3.9/site-packages/pdfplumber/display.py", line 56, in get_page_image
    with WandImage(
  File "/redacted/venv-acl/lib/python3.9/site-packages/wand/image.py", line 9365, in __init__
    self.read(filename=filename)
  File "/redacted/venv-acl/lib/python3.9/site-packages/wand/image.py", line 10120, in read
    self.raise_exception()
  File "/redacted/venv-acl/lib/python3.9/site-packages/wand/resource.py", line 225, in raise_exception
    raise e
wand.exceptions.PolicyError: attempt to perform an operation not allowed by the security policy `PDF' @ error/constitute.c/IsCoderAuthorized/422

Following https://stackoverflow.com/questions/52998331/imagemagick-security-policy-pdf-blocking-conversion,
adding the line

<policy domain="coder" rights="read | write" pattern="PDF" />

to /etc/ImageMagick-7/policy.xml before the last line </policymap> allows the formatchecker to complete its task. Assuming the functionality has been deactivated due to a security-related bug, it will be best to only make this modification while no other users can access the system, no automatic processing of PDFs is active (indexers, email scanners etc.) and to restore the safe setting immediately.

Hope this helps other users running into this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载