Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
django-safe-filefield
Advanced tools
Secure file field, which allows you to restrict uploaded file extensions.
.. image:: https://github.com/mixkorshun/django-safe-filefield/actions/workflows/flake8.yml/badge.svg?branch=master :alt: flake8 :target: https://github.com/mixkorshun/django-safe-filefield .. image:: https://github.com/mixkorshun/django-safe-filefield/actions/workflows/pytest.yml/badge.svg?branch=master :alt: pytest :target: https://github.com/mixkorshun/django-safe-filefield .. image:: https://badge.fury.io/py/django-safe-filefield.svg :alt: pypi :target: https://pypi.python.org/pypi/django-safe-filefield .. image:: https://img.shields.io/badge/code%20style-pep8-orange.svg :alt: pep8 :target: https://www.python.org/dev/peps/pep-0008/ .. image:: https://img.shields.io/badge/License-MIT-yellow.svg :alt: MIT :target: https://opensource.org/licenses/MIT
Secure file field, which allows you to restrict uploaded file extensions. It may be useful for user-uploaded files (attachments).
This package adds model and forms field. What this fields does:
libmagic
)The package can be installed using:
.. code-block::
pip install django-safe-filefield
Add the following settings:
.. code-block:: python
INSTALLED_APPS += [ 'safe_filefield', ]
django-safe-filefield requires libmagic
to be installed.
Simply add field to your model:
.. code-block:: python
from safe_filefield.models import SafeFileField
class MyModel(models.Model):
attachment = SafeFileField(
allowed_extensions=('xls', 'xlsx', 'csv')
)
Or directly to your form:
.. code-block:: python
from safe_filefield.forms import SafeFileField
class MyForm(forms.Form):
attachment = SafeFileField(
allowed_extensions=('xls', 'xlsx', 'csv')
)
Content type checking +++++++++++++++++++++
To check actual file content type, use check_content_type
argument. This
will prevent attacker from uploading malicious file just by changing its
extension.
.. code-block:: python
class MyForm(forms.Form): attachment = SafeFileField( check_content_type=True )
ClamAV support ++++++++++++++
.. note:: To use this functionality you should have clamd
daemon.
This package has ability to check uploaded file with ClamAV antivirus.
To use anti-virus protection simply enable it in your form or model definition:
.. code-block:: python
from safe_filefield.forms import SafeFileField
class MyForm(forms.Form): attachment = SafeFileField( scan_viruses=True, )
You can configure some ClamAV settings:
.. code-block:: python
CLAMAV_SOCKET = 'unix://tmp/clamav.sock' # or tcp://127.0.0.1:3310
CLAMAV_TIMEOUT = 30 # 30 seconds timeout, None by default which means infinite
If you have any valuable contribution, suggestion or idea, please let me know as well because I will look into it.
Pull requests are welcome.
FAQs
Secure file field, which allows you to restrict uploaded file extensions.
We found that django-safe-filefield demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.