Skip to content

Commit e1be258

Browse files
authored
cvm_tracing: Allow untagged tracing statements by default (#1402) (#1406)
After long discussions we have decided to flip the default of our tracing filter, and to allow untagged tracing statements by default. We believe that the risks and costs of being unable to debug incidents in production are too high, and that we can manually scrub our tracing statements to ensure that no sensitive information is leaked. Cherry-pick of #1402. Part of #852.
1 parent c8ccd67 commit e1be258

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Guide/src/reference/openhcl/diag/cvm_restrictions.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,41 +22,41 @@ behave as if it is running in a CVM for the purpose of diagnostics.
2222
## Tracing
2323

2424
Tracing statements and spans will still be sent to the host, and therefore will still show up in
25-
ETW traces and Kusto. However, individual statements must opt in to being logged inside a CVM, as a
26-
way of affirming that they do not leak any guest secrets.
25+
ETW traces and Kusto. However, individual statements may opt out of being logged inside a CVM, as a
26+
way of protecting guest secrets.
2727

2828
### For Developers:
2929

30-
This is done by using the `CVM_ALLOWED`
31-
constant provided by the `cvm_tracing` crate. `cvm_tracing` also provides a `CVM_CONFIDENTIAL`
32-
constant, to mark statements that could contain secrets and should not be logged in a CVM.
30+
This is done by using the `CVM_CONFIDENTIAL` constant provided by the
31+
`cvm_tracing` crate. `cvm_tracing` also provides a `CVM_ALLOWED` constant, to
32+
mark statements that do not contain secrets and can be logged in a CVM.
3333

3434
Examples:
3535

3636
```rust
3737
use cvm_tracing::{CVM_ALLOWED, CVM_CONFIDENTIAL};
3838

3939
tracing::info!(CVM_ALLOWED, foo, ?bar, "This statement will be logged in a CVM");
40-
tracing::info!(baz, "This statement will not be logged in a CVM");
41-
tracing::info!(CVM_CONFIDENTIAL, super_secret, "This statement will also not be logged in a CVM");
40+
tracing::info!(baz, "This statement will also be logged in a CVM");
41+
tracing::info!(CVM_CONFIDENTIAL, super_secret, "This statement will not be logged in a CVM");
4242

4343
// This also works with spans.
44-
let span = tracing::info_span!("a span", CVM_ALLOWED);
44+
let span = tracing::info_span!("a span", CVM_CONFIDENTIAL);
4545
my_func.instrument(span).await;
4646

4747
// And the #[instrument] macro.
48-
#[instrument(name = "foo", fields(CVM_ALLOWED))]
48+
#[instrument(name = "foo", fields(CVM_CONFIDENTIAL))]
4949
fn my_func() {
5050
// ...
5151
}
5252
```
5353

5454
```admonish tip
55-
Some of the tracing macros will not accept `cvm_tracing::CVM_ALLOWED` as an
55+
Some of the tracing macros will not accept `cvm_tracing::CVM_CONFIDENTIAL` as an
5656
argument.
5757
58-
Instead, you will need to `use cvm_tracing::CVM_ALLOWED`, and then use just
59-
`CVM_ALLOWED`.
58+
Instead, you will need to `use cvm_tracing::CVM_CONFIDENTIAL`, and then use just
59+
`CVM_CONFIDENTIAL`.
6060
```
6161

6262
## ohcldiag-dev

vm/cvm_tracing/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
//! Implements a tracing filter to restrict logging of events to only those
5-
//! that are marked as [`CVM_ALLOWED`].
4+
//! Implements a tracing filter to restrict logging of events that are marked
5+
//! as [`CVM_CONFIDENTIAL`].
66
77
// How it works:
88
// The magic value [`tracing::field::Empty`] will cause that field to be omitted
@@ -24,9 +24,9 @@ pub const CVM_ALLOWED: Empty = Empty;
2424
/// not be logged out of a confidential environment.
2525
pub const CVM_CONFIDENTIAL: Empty = Empty;
2626

27-
/// A tracing filter that will only allow events that are marked as [`CVM_ALLOWED`].
27+
/// A tracing filter that will block events that are marked as [`CVM_CONFIDENTIAL`].
2828
pub fn confidential_event_filter<S: Subscriber>() -> impl Filter<S> {
29-
FilterFn::new(move |m| m.fields().field("CVM_ALLOWED").is_some())
29+
FilterFn::new(move |m| m.fields().field("CVM_CONFIDENTIAL").is_none())
3030
}
3131

3232
#[cfg(test)]
@@ -96,6 +96,6 @@ mod test {
9696
fn it_works() {
9797
let (count, subscriber) = create_test_subscriber();
9898
log_test_events(subscriber);
99-
assert_eq!(count.load(std::sync::atomic::Ordering::SeqCst), 5);
99+
assert_eq!(count.load(std::sync::atomic::Ordering::SeqCst), 10);
100100
}
101101
}

0 commit comments

Comments
 (0)