multiwoven-integrations 0.43.17 → 0.43.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 308938c94623e2ad03d207db2f98cae4ddda7b523d3b36880db0caa7f24a7275
4
- data.tar.gz: 8c085afda93d95bcb930128a80c101be4c9cd9c7183bd93036a1d33abd1c0511
3
+ metadata.gz: 2997158adce499f5c945f7ad01ccfc1292485eea66ccbe9997c82c968c1ba22f
4
+ data.tar.gz: 572556b6bfc2fd91967062a063a3b917afd0bae4cde3ef7b5f79da61cc62648e
5
5
  SHA512:
6
- metadata.gz: 8a20174e9bafe4f3c6ee93d9c3789007e86615b705dc833909eeea0e04a408c4a8ebad2bec986ec129e1353dde53712b8cb9337ead40be4515264980d53b7628
7
- data.tar.gz: fa96749816eac6c1229a857ca767f350328339690d8ddaabd624a69f4bbc6bd5c45ad72dbaeea409471248a308ce6259e408cb1f2f6c274d88ec5f03ccb9da48
6
+ metadata.gz: 6004f0b01b929a5f8bd0c278a777f53c980b6bee8619ac0a0b3b730f411a6e29b1dfcc76d83049c3a309aa11a1ae5a9e9f4e31e2f670a5a216c2960ec7e7e903
7
+ data.tar.gz: 3b11aee92a2e24142db14a0e4289ede15c1c16670deb7db7b3e4afcbeb6d19599f29e23a371dfd09996d4a14a505f85b3ba950b754ab410688685d1bc90d8c93
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ### [0.43.18]
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * Amazon S3 source rejects unsupported or blank `auth_type` values instead of falling back to ambient pod credentials
9
+ * Amazon S3 source disables `auth_type: "role"` (failing closed without calling AWS STS) until per-workspace server-bound external IDs are implemented
10
+ * Amazon S3 source validates `bucket`, `path`, and `file_type` before constructing the DuckDB `DESCRIBE` path and rejects SQL injection, path traversal, and URL query parameters
11
+
3
12
  ### [0.43.17]
4
13
 
5
14
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Multiwoven
4
4
  module Integrations
5
- VERSION = "0.43.17"
5
+ VERSION = "0.43.18"
6
6
 
