Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

- name: Install mockgen
run: go install github.com/golang/mock/mockgen@v1.6.0
run: go install go.uber.org/mock/mockgen@latest

- name: Generate protobufs and ratsd server
run: go generate ./...
Expand Down
119 changes: 113 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,73 @@
# Copyright 2025 Contributors to the Veraison project.
# SPDX-License-Identifier: Apache-2.0

.DEFAULT_TARGET: all
.DEFAULT_GOAL := all
BIN := ratsd

.PHONY: help
help:
@echo "RATSD Makefile Commands:"
@echo ""
@echo "Building:"
@echo " all Build everything (check deps, generate code, build binary and attesters)"
@echo " build Build ratsd binary and all attesters"
@echo " build-sa Build sub-attesters only"
@echo " build-la Build ratsd binary only"
@echo ""
@echo "Code Generation:"
@echo " generate Generate code from protobuf and OpenAPI specs"
@echo " install-tools Install Go code generation tools (requires protoc)"
@echo " install-protoc Install protoc compiler (requires sudo)"
@echo " setup-dev Install protoc + Go tools (complete dev setup)"
@echo ""
@echo "Testing:"
@echo " test Run all tests"
@echo ""
@echo "Certificates:"
@echo " gen-certs Generate TLS certificates"
@echo " clean-certs Clean generated certificates"
@echo ""
@echo "Cleanup:"
@echo " clean Clean all build artifacts"
@echo " clean-sa Clean sub-attester build artifacts"
@echo " clean-la Clean ratsd binary"
@echo ""
@echo "Dependency Checks:"
@echo " check-protoc Check if protoc is installed"
@echo " check-generate-deps Check if all code generation tools are available"
@echo ""
@echo "Prerequisites:"
@echo " - Install protoc: sudo apt-get install protobuf-compiler (Ubuntu/Debian)"
@echo " - Run 'make install-tools' to install Go code generation tools"
@echo " - See README.md for detailed installation instructions"
@echo ""

.PHONY: all
all: generate build
all: check-protoc generate build

.PHONY: gen-certs
gen-certs:
./gen-certs create

.PHONY: generate
generate:
generate: check-generate-deps
go generate ./...

.PHONY: check-generate-deps
check-generate-deps: check-protoc
@echo "Checking for required code generation tools..."
@which protoc-gen-go > /dev/null 2>&1 || { \
echo "ERROR: protoc-gen-go is not installed."; \
echo "Please run 'make install-tools' first."; \
exit 1; \
}
@which protoc-gen-go-grpc > /dev/null 2>&1 || { \
echo "ERROR: protoc-gen-go-grpc is not installed."; \
echo "Please run 'make install-tools' first."; \
exit 1; \
}
@echo "All code generation dependencies are available."

.PHONY: build build-sa build-la
build: build-sa build-la

Expand All @@ -38,11 +91,65 @@ clean-la:
rm -f $(BIN)

.PHONY: install-tools
install-tools:
install-tools: check-protoc
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
go install google.golang.org/protobuf/cmd/protoc-gen-go
go install google.golang.org/protobuf/cmd/protoc-gen-go-grpc
go install go.uber.org/mock/mockgen
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install go.uber.org/mock/mockgen@latest

.PHONY: check-protoc
check-protoc:
@echo "Checking for protoc..."
@which protoc > /dev/null 2>&1 || { \
echo "ERROR: protoc (Protocol Buffer Compiler) is not installed or not in PATH."; \
echo ""; \
echo "Please install protoc using one of the following methods:"; \
echo ""; \
echo "Ubuntu/Debian:"; \
echo " sudo apt-get update && sudo apt-get install -y protobuf-compiler"; \
echo ""; \
echo "RHEL/CentOS:"; \
echo " sudo yum install -y protobuf-compiler"; \
echo ""; \
echo "Fedora:"; \
echo " sudo dnf install -y protobuf-compiler"; \
echo ""; \
echo "macOS:"; \
echo " brew install protobuf"; \
echo ""; \
echo "Or download from: https://github.com/protocolbuffers/protobuf/releases"; \
echo ""; \
exit 1; \
}
@echo "protoc found: $$(which protoc)"

