
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).
typid
is a python library that allows to create specific id types much like
stripe uses them across their platform to distinguish different data models from
their id already. typeid
is compatible to the UUID library and as such can act
as a drop-in replacement.
A type id has the following string representation:
user_nnv5rr3rfk3hgry6xrygr
└──┘ └───────────────────┘
type uuid (base58)
typeid
First generate the Types using generate(...), then use them like so:
from uuid_extensions import uuid7
from typeid import generate
typeids = generate("sk", "pk", "user", "apikey")
# Now they can be used with SkId, PkId, UserId, and ApikeyId
assert str(typeids.SkId(uuid7().hex)).startswith("sk_")
assert str(typeids.PkId(uuid7().hex)).startswith("pk_")
assert str(typeids.UserId(uuid7().hex)).startswith("user_")
assert str(typeids.ApikeyId(uuid7().hex)).startswith("apikey_")
# Obviously, loading a prefixed type id in the correct Type works just fine
assert (typeids.UserId("user_nnv5rr3rfk3hgry6xrygr").hex == "0664c4135ed83faabd4bc0dc33839c9f")
# Use custom suffixes, just in case you need them
other_ids.generate("admin", suffix="IdUseWithCare")
assert str(other_ids.AdminIdUseWithCare(uuid7().hex)).startswith("admin_")
The library also allows to create classes specifically for the use with sqlalchemy.
from typeid import generate
typeids = generate("user")
class User(Base):
__tablename__ = "user"
# use typeids.UserId in the Mapper[]
id: Mapped[typeids.UserId] = mapped_column(
# use typeids.UserId in the mapped_column!
typeids.UserId, primary_key=True, default=uuid.uuid4
)
name: str = Column(String(128), unique=True)
user = User(name="John Doe")
(db,) = get_session()
db.add(user)
db.commit()
db.refresh(user)
print(type(user.id))
# <class 'typeid.UserId'>
print((user.id))
# user_qvnrsem3skqho2hgni2mfk
FAQs
UUID-compatible Typed IDs with prefixes
We found that typeid 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.