huginn_http_observatory_mozilla_agent 0.4 → 0.5.2

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: e32f5a0a1c249676baa90180f68c2266b196876b9c1afd75d07199b673f4c1fa
4
- data.tar.gz: c7ba877f8d755c2706f9123e8eabc72613b16aab8d439a45cee709f41fb7af13
3
+ metadata.gz: 9171d8529cece1828437a51e89fd73a040086f4ea56ac179a98b05b933f171d8
4
+ data.tar.gz: 1abeb84b9c95e121a01bb51c9c441a4f1560a3baf42445626e23e3d85f024589
5
5
  SHA512:
6
- metadata.gz: 688407826acfffb54e203ae553e6ec190535cf37d1ba89a27e13523655725eadfa5328c995f5328061b8347bcc7a76bb57dca652f2f407a31d528ee08492d30a
7
- data.tar.gz: e749a0198815cc406963a797bbcc6a113be929b8ec969f2e21fe7e3c1b0827ee2040c2014ce34b57889572eda3c2476d10668dd75d4d07c5278cd78ed3b3dc13
6
+ metadata.gz: dd3a1cb5cc4854013121d744d1e3aa84c25348fb3d1451bb169ff160c9d8ad914b42a358b3e318d8461b1f1f050022b53ddc8596d6c252fbf8138534ca9fbb7d
7
+ data.tar.gz: 4d4078a374857e5a1a318cda7e7caa899d9119a4e8059b44c529b204c3cff0523afb7bdc31056b321d3e2ad7d957513cfe1e08b8001056bcab9cdae34c6fa7a9
@@ -11,10 +11,6 @@ module Agents
11
11
 
12
12
  `site` wanted hostname.
13
13
 
14
- `hidden` setting to "true" will hide a scan from public results returned by getRecentScans.
15
-
16
- `rescan` setting to "true" forces a rescan of a site.
17
-
18
14
  `debug` is used to verbose mode.
19
15
 
20
16
  `expected_receive_period_in_days` is used to determine if the Agent is working. Set it to the maximum number of days
@@ -26,37 +22,17 @@ module Agents
26
22
  Events look like this:
27
23
 
28
24
  {
29
- "algorithm_version": 2,
30
- "end_time": "Wed, 15 Jun 2022 19:07:19 GMT",
31
- "grade": "B-",
32
- "hidden": false,
33
- "likelihood_indicator": "MEDIUM",
34
- "response_headers": {
35
- "Cache-Control": "max-age=0, private, must-revalidate",
36
- "Content-Type": "text/html; charset=utf-8",
37
- "Date": "Wed, 15 Jun 2022 19:07:17 GMT",
38
- "Etag": "W/\"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"",
39
- "Referrer-Policy": "strict-origin-when-cross-origin",
40
- "Set-Cookie": "_rails_session=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX; path=/; HttpOnly",
41
- "Strict-Transport-Security": "max-age=63072000; includeSubDomains",
42
- "Transfer-Encoding": "chunked",
43
- "Vary": "Origin",
44
- "X-Content-Type-Options": "nosniff",
45
- "X-Download-Options": "noopen",
46
- "X-Frame-Options": "DENY",
47
- "X-Permitted-Cross-Domain-Policies": "none",
48
- "X-Request-Id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
49
- "X-Runtime": "0.011662",
50
- "X-Xss-Protection": "1; mode=block"
51
- },
52
- "scan_id": 27190361,
53
- "score": 65,
54
- "start_time": "Wed, 15 Jun 2022 19:07:15 GMT",
55
- "state": "FINISHED",
56
- "status_code": 200,
57
- "tests_failed": 2,
58
- "tests_passed": 10,
59
- "tests_quantity": 12
25
+ "id": 53621004,
26
+ "details_url": "https://developer.mozilla.org/en-US/observatory/analyze?host=callistodao.org",
27
+ "algorithm_version": 4,
28
+ "scanned_at": "2024-10-22T22:53:21.572Z",
29
+ "error": null,
30
+ "grade": "D",
31
+ "score": 30,
32
+ "status_code": 200,
33
+ "tests_failed": 4,
34
+ "tests_passed": 6,
35
+ "tests_quantity": 10
60
36
  }
61
37
  MD
62
38
 
@@ -74,8 +50,6 @@ module Agents
74
50
  form_configurable :site, type: :string
75
51
  form_configurable :changes_only, type: :boolean
76
52
  form_configurable :debug, type: :boolean
77
- form_configurable :hidden, type: :boolean
78
- form_configurable :rescan, type: :boolean
79
53
 
80
54
  def validate_options
81
55
  if options.has_key?('changes_only') && boolify(options['changes_only']).nil?
@@ -89,14 +63,6 @@ module Agents
89
63
  unless options['expected_receive_period_in_days'].present? && options['expected_receive_period_in_days'].to_i > 0
90
64
  errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working")
91
65
  end
92
-
93
- if options.has_key?('hidden') && boolify(options['hidden']).nil?
94
- errors.add(:base, "if provided, hidden must be true or false")
95
- end
96
-
97
- if options.has_key?('rescan') && boolify(options['rescan']).nil?
98
- errors.add(:base, "if provided, rescan must be true or false")
99
- end
100
66
  end
101
67
 
102
68
  def working?
@@ -110,7 +76,7 @@ module Agents
110
76
  private
111
77
 
112
78
  def check_site()
113
- uri = URI.parse("https://http-observatory.security.mozilla.org/api/v1/analyze?host=#{interpolated['site']}&hidden=#{interpolated['hidden']}&rescan=#{interpolated['rescan']}")
79
+ uri = URI.parse("https://observatory-api.mdn.mozilla.net/api/v2/scan?host=#{interpolated['site']}")
114
80
  request = Net::HTTP::Post.new(uri)
115
81
 
116
82
  req_options = {
@@ -139,31 +105,32 @@ module Agents
139
105
  def check_status()
140
106
  payload = check_site()
141
107
  if interpolated['debug'] == 'true'
142
- log payload['state']
108
+ log payload['status_code']
143
109
  end
144
- if payload['state'] == 'PENDING'
110
+ while payload['status_code'] != 200
145
111
  sleep(30)
146
112
  payload = check_site()
147
113
  end
148
114
  if interpolated['changes_only'] == 'true'
149
- if payload.to_s != memory['last_status']
115
+ if payload != memory['last_status']
150
116
  if !memory['last_status'].nil?
151
- last_status = memory['last_status'].gsub("=>", ": ").gsub(": nil", ": null")
152
- last_status = JSON.parse(last_status)
117
+ last_status = memory['last_status']
153
118
  if payload['score'] != last_status['score'] && payload['status_code'] == 200
154
119
  create_event payload: payload
120
+ else
121
+ log "no diff"
155
122
  end
156
123
  else
157
124
  if payload['status_code'] == 200
158
125
  create_event payload: payload
159
126
  end
160
127
  end
161
- memory['last_status'] = payload.to_s
128
+ memory['last_status'] = payload
162
129
  end
163
130
  else
164
131
  create_event payload: payload
165
132
  if payload.to_s != memory['last_status']
166
- memory['last_status'] = payload.to_s
133
+ memory['last_status'] = payload
167
134
  end
168
135
  end
169
136
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: huginn_http_observatory_mozilla_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Germain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-12 00:00:00.000000000 Z
11
+ date: 2024-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  requirements: []
85
- rubygems_version: 3.1.6
85
+ rubygems_version: 3.3.3
86
86
  signing_key:
87
87
  specification_version: 4
88
88
  summary: Write a short summary, because Rubygems requires one.