.PHONY: install-protoc
install-protoc:
@echo "Attempting to install protoc..."
@if command -v apt-get >/dev/null 2>&1; then \
echo "Detected apt-get (Ubuntu/Debian). Installing protobuf-compiler..."; \
sudo apt-get update && sudo apt-get install -y protobuf-compiler; \
elif command -v yum >/dev/null 2>&1; then \
echo "Detected yum (RHEL/CentOS). Installing protobuf-compiler..."; \
sudo yum install -y protobuf-compiler; \
elif command -v dnf >/dev/null 2>&1; then \
echo "Detected dnf (Fedora). Installing protobuf-compiler..."; \
sudo dnf install -y protobuf-compiler; \
elif command -v brew >/dev/null 2>&1; then \
echo "Detected brew (macOS). Installing protobuf..."; \
brew install protobuf; \
else \
echo "Unable to detect package manager. Please install protoc manually."; \
echo "See README.md for installation instructions."; \
exit 1; \
fi
@echo "protoc installation completed. Verifying..."
@which protoc || { echo "Installation failed. Please install protoc manually."; exit 1; }

.PHONY: setup-dev
setup-dev: install-protoc install-tools
@echo "Development environment setup complete!"
@echo "You can now run 'make' to build RATSD."

.PHONY: clean-certs
clean-certs:
Expand Down
72 changes: 69 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,71 @@
A RATS conceptual message collection daemon

# Building

## Prerequisites

Before building RATSD, you need to install the following system dependencies:

### Protocol Buffer Compiler (protoc)

**Ubuntu/Debian:**
```bash
sudo apt-get update
sudo apt-get install -y protobuf-compiler
```

**RHEL/CentOS/Fedora:**
```bash
# For RHEL/CentOS
sudo yum install -y protobuf-compiler
# For Fedora
sudo dnf install -y protobuf-compiler
```

**macOS:**
```bash
brew install protobuf
```

**From Source (if package not available):**
```bash
# Download and install protoc from https://github.com/protocolbuffers/protobuf/releases
# Example for Linux x86_64:
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v25.1/protoc-25.1-linux-x86_64.zip
unzip protoc-25.1-linux-x86_64.zip -d $HOME/.local
export PATH="$PATH:$HOME/.local/bin"
```

### Go Dependencies

The binary `ratsd` is built by using `make` using the following steps:
* Install golang version specified in go.mod
* Ensure GOPATH is available in the shell path (`export GOPATH="$HOME/go"; export PATH=$PATH:$GOPATH/bin`)
* Install build tools using `make install-tools`.
* Build RATSd using `make`

## (Optional) Regenerate ratsd core code from OpenAPI spec
Regeneration of the code for ratsd requires the installation of various protobuf packages beforehand. Use the following commands to install them:
Regeneration of the code for ratsd requires the installation of protobuf compiler and Go protobuf plugins.

**Prerequisites:** Make sure you have installed the `protoc` compiler (see Prerequisites section above).

Then install the Go code generation tools:
```bash
make install-tools
```
Then generate the code with `make generate`

Generate the code:
```bash
make generate
```

**Note:** The `make install-tools` command installs:
- `protoc-gen-go` - Go protocol buffer plugin
- `protoc-gen-go-grpc` - Go gRPC plugin
- `oapi-codegen` - OpenAPI code generator
- `mockgen` - Mock generation tool

All of these require the base `protoc` compiler to be installed separately.

## Building ratsd core and leaf attesters

Expand Down Expand Up @@ -59,7 +112,7 @@ Ratsd currently supports the Trusted Secure Module `tsm` attester. You can speci
```bash
curl -X POST http://localhost:8895/ratsd/chares -H "Content-type: application/vnd.veraison.chares+json" -d '{"nonce": "TUlEQk5IMjhpaW9pc2pQeXh4eHh4eHh4eHh4eHh4eHhNSURCTkgyOGlpb2lzalB5eHh4eHh4eHh4eHh4eHh4eA", tsm-report:{"privilege_level": "$level"}}' # Replace $level with a number from 0 to 3
```
## Get evidence from the selected attester only
### Get evidence from the selected attester only

If more than one leaf attesters present, ratsd adds the evidence generated by all attesters to the response of `/ratsd/chares`. To limit the output to the selected attester, add `list-options: selected` to config.yaml,
then specify the name of each attester along with the associated options in `attester-selection`. If the user does not wish to specify the attester-specific option, "$attester_name": "null" should be specified. The following is an example of the request:
Expand All @@ -79,3 +132,16 @@ If more than one leaf attesters present, ratsd adds the evidence generated by al
```

If `list-options` is not set, or if it's set to `all` in config.yaml, ratsd populates the EAT with CMW from all available attesters as the default behavior.
### Content type selection

Pick the desired output content type of each sub-attester
by specifying field "content-type" in "attester-selection" as shown in
the following example:
```json
"attester-selection": {
"mock-tsm":{
"content-type": "application/vnd.veraison.configfs-tsm+json",
"privilege_level": "3"
}
}
```
10 changes: 8 additions & 2 deletions api/mocks/imanager.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 25 additions & 5 deletions api/mocks/ipluggable.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading