
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
villain-pagination
Advanced tools
First of all, you need to install villain-pagination on your local to start.
pip install villain-pagination
Villain Paginator
uses SQLAlchemy ORM.
Let's start with a simple example below.
You need to import page
and paginator
function from villain-pagination
.
page
: is a class which used as response_model
in your route declaration.paginator
: is main functions that will paginate your data.To use paginate, 5 params required.
db
: is a SQLAlchemy session.model
: is a object which you want to paginate.order_by
: is a column of the model.page
: is a number of a page requested to show.size
: is a number of data which will shown in one page.And Here is an example.
from typing import Iterator, Any
from faker import Faker
from fastapi import Depends, FastAPI
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import Session, sessionmaker
from villain import page, paginator
engine = create_engine("sqlite:///.db", connect_args={"check_same_thread": False})
SessionLocal = sessionmaker(autocommit=True, autoflush=True, bind=engine)
Base = declarative_base(bind=engine)
fake = Faker()
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True, autoincrement=True)
name = Column(String, nullable=False)
Base.metadata.create_all()
app = FastAPI()
@app.on_event("startup")
def on_startup() -> None:
session = SessionLocal()
session.add_all([User(name=fake.name()) for _ in range(100)])
session.flush()
session.close()
def get_db() -> Iterator[Session]:
db = SessionLocal()
try:
yield db
finally:
db.close()
@app.get("/users/", response_model=page.Page)
def get_users(db: Session = Depends(get_db)) -> Any:
return paginator.paginate(db = db, model = User, order_by= User.id, page = 0, size = 10 )
FAQs
A small pagination package
We found that villain-pagination 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
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.