waha-ruby 0.1.0 → 0.1.1
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/.rubocop.yml +2 -2
- data/CHANGELOG.md +14 -0
- data/lib/waha/resources/media.rb +11 -3
- data/lib/waha/resources/webhooks.rb +1 -1
- data/lib/waha/support.rb +1 -1
- data/lib/waha/version.rb +1 -1
- data/lib/waha/webhook.rb +5 -14
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6143fc09b5ea2bfb45b55cba490a5b2f4b2527800991e8207f9f838c363998f
|
|
4
|
+
data.tar.gz: e740e63e91ffadba7ee5919d36722f973847c86818c244753535f98dca9cd70d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63f59ffd2b58f82e9ca8e925b5e8c07958e8e508f12a1df49c73cc9ffaf3311b7be6546632d988b987ac35cd11169bfe9effd2896642763a371501a6e04a2462
|
|
7
|
+
data.tar.gz: 4dee276f3bbfbb301a9f4beaa499c92e0bbba61ada941acef1487bcbe041539f21746f071679b8359044bb11d97a8761905ff06d37cc5b64cf3353b8001f39ec
|
data/.rubocop.yml
CHANGED
|
@@ -30,12 +30,12 @@ Metrics/ClassLength:
|
|
|
30
30
|
Metrics/ParameterLists:
|
|
31
31
|
Exclude:
|
|
32
32
|
- "lib/waha/resources/messages.rb"
|
|
33
|
-
- "lib/waha/transport/
|
|
33
|
+
- "lib/waha/transport/faraday.rb"
|
|
34
34
|
|
|
35
35
|
Metrics/AbcSize:
|
|
36
36
|
Exclude:
|
|
37
37
|
- "lib/waha/resources/messages.rb"
|
|
38
|
-
- "lib/waha/transport/
|
|
38
|
+
- "lib/waha/transport/faraday.rb"
|
|
39
39
|
|
|
40
40
|
Layout/LineLength:
|
|
41
41
|
Exclude:
|
data/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,20 @@ and this project adheres to
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- `Waha::Webhook.verify!` fails closed when the secret is nil, empty, or
|
|
14
|
+
blank, preventing signature forgery against unconfigured consumers.
|
|
15
|
+
- Webhook comparison delegates to `OpenSSL.secure_compare` for native
|
|
16
|
+
constant-time comparison.
|
|
17
|
+
- `Waha::Resources::Media#download` only accepts media URLs served by the
|
|
18
|
+
configured WAHA host; all loopback origins (`localhost`, `127.0.0.1`,
|
|
19
|
+
`::1`) rebase to the base URL, closing an SSRF and API-key exfiltration
|
|
20
|
+
vector.
|
|
21
|
+
- `Waha::Resources::Webhooks` deep duplication uses identity-based
|
|
22
|
+
memoization so value-equal config entries no longer alias each other.
|
|
23
|
+
- Chats message query keyword `last_message_id` maps to `lastMessageId`.
|
|
24
|
+
|
|
11
25
|
## [0.1.0] - 2026-09-09
|
|
12
26
|
|
|
13
27
|
### Added
|
data/lib/waha/resources/media.rb
CHANGED
|
@@ -6,6 +6,7 @@ module Waha
|
|
|
6
6
|
module Resources
|
|
7
7
|
class Media < Resource
|
|
8
8
|
DOWNLOAD_TIMEOUT = 60
|
|
9
|
+
LOOPBACK_HOSTS = %w[localhost 127.0.0.1 ::1].freeze
|
|
9
10
|
|
|
10
11
|
def initialize(transport:, base_url:)
|
|
11
12
|
super(transport:, session: nil)
|
|
@@ -36,19 +37,26 @@ module Waha
|
|
|
36
37
|
raise ValidationError.new(operation: "download_media", details: "unsupported media URL scheme")
|
|
37
38
|
end
|
|
38
39
|
|
|
39
|
-
return uri
|
|
40
|
+
return rebase_to_base_url(uri) if LOOPBACK_HOSTS.include?(uri.host)
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
unless uri.host == base_uri.host
|
|
43
|
+
raise ValidationError.new(operation: "download_media", details: "media URL host is not the WAHA server")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
uri.to_s
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
def rebase_to_base_url(uri)
|
|
45
|
-
base_uri = URI.parse(@base_url)
|
|
46
50
|
uri.scheme = base_uri.scheme
|
|
47
51
|
uri.host = base_uri.host
|
|
48
52
|
uri.port = base_uri.port
|
|
49
53
|
uri.to_s
|
|
50
54
|
end
|
|
51
55
|
|
|
56
|
+
def base_uri
|
|
57
|
+
@base_uri ||= URI.parse(@base_url.to_s)
|
|
58
|
+
end
|
|
59
|
+
|
|
52
60
|
def parse_uri(url)
|
|
53
61
|
text = url.to_s
|
|
54
62
|
uri = URI.parse(text)
|
|
@@ -63,7 +63,7 @@ module Waha
|
|
|
63
63
|
Support.value(session_data, "name") || fallback
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
def deep_dup(value, seen = {})
|
|
66
|
+
def deep_dup(value, seen = {}.compare_by_identity)
|
|
67
67
|
return value unless value.is_a?(Hash) || value.is_a?(Array)
|
|
68
68
|
return seen[value] if seen.key?(value)
|
|
69
69
|
|
data/lib/waha/support.rb
CHANGED
data/lib/waha/version.rb
CHANGED
data/lib/waha/webhook.rb
CHANGED
|
@@ -9,10 +9,14 @@ module Waha
|
|
|
9
9
|
module_function
|
|
10
10
|
|
|
11
11
|
def verify!(body:, signature:, algorithm:, secret:)
|
|
12
|
+
if secret.to_s.strip.empty?
|
|
13
|
+
raise VerificationError.new(operation: "verify_webhook", details: "secret is required")
|
|
14
|
+
end
|
|
15
|
+
|
|
12
16
|
verify_algorithm!(algorithm)
|
|
13
17
|
signature_text = verified_signature_text(signature)
|
|
14
18
|
expected = OpenSSL::HMAC.hexdigest(DIGEST, secret.to_s, body.to_s)
|
|
15
|
-
return true if secure_compare
|
|
19
|
+
return true if OpenSSL.secure_compare(signature_text, expected)
|
|
16
20
|
|
|
17
21
|
raise VerificationError.new(operation: "verify_webhook", details: "signature mismatch")
|
|
18
22
|
end
|
|
@@ -32,18 +36,5 @@ module Waha
|
|
|
32
36
|
raise VerificationError.new(operation: "verify_webhook", details: "malformed signature")
|
|
33
37
|
end
|
|
34
38
|
private_class_method :verified_signature_text
|
|
35
|
-
|
|
36
|
-
def secure_compare?(signature, expected)
|
|
37
|
-
signature.bytesize == expected.bytesize && secure_bytes_equal?(signature, expected)
|
|
38
|
-
end
|
|
39
|
-
private_class_method :secure_compare?
|
|
40
|
-
|
|
41
|
-
def secure_bytes_equal?(left, right)
|
|
42
|
-
left_bytes = left.unpack("C*")
|
|
43
|
-
right_bytes = right.unpack("C*")
|
|
44
|
-
comparison = left_bytes.zip(right_bytes).reduce(0) { |result, pair| result | (pair[0] ^ pair[1]) }
|
|
45
|
-
comparison.zero?
|
|
46
|
-
end
|
|
47
|
-
private_class_method :secure_bytes_equal?
|
|
48
39
|
end
|
|
49
40
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: waha-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mauricio Zaffari
|
|
@@ -251,7 +251,7 @@ licenses:
|
|
|
251
251
|
- MIT
|
|
252
252
|
metadata:
|
|
253
253
|
homepage_uri: https://github.com/develoz-com/waha-ruby
|
|
254
|
-
source_code_uri: https://github.com/develoz-com/waha-ruby/tree/v0.1.
|
|
254
|
+
source_code_uri: https://github.com/develoz-com/waha-ruby/tree/v0.1.1
|
|
255
255
|
changelog_uri: https://github.com/develoz-com/waha-ruby/blob/main/CHANGELOG.md
|
|
256
256
|
rubygems_mfa_required: 'true'
|
|
257
257
|
rdoc_options: []
|