Skip to content

Commit 91b3bb2

Browse files
fix(clickhouse): resolve security issues in TLS and ReadOnly configuration
- Fix insecure TLS configuration: only enable TLS when SSLMode is not "none" or "disable" - Fix missing ReadOnly enforcement: set ClickHouse "readonly" setting when ReadOnly="enable" - Ensure InsecureSkipVerify is only used for "relaxed" mode, not for "none" Co-authored-by: Anguel <modelorona@users.noreply.github.com>
1 parent 8fe710b commit 91b3bb2

File tree

1 file changed

+10
-2
lines changed
  • core/src/plugins/clickhouse

1 file changed

+10
-2
lines changed

core/src/plugins/clickhouse/db.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,21 @@ func (p *ClickHousePlugin) DB(config *engine.PluginConfig) (*gorm.DB, error) {
6060
if connectionInput.Debug != "disable" {
6161
options.Debug = true
6262
}
63+
// Configure settings based on ReadOnly mode
6364
if connectionInput.ReadOnly == "disable" {
6465
options.Settings = clickhouse.Settings{
6566
"max_execution_time": 60,
6667
}
68+
} else if connectionInput.ReadOnly == "enable" {
69+
options.Settings = clickhouse.Settings{
70+
"readonly": 1,
71+
"max_execution_time": 60,
72+
}
6773
}
68-
if connectionInput.SSLMode != "disable" {
69-
options.TLS = &tls.Config{InsecureSkipVerify: connectionInput.SSLMode == "relaxed" || connectionInput.SSLMode == "none"}
74+
75+
// Configure TLS - only enable when SSLMode is not "none" and not "disable"
76+
if connectionInput.SSLMode != "disable" && connectionInput.SSLMode != "none" {
77+
options.TLS = &tls.Config{InsecureSkipVerify: connectionInput.SSLMode == "relaxed"}
7078
}
7179

7280
conn := clickhouse.OpenDB(options)

0 commit comments

Comments
 (0)