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

PolicyError when trying to run formatchecker #56

Open
jowagner opened this issue May 25, 2023 · 0 comments
Open

PolicyError when trying to run formatchecker #56

jowagner opened this issue May 25, 2023 · 0 comments

Comments

@jowagner
Copy link

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 [email protected]: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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant