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

feat(catalog): add support for redacting sensitive connector properties #14193

Closed
wants to merge 3 commits into from
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
22 changes: 22 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ members = [
"src/tests/state_cleaning_test",
"src/utils/local_stats_alloc",
"src/utils/pgwire",
"src/utils/redaction/redaction",
"src/utils/redaction/redaction_derive",
"src/utils/runtime",
"src/utils/sync-point",
"src/utils/variables",
Expand Down
2 changes: 2 additions & 0 deletions src/connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ itertools = "0.12"
jni = { version = "0.21.1", features = ["invocation"] }
jst = { package = 'jsonschema-transpiler', git = "https://github.com/mozilla/jsonschema-transpiler", rev = "c1a89d720d118843d8bcca51084deb0ed223e4b4" }
maplit = "1.0.2"
mark_redaction = { path = "../utils/redaction/redaction" }
mark_redaction_derive = { path = "../utils/redaction/redaction_derive" }
moka = { version = "0.12", features = ["future"] }
mysql_async = { version = "0.33", default-features = false, features = [
"default",
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/cdc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use std::marker::PhantomData;

pub use enumerator::*;
use itertools::Itertools;
use mark_redaction_derive::MarkRedaction;
use risingwave_common::catalog::{ColumnDesc, Field, Schema};
use risingwave_pb::catalog::PbSource;
use risingwave_pb::connector_service::{PbSourceType, PbTableSchema, SourceType, TableSchema};
Expand Down Expand Up @@ -68,7 +69,7 @@ impl CdcSourceType {
}
}

#[derive(Clone, Debug, Default)]
#[derive(Clone, Debug, Default, MarkRedaction)]
pub struct CdcProperties<T: CdcSourceTypeTrait> {
/// Properties specified in the WITH clause by user
pub properties: HashMap<String, String>,
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/datagen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod split;
use std::collections::HashMap;

pub use enumerator::*;
use mark_redaction_derive::MarkRedaction;
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};
pub use source::*;
Expand All @@ -29,7 +30,7 @@ use crate::source::SourceProperties;
pub const DATAGEN_CONNECTOR: &str = "datagen";

#[serde_as]
#[derive(Clone, Debug, Deserialize)]
#[derive(Clone, Debug, Deserialize, MarkRedaction)]
xxchan marked this conversation as resolved.
Show resolved Hide resolved
pub struct DatagenProperties {
/// split_num means data source partition
#[serde(rename = "datagen.split.num")]
Expand Down
6 changes: 4 additions & 2 deletions src/connector/src/source/filesystem/opendal_source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use serde::Deserialize;
pub mod opendal_enumerator;
pub mod opendal_reader;

use mark_redaction_derive::MarkRedaction;

use self::opendal_enumerator::OpendalEnumerator;
use self::opendal_reader::OpendalReader;
use super::{OpendalFsSplit, S3Properties};
Expand All @@ -30,7 +32,7 @@ pub const GCS_CONNECTOR: &str = "gcs";
// The new s3_v2 will use opendal.
pub const OPENDAL_S3_CONNECTOR: &str = "s3_v2";

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, MarkRedaction)]
pub struct GcsProperties {
#[serde(rename = "gcs.bucket_name")]
pub bucket_name: String,
Expand Down Expand Up @@ -78,7 +80,7 @@ impl OpendalSource for OpendalGcs {
}
}

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, MarkRedaction)]
pub struct OpendalS3Properties {
pub s3_properties: S3Properties,
#[serde(rename = "s3.assume_role", default)]
Expand Down
5 changes: 4 additions & 1 deletion src/connector/src/source/filesystem/s3/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod enumerator;

pub use enumerator::S3SplitEnumerator;
mod source;
use mark_redaction_derive::MarkRedaction;
use serde::Deserialize;
pub use source::S3FileReader;

Expand All @@ -24,7 +25,7 @@ use crate::source::SourceProperties;

pub const S3_CONNECTOR: &str = "s3";

#[derive(Clone, Debug, Deserialize, PartialEq)]
#[derive(Clone, Debug, Deserialize, PartialEq, MarkRedaction)]
pub struct S3Properties {
#[serde(rename = "s3.region_name")]
pub region_name: String,
Expand All @@ -33,8 +34,10 @@ pub struct S3Properties {
#[serde(rename = "match_pattern", default)]
pub match_pattern: Option<String>,
#[serde(rename = "s3.credentials.access", default)]
#[mark_redaction(rename = "s3.credentials.access")]
Copy link
Contributor

@tabVersion tabVersion Dec 26, 2023

Choose a reason for hiding this comment

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

access key seems not that sensitive. cc @hzxa21

Copy link
Member

Choose a reason for hiding this comment

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

Can we reuse the serde attributes for mark_redaction to avoid duplication?

pub access: Option<String>,
#[serde(rename = "s3.credentials.secret", default)]
#[mark_redaction(rename = "s3.credentials.secret")]
pub secret: Option<String>,
#[serde(rename = "s3.endpoint_url")]
pub endpoint_url: Option<String>,
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/google_pubsub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub mod source;
pub mod split;

pub use enumerator::*;
use mark_redaction_derive::MarkRedaction;
use serde_with::{serde_as, DisplayFromStr};
pub use source::*;
pub use split::*;
Expand All @@ -29,7 +30,7 @@ use crate::source::SourceProperties;
pub const GOOGLE_PUBSUB_CONNECTOR: &str = "google_pubsub";

#[serde_as]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Hash, WithOptions)]
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Hash, WithOptions, MarkRedaction)]
pub struct PubsubProperties {
#[serde_as(as = "DisplayFromStr")]
#[serde(rename = "pubsub.split_count")]
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/kafka/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ pub mod split;
pub mod stats;

pub use enumerator::*;
use mark_redaction_derive::MarkRedaction;
pub use private_link::*;
pub use source::*;
pub use split::*;
Expand Down Expand Up @@ -87,7 +88,7 @@ pub struct RdKafkaPropertiesConsumer {
pub enable_auto_commit: Option<bool>,
}

#[derive(Clone, Debug, Deserialize, WithOptions)]
#[derive(Clone, Debug, Deserialize, WithOptions, MarkRedaction)]
pub struct KafkaProperties {
/// This parameter is not intended to be exposed to users.
/// This parameter specifies only for one parallelism. The parallelism of kafka source
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/kinesis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod enumerator;
pub mod source;
pub mod split;

use mark_redaction_derive::MarkRedaction;
use serde::Deserialize;
use serde_with::{serde_as, DisplayFromStr};
use with_options::WithOptions;
Expand All @@ -29,7 +30,7 @@ use crate::source::SourceProperties;
pub const KINESIS_CONNECTOR: &str = "kinesis";

#[serde_as]
#[derive(Clone, Debug, Deserialize, WithOptions)]
#[derive(Clone, Debug, Deserialize, WithOptions, MarkRedaction)]
pub struct KinesisProperties {
#[serde(rename = "scan.startup.mode", alias = "kinesis.scan.startup.mode")]
// accepted values: "latest", "earliest", "timestamp"
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/nats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub mod enumerator;
pub mod source;
pub mod split;

use mark_redaction_derive::MarkRedaction;
use serde::Deserialize;
use with_options::WithOptions;

Expand All @@ -26,7 +27,7 @@ use crate::source::SourceProperties;

pub const NATS_CONNECTOR: &str = "nats";

#[derive(Clone, Debug, Deserialize, WithOptions)]
#[derive(Clone, Debug, Deserialize, WithOptions, MarkRedaction)]
pub struct NatsProperties {
#[serde(flatten)]
pub common: NatsCommon,
Expand Down
12 changes: 10 additions & 2 deletions src/connector/src/source/nexmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ pub mod enumerator;
pub mod source;
pub mod split;

use std::collections::HashMap;
use std::collections::{HashMap, HashSet};

pub use enumerator::*;
use mark_redaction::MarkRedaction;
use mark_redaction_derive::MarkRedaction;
use nexmark::config::{NexmarkConfig, RateShape};
use nexmark::event::EventType;
use serde::Deserialize;
Expand All @@ -45,8 +47,14 @@ const fn none<T>() -> Option<T> {

pub type NexmarkProperties = Box<NexmarkPropertiesInner>;

impl MarkRedaction for NexmarkProperties {
fn marks() -> HashSet<String> {
NexmarkPropertiesInner::marks()
}
}

#[serde_as]
#[derive(Clone, Debug, Deserialize, WithOptions)]
#[derive(Clone, Debug, Deserialize, WithOptions, MarkRedaction)]
pub struct NexmarkPropertiesInner {
#[serde_as(as = "DisplayFromStr")]
#[serde(rename = "nexmark.split.num", default = "identity_i32::<1>")]
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/pulsar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod split;
pub mod topic;

pub use enumerator::*;
use mark_redaction_derive::MarkRedaction;
use serde::Deserialize;
use serde_with::serde_as;
pub use split::*;
Expand All @@ -37,7 +38,7 @@ impl SourceProperties for PulsarProperties {
const SOURCE_NAME: &'static str = PULSAR_CONNECTOR;
}

#[derive(Clone, Debug, Deserialize, WithOptions)]
#[derive(Clone, Debug, Deserialize, WithOptions, MarkRedaction)]
#[serde_as]
pub struct PulsarProperties {
#[serde(rename = "scan.startup.mode", alias = "pulsar.scan.startup.mode")]
Expand Down
3 changes: 2 additions & 1 deletion src/connector/src/source/test_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use std::sync::{Arc, OnceLock};

use anyhow::anyhow;
use async_trait::async_trait;
use mark_redaction_derive::MarkRedaction;
use parking_lot::Mutex;
use risingwave_common::types::JsonbVal;
use serde_derive::{Deserialize, Serialize};
Expand Down Expand Up @@ -114,7 +115,7 @@ pub fn registry_test_source(box_source: BoxSource) -> TestSourceRegistryGuard {

pub const TEST_CONNECTOR: &str = "test";

#[derive(Clone, Debug)]
#[derive(Clone, Debug, MarkRedaction)]
pub struct TestSourceProperties {
properties: HashMap<String, String>,
}
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ futures-async-stream = { workspace = true }
iana-time-zone = "0.1"
itertools = "0.12"
maplit = "1"
mark_redaction = { path = "../utils/redaction/redaction" }
mark_redaction_derive = { path = "../utils/redaction/redaction_derive" }
md5 = "0.7.0"
num-integer = "0.1"
parking_lot = "0.12"
Expand Down
2 changes: 2 additions & 0 deletions src/frontend/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub use index_set::*;
pub(crate) mod group_by;
pub mod infer_stmt_row_desc;
pub mod overwrite_options;
pub mod redaction;

pub use group_by::*;
pub use overwrite_options::*;

Expand Down
Loading