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 +4 -4
- data/CHANGELOG.md +9 -0
- data/lib/multiwoven/integrations/rollout.rb +1 -1
- data/lib/multiwoven/integrations/source/amazon_s3/client.rb +46 -23
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2997158adce499f5c945f7ad01ccfc1292485eea66ccbe9997c82c968c1ba22f
|
|
4
|
+
data.tar.gz: 572556b6bfc2fd91967062a063a3b917afd0bae4cde3ef7b5f79da61cc62648e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
|
@@ -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,
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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:
|
|
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
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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)
|