Thank you for your interest in contributing to CloakDB.
-
Clone the repository and set up a virtual environment:
git clone https://github.com/latryee/CloakDB.git cd CloakDB python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install development dependencies:
pip install --upgrade pip pip install -e ".[dev]"
All pull requests must pass the automated test suite, linting, formatting, and type checks.
pytest --cov=cloakdb --cov-report=term-missingWe use Ruff for linting and code formatting:
# Check linting
ruff check .
# Auto-fix lint issues
ruff check --fix .
# Check formatting
ruff format --check .
# Auto-format code
ruff format .We use Mypy for static type checking:
mypy srcRun all checks in one command:
ruff check . && ruff format --check . && mypy src && pytest- Create or open the relevant module in
src/cloakdb/strategies/(e.g.,general.py,numeric.py,redaction.py). - Subclass
MaskingStrategyfromcloakdb.strategies.base. - Implement the
transform(self, value, context, **params)method. - Register the strategy using
@register_strategy("<name>", aliases=["<alias1>"]). - Add comprehensive unit tests in
tests/test_strategies.py.
Example:
from typing import Any
from cloakdb.core.context import TransformationContext
from cloakdb.strategies.base import MaskingStrategy
from cloakdb.strategies.registry import register_strategy
@register_strategy("custom_prefix", aliases=["prefix"])
class CustomPrefixStrategy(MaskingStrategy):
description = "Prepends a fixed prefix to string values"
def transform(
self,
value: Any,
context: TransformationContext,
*,
prefix: str = "MASKED_",
**kwargs: Any,
) -> Any:
if value is None:
return None
return f"{prefix}{value}"- Keep changes focused and minimal. Avoid large refactors or unnecessary dependencies.
- Ensure new features and bug fixes include automated tests.
- Keep documentation up to date.