Skip to content

eclipse-score/inc_security_crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

19 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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]

πŸš€ 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/...
# linux ARM architecture
# check .bazelrc for available host (x86_64) and target (aarch64) configurations
bazel build //score/... --config=target_config_3

3️⃣ Run Tests

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

# host platform
bazel test //tests/...
# with detailed output and no caching
bazel test //tests/... --test_output=all --cache_test_results=no

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.


πŸ›  Tools & Linters

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

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

πŸ“– 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.

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

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages