tessera contributor guide
此内容尚不支持你的语言。
This document is a guide for a developer who is opening the repository for the first time and wants to make a change. The goal: a working environment, passing tests, and a first PR in a single day.
1. Local build
Section titled “1. Local build”1.1 System dependencies
Section titled “1.1 System dependencies”Astra Linux SE / Ubuntu 22.04 / Debian 12:
sudo apt install -y \ build-essential pkg-config \ libssl-dev libudev-dev libdbus-1-dev libpam0g-dev libsystemd-dev \ softhsm2 opensc opensc-pkcs11 \ pamtester clangThe Rust toolchain is pinned in rust-toolchain.toml.
If rustup is present, the toolchain is downloaded automatically:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shrustup show # picks the version from rust-toolchain.toml1.2 Build
Section titled “1.2 Build”cargo build --workspacecargo build --workspace --release1.3 Cargo features
Section titled “1.3 Cargo features”- Default: no special features.
tessera_core/pkcs11-tests— enables the integration tests that require a realgost-engineor softhsm2. The recipe for running them with softhsm2 token initialization is in §2.2.
2. Tests
Section titled “2. Tests”2.1 Unit and ordinary integration tests
Section titled “2.1 Unit and ordinary integration tests”cargo test --workspaceAll unit and integration tests must pass.
2.2 Integration tests with softhsm2
Section titled “2.2 Integration tests with softhsm2”sudo apt install softhsm2 opensc-pkcs11softhsm2-util --init-token --slot 0 \ --label test --pin 1234 --so-pin 5678SOFTHSM2_CONF=/etc/softhsm/softhsm2.conf \ cargo test --workspace --features tessera_core/pkcs11-testsThe PKCS#11 tests add an extra set of integration checks (module loading,
certificate lookup, the CKA_EXTRACTABLE check).
2.3 Smoke test with pamtester
Section titled “2.3 Smoke test with pamtester”Requires Linux + root + an installed tessera:
# In a separate Astra SE 1.8 VM:sudo apt install ./target/release/tessera_0.4.0-1_amd64.debsudo /usr/share/tessera/integrate-pam.sh --mode=2fa /etc/pam.d/sudopamtester sudo alice authenticate3. Pre-commit hooks
Section titled “3. Pre-commit hooks”A .pre-commit-config.yaml is shipped at the
root of the repository. To install:
pip install pre-commitpre-commit installWhat is checked on commit:
cargo fmt --all -- --check;cargo clippy --workspace --all-targets -- -D warnings;cargo deny check;cargo test --workspace;- the syntax of bash scripts (
bash -n); - the
Cargo.tomlversion matchingdebian/changelog; - the absence of MAX_INTEGRITY OID placeholders in tracked files.
If you do not have the pre-commit framework, you can run the commands
manually:
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspace4. Commit style
Section titled “4. Commit style”The format is Conventional Commits:
<type>(<scope>): <subject>
<body>
<footer>Commit messages are in English. Examples:
feat(monitord): handle suspend/resume via D-Busfix(core): correct CRL freshness check for mode = "crl"docs(install): add Mode A scenario with FAT32 mediachore: bump serde to 1.0.xrefactor(proto): rename Pong to HelloAck for consistencytest(monitord): add suspend_grace e2e test
<scope> corresponds to the crate or module: monitord, core, proto,
pam, install, arch, security, release, dev.
5. PR workflow
Section titled “5. PR workflow”-
Branch off
main:Terminal window git checkout -b feat/awesome-feature main -
Atomic commits: one logically coherent commit at a time. A PR usually contains 1–5 commits.
-
Automatic CI runs: GitHub Actions:
.github/workflows/build.yml— tests (ubuntu:cargo test, astra container:cargo nextest run), building the.debin both variants,lintian(the ubuntu leg);.github/workflows/lint.yml—cargo clippy -D warningsand supply-chain (cargo deny,cargo audit);.github/workflows/nightly.yml— a daily run of the tests in the release profile.cargo fmt --checkruns in the pre-commit hook, not in CI.
-
Code review checklist:
- is there a test for the new functionality?
- are the relevant docs updated (configuration, architecture, threat-model)?
- has a new TOML field appeared without documentation?
- does the change violate the fail-closed invariants (see architecture.md §13)?
- is the reproducible build still intact?
-
Merge via squash + rebase merge. Large PRs — reviewed in batches of 3–5 commits; squashed into
mainfor a clean history.
6. Git hooks
Section titled “6. Git hooks”The repo ships hooks in scripts/git-hooks/ that block commits and pushes to
main on weekdays between 08:00 and 19:00 local time. Enable them once per
clone:
git config core.hooksPath scripts/git-hooksgit commit --no-verify / git push --no-verify override in emergencies.
7. How to add a new PKCS#11 provider
Section titled “7. How to add a new PKCS#11 provider”The current support is implemented in
crates/tessera_core/src/token/.
Steps:
- Study the interfaces (
PkcsModule,Session,Slot). - Implement a new adapter in a submodule (for example,
token/newvendor/). - Register it via
crypto_backend = "pkcs11_native"withpkcs11_module = "/usr/lib/libnewvendor.so". - Add tests:
- positive: module loading + certificate lookup;
- negative: the module did not load (a nonexistent path);
- non-extractable: the
CKA_EXTRACTABLE = falsecheck.
- Update the documentation:
- README.md — the “Supported tokens” section;
- docs/install.md — the driver installation section;
- docs/configuration.md — the modules table;
- docs/threat-model.md — §3.3 (if the threat model changes).
8. How to add a new host_id source
Section titled “8. How to add a new host_id source”See crates/tessera_core/src/host_identity/.
Steps:
- Create a
<source>.rsmodule implementing theHostIdSourcetrait. - Register it in
chain.rs(HostIdentityResolver::from_validated). - Add it to
RawHostIdentity::sources(name validation). - Add it to
HostIdSourceKind(the associated enum). - Tests:
- positive: the source returns a value;
- negative: the source is unavailable → the next in the chain fires.
- Update docs/configuration.md (the
[host_identity]table) and architecture.md §12.
8.1 Where the certificate authorization logic lives
Section titled “8.1 Where the certificate authorization logic lives”The authorization of “which user on which host” is fully described in the certificate itself through X.509 extensions and is verified in code:
crates/tessera_core/src/x509/host_binding_ext.rs— parsing of thepam_cert_host_bindingextension (the OID and ASN.1 structure are inx509/oids.rs).crates/tessera_core/src/x509/allowed_roles_ext.rs— parsing of thepam_cert_allowed_rolesextension.verify_cert_scope— the final matching of the parsed entries againsthost_id_hashand the requested role, which is alsopam_user. See also docs/cert-issuance.md for the semantics of the entries.
9. Versioning
Section titled “9. Versioning”SemVer 2.0.0 semantics:
- MAJOR — breaking changes (incompatible changes to the
config.tomlschema, the IPC protocol, removed configuration options). - MINOR — backward-compatible new functionality (a new PKCS#11 provider, a new host_id source, a new stage in hooks).
- PATCH — bug fixes, doc updates, dependency updates without an API change.
Each MAJOR release requires:
- a migration note in docs/changelog.md (Russian);
- an update of
PROTOCOL_VERSIONincrates/tessera_proto/src/version.rs(if the wire protocol changes); - an update of the threat model (docs/threat-model.md).