
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
django-randomcharfield
Advanced tools
This is a custom Django model field written as an alternative to UUIDs.
It works by base64-encoding 20 bytes (160 bits) from urandom
, as recommended by Neil Madden's fantastic blog post, "Moving away from UUIDs"
Use any package manager of choice. If using pip, install with this command:
pip install django-randomcharfield
Add this to your model definition as follows:
from django.db import models
from randomcharfield import (
RandomCharField, generate_random_field,
)
class SomeModel(models.Model):
uid = RandomCharField(default=generate_random_field)
Note that this doesn't make any assumptions about your current database state. That means you are responsible for creating the database index for this field, adding a uniqueness constraint, or making it a primary key.
If you have existing rows in your table and want to add a uniqueness constraint, you may want to set this field as nullable (i.e. passing in null=True
) and to devise a plan to populate this. A good guide for such a plan is one written in the official Django documentation to deal with the same situation for UUIDField
: https://docs.djangoproject.com/en/3.0/howto/writing-migrations/#migrations-that-add-unique-fields
This isn't a lot of code, so you should probably be just copying the field to your project if you want customisations, rather than proposing changes.
MIT
FAQs
An alternative to UUIDs for model fields
We found that django-randomcharfield demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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 flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.