Skip to content

Latest commit

 

History

72 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++ & Rust Bazel Template Repository

This repository serves as a template for setting up C++ and Rust projects using Bazel. It provides a standardized project structure, ensuring best practices for:

  • Build configuration with Bazel.
  • Testing (unit and integration tests).
  • Documentation setup.
  • CI/CD workflows.
  • Development environment configuration.

📂 Project Structure

File/Folder Description
README.md Short description & build instructions
score/ Crypto component
tests/ Unit tests (UT) and integration tests (IT)
examples/ Example files used for guidance
third_party/ Build file for external dependencies (e.g. gRPC)
docs/ Documentation (Doxygen for C++ / mdBook for Rust)
.vscode/ Recommended VS Code settings
.bazelrc, MODULE.bazel, BUILD Bazel configuration & settings
project_config.bzl Project-specific metadata for Bazel macros

Score Folder Layout

score/                            ← Source code  ◄ main
├── mw/crypto/
│   └── api/                      ← [LIBRARY]
│       ├── common/
│       ├── config/               ← API config
│       ├── contexts/             ← Crypto contexts
│       ├── objects/              ← Key/cert objects
│       └── src/                  ← Entry point
│
├── crypto/
│   ├── api/
│   │   └── control_plane/        ← [LIB CTRL-PLANE]
│   │
│   ├── ipc/
│   │   └── grpc_adapter/         ← [IPC — gRPC]
│   │
│   └── daemon/
│       ├── control_plane/        ← [DAEMON CTRL-PLANE]
│       ├── mediator/             ← [MEDIATOR]
│       ├── data_manager/         ← [DATA MANAGER]
│       ├── key_management/       ← [KEY MANAGEMENT]
│       ├── config/               ← [CONFIG]
│       └── provider/
│           ├── score_provider/   ← [SW PROVIDER / OpenSSL]
│           └── pkcs11/           ← [HW PROVIDER / PKCS#11]
│
└── cryptoki/                     ← [HW SECURE PROVIDER / PKCS#11 Rust Library]  ◄ Peer Package

🚀 Getting Started

1️⃣ Clone the Repository

git clone https://github.com/eclipse-score/YOUR_PROJECT.git
cd YOUR_PROJECT

2️⃣ Build the Examples of module

DISCLAIMER: Depending what module implements, it's possible that different configuration flags needs to be set on command line.

To build all targets of the module the following command can be used:

# host platform
bazel build //score/...
# qnx arm architecture
# check .bazelrc for available host (x86_64) and target (aarch64) configurations
bazel build //score/... --config=aarch64-qnx

3️⃣ Run Tests

# pre-requisite: pull ubuntu docker image within devcontainer (once)
docker pull ubuntu:24.04

# host platform
bazel test //score/...
# with detailed output and no caching
bazel test //score/... --test_output=all --cache_test_results=no
# single integration test (via pytest -k option)
bazel test //score/tests/integration_tests:integration_test --test_arg="-k" --test_arg="test_score_api_hash" --test_output=all

# cc_test and rust_test for x86_64-qnx target
bazel test //score/... --config=x86_64-qnx
# itf based integration test for x86_64-qnx target
bazel test //score/... --config=x86_64-qnx-itf

Note: Run the docker pull command from a VS Code Terminal associated with the devcontainer. This properly sets up all environment variables, which may not be the case when just using docker to attach to the running container.

4️⃣ Generate Coverage

Run the LLVM coverage tests and generate the HTML report locally:

bazel coverage --config=llvm_cov --build_tests_only -- //score/...

COVERAGE_THRESHOLD=0 bazel run @score_tooling//coverage:generate_coverage_html -- \
    --yaml tools/coverage/coverage_justifications.yaml \
    --testlogs-subdir score \
    --archive-dir coverage_artifact

🛠 Tools & Linters

The template integrates tools and linters from centralized repositories to ensure consistency across projects.

  • C++: clang-tidy, cppcheck, Google Test
  • Python: ruff
  • Rust: clippy, rustfmt, Rust Unit Tests
  • CI/CD: GitHub Actions for automated builds and tests

Generate the Bazel-managed .venv_test environment with bazel run //:venv and use .venv_test/bin/python as the VS Code Python interpreter.


📖 Documentation

  • A centralized docs structure is planned.
bazel run //:docs

⚙️ project_config.bzl

This file defines project-specific metadata used by Bazel macros, such as dash_license_checker.

📌 Purpose

It provides structured configuration that helps determine behavior such as:

  • Source language type (used to determine license check file format)
  • Safety level or other compliance info (e.g. ASIL level)

📄 Example Content

PROJECT_CONFIG = {
    "asil_level": "QM",  # or "ASIL-A", "ASIL-B", etc.
    "source_code": ["cpp", "rust"]  # Languages used in the module
}

🔧 Use Case

When used with macros like dash_license_checker, it allows dynamic selection of file types (e.g., cargo, requirements) based on the languages declared in source_code.

DevContainer Setup

Known Issue: Pre-commit Hook Not Running

Problem: The pre-commit hook does not run when using git commit inside the DevContainer.

Cause: A stale core.hooksPath configuration overrides the default hook lookup path.

Fix: Unset the custom hooks path:

git config --unset core.hooksPath

Note: For a permanent fix, run this command on the host machine (outside the DevContainer). The DevContainer only receives a copy of the host's Git configuration at build time, so changes made inside the container will not persist after a rebuild.


Valeo S-CORE Crypto Module

This is the main eclipse-score repository of the security-crypto module.

Supported Providers

This repository supports multiple interchangeable cryptographic backends:

  • SoftHSM (C++ Default): The default fallback emulator.
  • Valeo Cryptoki (Rust Backend): S-CORE's high-security Rust-based PKCS#11 provider. For complete compilation, running, and troubleshooting manuals, please refer directly to the Valeo Cryptoki Integration Guide.

Use of genAI in this repository

The repository partially contains AI-generated code by using GitHub Copilot Business. This notice needs to remain attached to any reproduction of this repository.

About

Incubation repository for Security & Cryptography feature

Resources

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages