Azure / Azure/typespec-azure

Identity PII

Open
#2,540 0 comments 0 reactions 0 assignees View on GitHub
design:needed lib:azure-core triaged:core
Dominant language
TypeScript
Stars
27
Forks
90
Avg merge
1d 22h
Merged PRs (30d)
156

Description

### Clear and concise description of the problem

Some languages e.g., Rust, make printing models, headers, etc. very easy e.g.,

```rust
#[derive(Debug)]
pub struct Employee {
pub id: Option,
pub name: Option,
pub title: Option,
}

let employee = client.get_employee(&id).await?;
println!("Found {employee:#?}");

// Found Employee {
// id: Some("abc123"),
// name: Some("Mary Smith"),
// title: Some("Director"),
// }
```

Devs idiomatically use this for logging or printf-debugging but `id` and probably `name` shouldn't be logged as PII (note: does not affect display in debuggers).

What we'd like is a way in TypeSpec to identity which fields either have PII (opt-in) or wouldn't reasonably have PII (opt-out) so that we can implement or derive this `Debug` trait so that we don't emit those fields e.g.,

```typespec
model Employee {
@pii
id?: string,
name: string,
title?: string,
```

In which case, our emitter could emit something like:

```rust
#[derive(SafeDebug)]
pub struct Employee {
#[safe_debug(hidden)]
pub id: Option,
pub name: Option,
pub title: Option,
}

let employee = client.get_employee(&id).await?;
println!("Found {employee:#?}");

// Found Employee {
// name: Some("Mary Smith"),
// title: Some("Director"),
// ..
// }
```

Other languages might also elide this information from any tracing they might do, or `ToString()` override, etc.

### Checklist

- [x] Follow our [Code of Conduct](https://github.com/azure/typespec-azure/blob/main/CODE_OF_CONDUCT.md)
- [x] Check that this issue is about the Azure libraries for typespec. For feature request in the typespec language or core libraries file it in the [TypeSpec repo](https://github.com/Microsoft/TypeSpec/issues/new/choose)
- [x] Read the [docs](https://azure.github.io/typespec-azure/).
- [x] Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by locating the TypeSpec Azure emitter that generates models and determine how a PII annotation could flow into generated language-specific debugging or string representations; done should define the annotation semantics and demonstrate that marked fields are omitted from generated logging output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, typescript
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.