7
7
  ENABLED_SOURCES = %w[
8
8
  Snowflake
@@ -4,6 +4,13 @@ module Multiwoven::Integrations::Source
4
4
  module AmazonS3
5
5
  include Multiwoven::Integrations::Core
6
6
  class Client < UnstructuredSourceConnector
7
+ S3_FILE_TYPE = /\A[a-zA-Z0-9]+\z/.freeze
8
+ FORBIDDEN_S3_PATH_CHARACTERS = /['";?\\\x00-\x1f\x7f]/.freeze
9
+
10
+ UNSUPPORTED_AUTH_TYPE_ERROR = "Unsupported authentication type. Allowed values: user"
11
+ ROLE_AUTH_DISABLED_ERROR = "IAM role authentication is disabled until per-workspace external IDs are configured on the server"
12
+ INVALID_S3_PATH_ERROR = "Invalid S3 path"
13
+
7
14
  @session_name = ""
8
15
 
9
16
  def check_connection(connection_config)
@@ -15,7 +22,7 @@ module Multiwoven::Integrations::Source
15
22
  else
16
23
  conn = create_connection(connection_config)
17
24
  path = build_path(connection_config)
18
- get_results(conn, "DESCRIBE SELECT * FROM '#{path}';")
25
+ get_results(conn, describe_query(path))
19
26
  end
20
27
  ConnectionStatus.new(status: ConnectionStatusType["succeeded"]).to_multiwoven_message
21
28
  rescue StandardError => e
@@ -32,7 +39,7 @@ module Multiwoven::Integrations::Source
32
39
  conn = create_connection(connection_config)
33
40
  # If pulling from multiple files, all files must have the same schema
34
41
  path = build_path(connection_config)
35
- records = get_results(conn, "DESCRIBE SELECT * FROM '#{path}';")
42
+ records = get_results(conn, describe_query(path))
36
43
  columns = build_discover_columns(records)
37
44
  [Multiwoven::Integrations::Protocol::Stream.new(name: path, action: StreamAction["fetch"], json_schema: convert_to_json_schema(columns))]
38
45
  end
@@ -64,22 +71,15 @@ module Multiwoven::Integrations::Source
64
71
  private
65
72
 
66
73
  def get_auth_data(connection_config)
67
- session = @session_name.gsub(/\s+/, "-")
68
74
  @session_name = ""
69
- if connection_config[:auth_type] == "user"
75
+
76
+ case connection_config[:auth_type].to_s
77
+ when "user"
70
78
  aws_credentials(connection_config[:access_id], connection_config[:secret_access])
71
- elsif connection_config[:auth_type] == "role"
72
- sts_client = Aws::STS::Client.new(region: connection_config[:region])
73
- resp = sts_client.assume_role({
74
- role_arn: connection_config[:arn],
75
- role_session_name: session,
76
- external_id: connection_config[:external_id]
77
- })
78
- Aws::Credentials.new(
79
- resp.credentials.access_key_id,
80
- resp.credentials.secret_access_key,
81
- resp.credentials.session_token
82
- )
79
+ when "role"
80
+ raise ArgumentError, ROLE_AUTH_DISABLED_ERROR
81
+ else
82
+ raise ArgumentError, UNSUPPORTED_AUTH_TYPE_ERROR
83
83
  end
84
84
  end
85
85
 
@@ -90,13 +90,11 @@ module Multiwoven::Integrations::Source
90
90
 
91
91
  def create_s3_connection(connection_config)
92
92
  connection_config = connection_config.with_indifferent_access
93
-
94
- # Get authentication credentials
93
+ region = Multiwoven::Integrations::Core::DuckdbLockdown.s3_region(connection_config[:region])
95
94
  auth_data = get_auth_data(connection_config)
96
95
 
97
- # Build client options; use custom endpoint when provided (e.g. MinIO)
98
96
  s3_options = {
99
- region: connection_config[:region],
97
+ region: region,
100
98
  credentials: auth_data
101
99
  }
102
100
  endpoint = connection_config[:endpoint].to_s.strip
@@ -157,9 +155,34 @@ module Multiwoven::Integrations::Source
157
155
  end
158
156
 
159
157
  def build_path(connection_config)
160
- path = connection_config[:path]
161
- path = "#{path}/" if path.to_s.strip.empty? || path[-1] != "/"
162
- "s3://#{connection_config[:bucket]}#{path}*.#{connection_config[:file_type]}"
158
+ bucket = connection_config[:bucket].to_s
159
+ raise ArgumentError, INVALID_S3_PATH_ERROR unless bucket.match?(Multiwoven::Integrations::Core::DuckdbLockdown::S3_BUCKET_NAME)
160
+
161
+ file_type = connection_config[:file_type].to_s
162
+ raise ArgumentError, INVALID_S3_PATH_ERROR unless file_type.match?(S3_FILE_TYPE)
163
+
164
+ path = sanitize_s3_path(connection_config[:path])
165
+ "s3://#{bucket}#{path}*.#{file_type}"
166
+ end
167
+
168
+ def sanitize_s3_path(raw_path)
169
+ path = raw_path.to_s
170
+ raise ArgumentError, INVALID_S3_PATH_ERROR if invalid_s3_path_characters?(path)
171
+ return "/" if path.strip.empty?
172
+
173
+ normalized = path.start_with?("/") ? path : "/#{path}"
174
+ normalized = "#{normalized}/" unless normalized.end_with?("/")
175
+ raise ArgumentError, INVALID_S3_PATH_ERROR if normalized.split("/").include?("..")
176
+
177
+ normalized
178
+ end
179
+
180
+ def invalid_s3_path_characters?(path)
181
+ path.match?(FORBIDDEN_S3_PATH_CHARACTERS) || path.match?(Multiwoven::Integrations::Core::DuckdbLockdown::URL_QUERY_MARKER)
182
+ end
183
+
184
+ def describe_query(path)
185
+ "DESCRIBE SELECT * FROM '#{path.gsub("'", "''")}';"
163
186
  end
164
187
 
165
188
  def get_results(conn, query)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiwoven-integrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.17
4
+ version: 0.43.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Subin T P