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

New IMPORT_FORMATS setting does not prevent POST of incorrect type #1617

Closed
matthewhegarty opened this issue Sep 9, 2023 · 1 comment
Closed
Labels

Comments

@matthewhegarty
Copy link
Contributor

matthewhegarty commented Sep 9, 2023

Describe the bug

In PR #1606 we now have the ability to limit which formats can be imported. However this is a front end constraint only and you can still POST an undefined format.

To Reproduce

The test in the attached patch proves the issue. IMPORT_FORMATS are limited to 'csv' but you can POST a tsv. This format does not get processed correctly (fails with errors), however processing should not be allowed at all, otherwise it is a potential security issue.

Versions (please complete the following information):

  • Django Import Export: dev
  • Python 3.11
  • Django 4.2

Expected behavior
I would expect to see an error message stating that the tsv format is not allowed.

Additional context

Apply attached patch with git apply post-incorrect-type.txt

post-incorrect-type.txt

use the attached books.txt
(but rename to books.tsv and put in tests/core/exports)

These changes are in a branch here

@matthewhegarty
Copy link
Contributor Author

Going to close this... I don't think it is an issue.
I loaded the import page, then set IMPORT_EXPORT_FORMATS=[base_formats.CSV]
Then I tried to import an xlsx file and I got this error message, so I am confident it is working ok.

image

The test I added proves that you can send any file despite the format (i.e. you can send a tsv file with 'csv' format defined) but there is no reliable way to restrict that, and parsing fails with an error message as expected.

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

No branches or pull requests

1 participant