cronwatch 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 17442875e05c9f99c45cbba2f547fcd0e3233c30962b2825c03f5b0470c18aae
4
- data.tar.gz: '065965f32d1b1a2ada5c9344928de83683d98a5b178d174cc44f795d80eb9efa'
3
+ metadata.gz: ce9304826bfc7f8e79615453ee7b5c25503d3dbd7d8b803c229152b3e3c93844
4
+ data.tar.gz: ef0e084ae833b0e57f2dd997fa500ca43c6dfcddd65730265e166d7c227f00d5
5
5
  SHA512:
6
- metadata.gz: 54d7a578558f41e1efebd3dec812f997a5e052ae96ecf479b45a45e51b95316c71c892aacc7349d44931b0318135c2955a28f54f74b0c6d6ce7d26de7499b346
7
- data.tar.gz: 8477df64cd3c969adf84ebf657c5f3d605616be348dc207926f59923ae2d14edfc727bd90d3a2388e1c6a89818160070cf71b1891af290cc1264b785a91808a0
6
+ metadata.gz: 23c832ba7e7ff1e34ca6930f3b9eb7785f6175db5bfec6ef731495f695a16454ea63e0fb474dd305771f33eed145d3ab41fa762ea40baafb8187254c8b1099d5
7
+ data.tar.gz: bdaac367aac5c069fd6c3c3c38117e40c1afa7f073d5cb95c2c56c0a97efa58a0fabe86b1640905d2d01ec44cef44ae78aaff45d03cc4fe9dd9e381295e44d57
@@ -38,7 +38,7 @@ module Cronwatch
38
38
  end
39
39
 
40
40
  def self.origin(url)
41
- uri = URI(url)
41
+ uri = URI(HTTP.clean_url(url))
42
42
  raise URI::InvalidURIError unless uri.scheme && uri.host
43
43
 
44
44
  port = uri.port && uri.port != uri.default_port ? ":#{uri.port}" : ""
@@ -34,7 +34,7 @@ module Cronwatch
34
34
  # past it while the body is still arriving, returns the answer with an
35
35
  # empty body, as the SDK's channels treat a body they could not read.
36
36
  def post(url, body, headers)
37
- uri = URI(url)
37
+ uri = HTTP.postable(url)
38
38
  deadline = HTTP.monotonic + @timeout
39
39
  request = Net::HTTP::Post.new(uri.request_uri)
40
40
  headers.each { |k, v| request[k] = HTTP.trim_header(v) }
@@ -96,6 +96,30 @@ module Cronwatch
96
96
  [deadline - monotonic, 0.001].max
97
97
  end
98
98
 
99
+ # A URL as fetch reads it: the spaces and control characters around it,
100
+ # and any tab or line break inside it, dropped (a pasted webhook URL often
101
+ # ends in a newline).
102
+ def clean_url(url)
103
+ url.to_s.gsub(/\A[\u0000-\u0020]+|[\u0000-\u0020]+\z/, "").delete("\t\n\r")
104
+ end
105
+
106
+ # The URL parsed, once it is one a channel can post to. Refused without
107
+ # quoting it: URI's own errors quote the whole URL, and a webhook URL's
108
+ # path is its credential.
109
+ def postable(url)
110
+ uri = begin
111
+ URI(clean_url(url))
112
+ rescue URI::Error, ArgumentError
113
+ nil
114
+ end
115
+ scheme = uri&.scheme&.downcase
116
+ unless %w[http https].include?(scheme) && uri.host && !uri.host.empty?
117
+ shown = uri&.scheme && uri.host ? "#{scheme}:" : "this URL"
118
+ raise ArgumentError, "only http and https URLs can be posted to, not #{shown}"
119
+ end
120
+ uri
121
+ end
122
+
99
123
  # A header value without the spaces, tabs and line breaks around it, as fetch sends it.
100
124
  def trim_header(value)
101
125
  value.to_s.gsub(/\A[ \t\r\n]+|[ \t\r\n]+\z/, "")
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Cronwatch
4
4
  # Kept in step with @cronwatch/sdk.
5
- VERSION = "0.5.0"
5
+ VERSION = "0.5.1"
6
6
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cronwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon C. Phillips
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-09-28 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: fugit
@@ -27,7 +26,6 @@ dependencies:
27
26
  description: 'Wrap a job, run a check, get told when it is missed, failed, stuck,
28
27
  slow or over budget. The Ruby port of @cronwatch/sdk: same rules, same alerts, same
29
28
  stored rows.'
30
- email:
31
29
  executables: []
32
30
  extensions: []
33
31
  extra_rdoc_files: []
@@ -107,7 +105,6 @@ metadata:
107
105
  bug_tracker_uri: https://github.com/phillips-jon/cronwatch/issues
108
106
  documentation_uri: https://cronwatch.dev/docs/ruby/
109
107
  rubygems_mfa_required: 'true'
110
- post_install_message:
111
108
  rdoc_options: []
112
109
  require_paths:
113
110
  - lib
@@ -122,8 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
119
  - !ruby/object:Gem::Version
123
120
  version: '0'
124
121
  requirements: []
125
- rubygems_version: 3.0.3.1
126
- signing_key:
122
+ rubygems_version: 3.6.9
127
123
  specification_version: 4
128
124
  summary: Cron and scheduled-job monitoring that lives inside your app.
129
125
  test_files: []