Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate oak containers protos into one ergonomic file for customer teams, and add relevant build targets #4663

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 0 additions & 2 deletions Cargo.lock

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

5 changes: 0 additions & 5 deletions oak_containers/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion oak_containers_launcher/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for connecting to the launcher.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../proto/containers/launcher.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/key_provisioning/key_provisioning.proto",
"../proto/containers/hostlib_key_provisioning.proto",
Expand Down
2 changes: 0 additions & 2 deletions oak_containers_launcher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
pub mod proto {
pub mod oak {
pub mod containers {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
Expand Down
12 changes: 4 additions & 8 deletions oak_containers_launcher/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ use tokio_stream::wrappers::TcpListenerStream;
use tonic::{transport::Server, Request, Response, Status};

use crate::proto::oak::{
containers::{
containers::v1::{
hostlib_key_provisioning_server::{HostlibKeyProvisioning, HostlibKeyProvisioningServer},
launcher_server::{Launcher, LauncherServer},
v1::{
hostlib_key_provisioning_server::{
HostlibKeyProvisioning, HostlibKeyProvisioningServer,
},
GetGroupKeysResponse, GetKeyProvisioningRoleResponse, KeyProvisioningRole,
},
GetApplicationConfigResponse, GetImageResponse, SendAttestationEvidenceRequest,
GetApplicationConfigResponse, GetGroupKeysResponse, GetImageResponse,
GetKeyProvisioningRoleResponse, KeyProvisioningRole, SendAttestationEvidenceRequest,
},
session::v1::AttestationEvidence,
};
Expand Down
4 changes: 2 additions & 2 deletions oak_containers_orchestrator/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for Orchestrator services.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../proto/key_provisioning/key_provisioning.proto",
"../proto/containers/orchestrator_crypto.proto",
"../proto/containers/application_interfaces.proto",
"../proto/containers/launcher.proto",
"../proto/containers/hostlib_key_provisioning.proto",
"../proto/session/messages.proto",
],
Expand Down
4 changes: 2 additions & 2 deletions oak_containers_orchestrator/src/ipc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ use tonic::{transport::Server, Request, Response};
use crate::{
crypto::{CryptoService, KeyStore},
launcher_client::LauncherClient,
proto::oak::containers::{
proto::oak::containers::v1::{
orchestrator_crypto_server::OrchestratorCryptoServer,
orchestrator_server::{Orchestrator, OrchestratorServer},
v1::orchestrator_crypto_server::OrchestratorCryptoServer,
GetApplicationConfigResponse,
},
};
Expand Down
6 changes: 3 additions & 3 deletions oak_containers_orchestrator/src/launcher_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use tonic::transport::Channel;

use crate::proto::oak::{
attestation::v1::Evidence,
containers::{
launcher_client::LauncherClient as GrpcLauncherClient,
v1::{hostlib_key_provisioning_client::HostlibKeyProvisioningClient, KeyProvisioningRole},
containers::v1::{
hostlib_key_provisioning_client::HostlibKeyProvisioningClient,
launcher_client::LauncherClient as GrpcLauncherClient, KeyProvisioningRole,
SendAttestationEvidenceRequest,
},
key_provisioning::v1::GroupKeys,
Expand Down
2 changes: 0 additions & 2 deletions oak_containers_orchestrator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
pub mod proto {
pub mod oak {
pub mod containers {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
Expand Down
1 change: 0 additions & 1 deletion oak_containers_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ oak_grpc_utils = { workspace = true }
[dependencies]
anyhow = "*"
async-trait = { version = "*", default-features = false }
oak_attestation = { workspace = true }
oak_crypto = { workspace = true }
prost = "*"
prost-types = "*"
Expand Down
3 changes: 1 addition & 2 deletions oak_containers_sdk/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for connecting to the Orchestrator.
generate_grpc_code(
&[
"oak_containers/proto/interfaces.proto",
"oak_crypto/proto/v1/crypto.proto",
"proto/session/messages.proto",
"proto/containers/orchestrator_crypto.proto",
"proto/containers/application_interfaces.proto",
],
"..",
CodegenOptions {
Expand Down
2 changes: 0 additions & 2 deletions oak_containers_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@
mod proto {
pub mod oak {
pub mod containers {
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
}
}
pub use oak_attestation::proto::oak::{attestation, session};
pub use oak_crypto::proto::oak::crypto;
}
}
Expand Down
2 changes: 1 addition & 1 deletion oak_containers_sdk/src/orchestrator_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use anyhow::{Context, Result};
use tonic::transport::{Endpoint, Uri};
use tower::service_fn;

use crate::proto::oak::containers::orchestrator_client::OrchestratorClient as GrpcOrchestratorClient;
use crate::proto::oak::containers::v1::orchestrator_client::OrchestratorClient as GrpcOrchestratorClient;

// Unix Domain Sockets do not use URIs, hence this URI will never be used.
// It is defined purely since in order to create a channel, since a URI has to
Expand Down
1 change: 0 additions & 1 deletion oak_containers_stage1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ clap = { version = "*", features = ["derive"] }
coset = { version = "*", features = ["std"] }
futures-util = "*"
oak_attestation = { workspace = true }
oak_crypto = { workspace = true }
oak_dice = { workspace = true }
nix = { version = "*", features = ["mman"] }
p256 = { version = "*" }
Expand Down
2 changes: 1 addition & 1 deletion oak_containers_stage1/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for loading the system image.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/session/messages.proto",
"../proto/containers/launcher.proto",
],
"..",
CodegenOptions {
Expand Down
7 changes: 5 additions & 2 deletions oak_containers_stage1/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@
mod proto {
pub mod oak {
pub mod containers {
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
}
}
pub use oak_attestation::proto::oak::{attestation, session};
}
}

use anyhow::{Context, Result};
use proto::oak::containers::launcher_client::LauncherClient as GrpcLauncherClient;
use proto::oak::containers::v1::launcher_client::LauncherClient as GrpcLauncherClient;
use tonic::transport::{Channel, Uri};

pub struct LauncherClient {
Expand Down
3 changes: 2 additions & 1 deletion oak_functions_containers_app/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/containers/application_interfaces.proto",
"../proto/session/messages.proto",
],
"..",
Expand Down
6 changes: 4 additions & 2 deletions oak_functions_containers_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ pub mod proto {
tonic::include_proto!("oak.functions");
}
pub mod containers {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers");
pub mod v1 {
#![allow(clippy::return_self_not_must_use)]
tonic::include_proto!("oak.containers.v1");
}
}
pub use oak_attestation::proto::oak::{attestation, session};
pub use oak_crypto::proto::oak::crypto;
Expand Down
42 changes: 39 additions & 3 deletions proto/containers/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,52 @@

load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")

package(
default_visibility = ["//visibility:public"],
licenses = ["notice"],
)

proto_library(
name = "orchestrator_crypto_proto",
srcs = ["orchestrator_crypto.proto"],
name = "common_proto",
srcs = ["common.proto"],
)

proto_library(
name = "application_interfaces_proto",
srcs = ["application_interfaces.proto"],
deps = [
"//oak_crypto/proto/v1:crypto_proto",
"//oak_remote_attestation/proto/v1:messages_proto",
"@com_google_protobuf//:empty_proto",
":common_proto"
],
)

cc_proto_library(
name = "application_interfaces_cc_proto",
deps = [":application_interfaces_proto"],
)


py_proto_library(
name = "application_interfaces_py_proto",
deps = [":application_interfaces_proto"],
)

py_grpc_library(
name = "application_interfaces_py_grpc",
srcs = [":application_interfaces_proto"],
deps = [":application_interfaces_py_proto"],
)

proto_library(
name = "launcher_proto",
srcs = ["launcher.proto"],
deps = [
":common_proto",
],
)

Expand All @@ -42,6 +77,7 @@ build_test(
name = "build_test",
targets = [
":hostlib_key_provisioning_proto",
":orchestrator_crypto_proto",
":application_interfaces_proto",
":launcher_proto"
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,27 @@
// limitations under the License.
//

// Interfaces that may be invoked by the application

syntax = "proto3";

package oak.containers.v1;

import "oak_crypto/proto/v1/crypto.proto";
import "google/protobuf/empty.proto";
import "proto/containers/common.proto";

// Defines the service exposed by the orchestrator, that can be invoked by the application.
service Orchestrator {
// Exposes the previously loaded trusted application config to the application,
// which may choose to retrieve it.
rpc GetApplicationConfig(google.protobuf.Empty) returns (GetApplicationConfigResponse) {}

// Notifies the orchestrator that the trusted app is ready to serve requests and listening on the
// pre-arranged port (8080).
rpc NotifyAppReady(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}


// Choice between a key generated by the enclave instance and the key distributed to the enclave
// group with Key Provisioning.
Expand Down
19 changes: 6 additions & 13 deletions oak_containers_syslogd/build.rs → proto/containers/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@
// limitations under the License.
//

use oak_grpc_utils::{generate_grpc_code, CodegenOptions};
syntax = "proto3";

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Generate gRPC code for connecting to the launcher.
generate_grpc_code(
&[
"../oak_containers/proto/interfaces.proto",
"../oak_crypto/proto/v1/crypto.proto",
"../proto/session/messages.proto",
],
"..",
CodegenOptions::default(),
)?;
package oak.containers.v1;

Ok(())
message GetApplicationConfigResponse {
// Arbitrary config that the container can retrieve from the orchestrator.
// Included in the attestation measurements conducted by the orchestrator.
bytes config = 1;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting choice of file that the git algorithm determined I modified and renamed.

For clarity: the old build file is deleted, as it was unused.

The new proto file is unrelated.

Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

syntax = "proto3";

package oak.containers;
package oak.containers.v1;

import "google/protobuf/empty.proto";
import "oak_crypto/proto/v1/crypto.proto";
import "proto/attestation/endorsement.proto";
import "proto/attestation/evidence.proto";
import "proto/session/messages.proto";
import "proto/containers/common.proto";


// As images can be large (hundreds of megabytes), the launcher chunks up the response into smaller
// pieces to respect proto/gRPC limits. The image needs to be reassembled in the stage1 or the
Expand All @@ -31,12 +31,6 @@ message GetImageResponse {
bytes image_chunk = 1;
}

message GetApplicationConfigResponse {
// Arbitrary config that the container can retrieve from the orchestrator.
// Included in the attestation measurements conducted by the orchestrator.
bytes config = 1;
}

message SendAttestationEvidenceRequest {
oak.session.v1.AttestationEvidence evidence = 1 [deprecated = true];
oak.attestation.v1.Evidence dice_evidence = 2;
Expand Down Expand Up @@ -67,14 +61,3 @@ service Launcher {
// pre-arranged port (8080).
rpc NotifyAppReady(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}

// Defines the service exposed by the orchestrator, that can be invoked by the application.
service Orchestrator {
// Exposes the previously loaded trusted application config to the application,
// which may choose to retrieve it.
rpc GetApplicationConfig(google.protobuf.Empty) returns (GetApplicationConfigResponse) {}

// Notifies the orchestrator that the trusted app is ready to serve requests and listening on the
// pre-arranged port (8080).
rpc NotifyAppReady(google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
Loading