Skip to content

Commit 1262644

Browse files
committed
rvps: add flag to restrict operations to be read-only
Introduce rvps_read_only flag, that forces the rvps server to only allow queries and not register new reference values. This is useful for operator/kubernetes/container deployment where the rvps is run as standalone and therefore not configured via kbs-config.toml. Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
1 parent 12a9ed6 commit 1262644

File tree

9 files changed

+30
-3
lines changed

9 files changed

+30
-3
lines changed

attestation-service/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ mod tests {
9494
rvps_config: RvpsConfig::BuiltIn(RvpsCrateConfig {
9595
storage: ReferenceValueStorageConfig::LocalFs(local_fs::Config::default()),
9696
extractors: None,
97+
rvps_read_only: false,
9798
}),
9899
attestation_token_broker: AttestationTokenConfig::Simple(simple::Configuration {
99100
duration_min: 5,
@@ -107,6 +108,7 @@ mod tests {
107108
rvps_config: RvpsConfig::BuiltIn(RvpsCrateConfig {
108109
storage: ReferenceValueStorageConfig::LocalFs(local_fs::Config::default()),
109110
extractors: None,
111+
rvps_read_only: false,
110112
}),
111113
attestation_token_broker: AttestationTokenConfig::Simple(simple::Configuration {
112114
duration_min: 5,
@@ -124,6 +126,7 @@ mod tests {
124126
rvps_config: RvpsConfig::BuiltIn(RvpsCrateConfig {
125127
storage: ReferenceValueStorageConfig::LocalFs(local_fs::Config::default()),
126128
extractors: None,
129+
rvps_read_only: false,
127130
}),
128131
attestation_token_broker: AttestationTokenConfig::Ear(ear_broker::Configuration {
129132
duration_min: 5,
@@ -140,6 +143,7 @@ mod tests {
140143
rvps_config: RvpsConfig::BuiltIn(RvpsCrateConfig {
141144
storage: ReferenceValueStorageConfig::LocalFs(local_fs::Config::default()),
142145
extractors: None,
146+
rvps_read_only: false,
143147
}),
144148
attestation_token_broker: AttestationTokenConfig::Ear(ear_broker::Configuration {
145149
duration_min: 5,

integration-tests/src/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl TestHarness {
157157
storage: ReferenceValueStorageConfig::LocalJson(local_json::Config {
158158
file_path: rv_path,
159159
}),
160+
rvps_read_only: false,
160161
}),
161162
RvpsType::Remote => {
162163
info!("Starting Remote RVPS");

kbs/config/as-config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"policy_engine": "opa",
44
"rvps_config": {
55
"type": "GrpcRemote",
6-
"address": "http://rvps:50003"
6+
"address": "http://rvps:50003",
7+
"rvps_read_only": false
78
},
89
"attestation_token_broker": {
910
"type": "Ear",

kbs/config/rvps.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"storage": {
33
"type":"LocalFs",
44
"file_path": "/opt/confidential-containers/attestation-service/reference_values"
5-
}
5+
},
6+
"rvps_read_only": false
67
}

kbs/src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ mod tests {
320320
file_path: "/opt/confidential-containers/attestation-service/reference_values".into(),
321321
}),
322322
extractors: None,
323+
rvps_read_only: false,
323324
}),
324325
attestation_token_broker: AttestationTokenConfig::Simple(simple::Configuration{
325326
duration_min: 5,

rvps/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ RVPS can be launched with a specified configuration file by `-c` flag. A configu
9898
"storage": {
9999
"type": "LocalFs",
100100
"file_path": "/opt/confidential-containers/attestation-service/reference_values"
101-
}
101+
},
102+
"rvps_read_only": false
102103
}
103104
```
104105
- `storage.type`: backend storage type to store reference values. Currently `LocalFs` and `LocalJson` are supported.
105106
- `storage.*`: Each different type of storage has its own associated configuration parameters. This is also a JSON map object.
107+
- `rvps_read_only`: Whether RVPS should run in read-only mode (disable reference value registration). Defaults to `false`.
106108

107109
## Integrate RVPS into the Attestation Service
108110

rvps/src/bin/rvps.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ async fn main() -> Result<()> {
5353

5454
info!("Listen socket: {}", &cli.address);
5555

56+
if config.rvps_read_only {
57+
info!("RVPS is running in READ-ONLY mode. Reference value registration is disabled.");
58+
} else {
59+
info!("RVPS is running in normal mode. Reference value registration is enabled.");
60+
}
61+
5662
let socket = cli.address.parse().context("parse socket addr failed")?;
5763

5864
server::start(socket, config).await

rvps/src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ pub struct Config {
1515

1616
#[serde(default)]
1717
pub extractors: Option<ExtractorsConfig>,
18+
19+
#[serde(default)]
20+
pub rvps_read_only: bool,
1821
}
1922

2023
impl Config {

rvps/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fn default_version() -> String {
5252
pub struct Rvps {
5353
extractors: Extractors,
5454
storage: Box<dyn ReferenceValueStorage + Send + Sync>,
55+
read_only: bool,
5556
}
5657

5758
impl Rvps {
@@ -63,10 +64,17 @@ impl Rvps {
6364
Ok(Rvps {
6465
extractors,
6566
storage,
67+
read_only: config.rvps_read_only,
6668
})
6769
}
6870

6971
pub async fn verify_and_extract(&mut self, message: &str) -> Result<()> {
72+
if self.read_only {
73+
bail!(
74+
"RVPS is configured in read-only mode. Reference value registration is disabled."
75+
);
76+
}
77+
7078
let message: Message = serde_json::from_str(message).context("parse message")?;
7179

7280
// Judge the version field

0 commit comments

Comments
 (0)