visionary-sdk 0.9.0 → 0.10.0
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/LICENSE +207 -201
- data/README.md +22 -0
- data/lib/visionary/context.rb +10 -0
- data/lib/visionary/middleware.rb +1 -1
- data/lib/visionary/schema/mysql/requests.sql +2 -1
- data/lib/visionary/schema/postgres/requests.sql +2 -1
- data/lib/visionary/schema/sqlite/requests.sql +2 -1
- data/lib/visionary/schema.rb +2 -1
- data/lib/visionary/version.rb +1 -1
- data/lib/visionary/writer.rb +8 -2
- data/lib/visionary.rb +11 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7630e61ac28975c342c573744fcf10efc46da8ba67458ff32ba0a647754254c
|
|
4
|
+
data.tar.gz: 0de62f0a84b32998b74933fabbd1ec69bb70ca358e0e43c974c86dad73e7cac8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9463fc0d7556b2282704f0ea61a7459443672bf80fd176e2753c3e2116f661d823d5b5a28d8da786f3071d9ce4085e27cc59453133a6784de819079b3c9af982
|
|
7
|
+
data.tar.gz: c714e4b18951537ef203db2d7cf25d56f295508bba15a0ef60b58b2969d3d341e7868e0f059987f3e0d206f39b3f80e92351c5a8d335ebb76937db662a945bf0
|
data/LICENSE
CHANGED
|
@@ -1,202 +1,208 @@
|
|
|
1
|
+
Visionary Non-Commercial License (VNCL) v1.0
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
3
|
+
Copyright (c) 2026 Saurav Sajeev. All rights reserved, except as expressly
|
|
4
|
+
permitted below.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
1. Definitions
|
|
8
|
+
|
|
9
|
+
"Software" means Visionary, including its source code, object code, server,
|
|
10
|
+
host agent, SDKs, libraries, documentation, and associated materials
|
|
11
|
+
distributed under this License.
|
|
12
|
+
|
|
13
|
+
"Author" means Saurav Sajeev, the original author and copyright holder of the
|
|
14
|
+
Software, to the extent of their ownership of the relevant material.
|
|
15
|
+
|
|
16
|
+
"Commercial Use" means using the Software, in whole or in part, to sell,
|
|
17
|
+
license, sublicense, rent, lease, monetize, commercially distribute, or provide
|
|
18
|
+
a paid product or service. It also includes offering the Software as a hosted
|
|
19
|
+
service to third parties for compensation, or incorporating it into a product
|
|
20
|
+
or service distributed commercially.
|
|
21
|
+
|
|
22
|
+
"Redistribution" means making the Software, or a modified or derivative version
|
|
23
|
+
of it, available to another person or entity by distribution, publication,
|
|
24
|
+
hosting for download, sublicensing, or other transfer.
|
|
25
|
+
|
|
26
|
+
"Internal Use" means use by an individual or an organization solely for its
|
|
27
|
+
own internal operations, without providing the Software or its functionality
|
|
28
|
+
as a product or service to external customers or third parties.
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
2. Grant of Permission
|
|
32
|
+
|
|
33
|
+
Subject to the terms of this License, the Author grants you a limited,
|
|
34
|
+
worldwide, non-exclusive, royalty-free, revocable only as permitted by
|
|
35
|
+
applicable law, and non-transferable license to:
|
|
36
|
+
|
|
37
|
+
a. Access, view, and study the Software's source code.
|
|
38
|
+
|
|
39
|
+
b. Download and run the Software for personal, non-commercial purposes.
|
|
40
|
+
|
|
41
|
+
c. Install and deploy the Software in development, testing, staging, and
|
|
42
|
+
production environments for Internal Use.
|
|
43
|
+
|
|
44
|
+
d. Modify the Software for personal use or Internal Use, including within
|
|
45
|
+
commercial organizations, provided such modifications are not
|
|
46
|
+
redistributed or commercially exploited.
|
|
47
|
+
|
|
48
|
+
e. Make reasonable backup copies for permitted use.
|
|
49
|
+
|
|
50
|
+
These permissions do not transfer ownership of the Software or grant any rights
|
|
51
|
+
beyond those expressly stated in this License.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
3. Non-Commercial Restriction
|
|
55
|
+
|
|
56
|
+
You must not, without the Author's prior written permission:
|
|
57
|
+
|
|
58
|
+
a. Sell, license, sublicense, rent, lease, or otherwise commercially exploit
|
|
59
|
+
the Software.
|
|
60
|
+
|
|
61
|
+
b. Offer the Software or a modified version as a paid product, subscription,
|
|
62
|
+
managed service, or hosted monitoring service.
|
|
63
|
+
|
|
64
|
+
c. Incorporate the Software or a substantial portion of it into a product or
|
|
65
|
+
service that is sold, licensed, distributed, or otherwise commercially
|
|
66
|
+
offered to third parties.
|
|
67
|
+
|
|
68
|
+
d. Use the Software to provide monitoring, observability, analytics, or other
|
|
69
|
+
functionality to external customers as a commercial service.
|
|
70
|
+
|
|
71
|
+
e. Monetize access to the Software or charge third parties for access to its
|
|
72
|
+
functionality.
|
|
73
|
+
|
|
74
|
+
Internal production use by a commercial organization is permitted under
|
|
75
|
+
Section 2, provided that the organization does not commercially exploit or
|
|
76
|
+
redistribute the Software in a manner prohibited by this License.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
4. Redistribution and Publication
|
|
80
|
+
|
|
81
|
+
Without the Author's prior written permission, you must not:
|
|
82
|
+
|
|
83
|
+
a. Redistribute or republish the original Software, in source or binary
|
|
84
|
+
form.
|
|
85
|
+
|
|
86
|
+
b. Publish, distribute, or make publicly available a modified version, fork,
|
|
87
|
+
or derivative work of the Software.
|
|
88
|
+
|
|
89
|
+
c. Upload the Software or modified versions to public package registries,
|
|
90
|
+
software marketplaces, application stores, repositories, or download
|
|
91
|
+
platforms for redistribution.
|
|
92
|
+
|
|
93
|
+
d. Sublicense, transfer, or grant others rights to use the Software beyond
|
|
94
|
+
the permissions expressly provided in this License.
|
|
95
|
+
|
|
96
|
+
e. Remove or misrepresent the Software's authorship, copyright notices, or
|
|
97
|
+
license information.
|
|
98
|
+
|
|
99
|
+
Private modifications and internal deployments permitted by Section 2 are not
|
|
100
|
+
prohibited merely because they exist within a commercial organization's
|
|
101
|
+
infrastructure.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
5. Commercial Licensing
|
|
105
|
+
|
|
106
|
+
The Author may separately grant commercial licenses, redistribution rights, or
|
|
107
|
+
other permissions under different terms.
|
|
108
|
+
|
|
109
|
+
Anyone wishing to sell, redistribute, sublicense, incorporate, or commercially
|
|
110
|
+
exploit the Software beyond the permissions granted here must obtain prior
|
|
111
|
+
written authorization from the Author.
|
|
112
|
+
|
|
113
|
+
A separate commercial agreement may specify fees, attribution requirements,
|
|
114
|
+
support terms, distribution rights, and other conditions.
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
6. Ownership and Intellectual Property
|
|
118
|
+
|
|
119
|
+
The Software remains the property of its respective copyright holders.
|
|
120
|
+
|
|
121
|
+
This License does not transfer ownership of the Software, its name, branding,
|
|
122
|
+
trademarks, or logos. No trademark license is granted except as necessary to
|
|
123
|
+
identify the unmodified Software truthfully.
|
|
124
|
+
|
|
125
|
+
You retain ownership of your independently created contributions to the extent
|
|
126
|
+
provided by applicable law, but this does not grant you permission to
|
|
127
|
+
distribute or commercially exploit the Software or derivative works in
|
|
128
|
+
violation of this License.
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
7. Third-Party Components
|
|
132
|
+
|
|
133
|
+
This License applies only to material the Author has the legal right to
|
|
134
|
+
license under these terms.
|
|
135
|
+
|
|
136
|
+
Third-party components, dependencies, and contributions remain subject to their
|
|
137
|
+
respective licenses. Where another license grants rights that cannot legally
|
|
138
|
+
be restricted by this License, those rights remain unaffected.
|
|
139
|
+
|
|
140
|
+
You are responsible for complying with applicable third-party license
|
|
141
|
+
obligations when using or distributing such components.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
8. Termination
|
|
145
|
+
|
|
146
|
+
Your permissions under this License terminate automatically if you materially
|
|
147
|
+
violate its terms.
|
|
148
|
+
|
|
149
|
+
Upon termination, you must cease activities that are no longer authorized by
|
|
150
|
+
this License, including prohibited redistribution or commercial exploitation,
|
|
151
|
+
subject to any rights or remedies provided by applicable law.
|
|
152
|
+
|
|
153
|
+
Permissions may be reinstated by the Author in writing.
|
|
154
|
+
|
|
155
|
+
Termination does not eliminate rights that applicable law makes irrevocable,
|
|
156
|
+
nor does it automatically revoke separate licenses granted by third-party
|
|
157
|
+
copyright holders.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
9. Disclaimer of Warranty
|
|
161
|
+
|
|
162
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
163
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
164
|
+
FOR A PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT.
|
|
165
|
+
|
|
166
|
+
YOU ASSUME ALL RISKS ARISING FROM THE USE OF THE SOFTWARE, TO THE MAXIMUM
|
|
167
|
+
EXTENT PERMITTED BY APPLICABLE LAW.
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
10. Limitation of Liability
|
|
171
|
+
|
|
172
|
+
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THE AUTHOR SHALL NOT BE
|
|
173
|
+
LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT,
|
|
174
|
+
OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR ITS
|
|
175
|
+
USE, DISTRIBUTION, OR OTHER DEALINGS.
|
|
176
|
+
|
|
177
|
+
Nothing in this License excludes liability that cannot lawfully be excluded
|
|
178
|
+
under applicable law.
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
11. No Additional Rights
|
|
182
|
+
|
|
183
|
+
No rights are granted by implication, estoppel, or otherwise beyond those
|
|
184
|
+
expressly stated in this License.
|
|
185
|
+
|
|
186
|
+
Any use, distribution, or commercialization not expressly permitted requires
|
|
187
|
+
the Author's prior written permission, unless applicable law provides
|
|
188
|
+
otherwise.
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
12. Governing Law
|
|
192
|
+
|
|
193
|
+
The governing law and jurisdiction applicable to this License shall be
|
|
194
|
+
determined by a separate written agreement between the relevant parties or, in
|
|
195
|
+
the absence of such an agreement, by applicable law and conflict-of-law rules.
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
13. Entire Agreement
|
|
199
|
+
|
|
200
|
+
This License governs the permissions granted by the Author for the Software
|
|
201
|
+
covered by it. If any provision is held unenforceable, the remaining provisions
|
|
202
|
+
shall continue to apply to the extent permitted by law.
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
License: Visionary Non-Commercial License (VNCL) v1.0
|
|
206
|
+
Copyright holder: Saurav Sajeev
|
|
207
|
+
Project: Visionary
|
|
208
|
+
Commercial licensing: Requires separate written authorization.
|
data/README.md
CHANGED
|
@@ -158,6 +158,27 @@ handle or role.
|
|
|
158
158
|
**Records:** `user_id`, `user_handle`, `user_role` on the request row and on
|
|
159
159
|
its errors.
|
|
160
160
|
|
|
161
|
+
### Record login attempts
|
|
162
|
+
|
|
163
|
+
**When:** you want the security detectors to spot one IP trying many
|
|
164
|
+
accounts, many IPs trying one account, or a signed-in user trying someone
|
|
165
|
+
else's.
|
|
166
|
+
|
|
167
|
+
```ruby
|
|
168
|
+
# Rails: app/controllers/sessions_controller.rb
|
|
169
|
+
def create
|
|
170
|
+
Visionary.login_attempt(params[:email])
|
|
171
|
+
user = User.authenticate_by(email: params[:email], password: params[:password])
|
|
172
|
+
user ? sign_in(user) : head(:unauthorized)
|
|
173
|
+
end
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Call it in the login handler with the username or email typed, whether or
|
|
177
|
+
not it exists or the password was right. The value is trimmed and clipped to
|
|
178
|
+
255 characters. No-op outside a request seen by the middleware.
|
|
179
|
+
|
|
180
|
+
**Records:** `login_account` on the request row.
|
|
181
|
+
|
|
161
182
|
### Database queries (ActiveRecord)
|
|
162
183
|
|
|
163
184
|
**When:** the app uses ActiveRecord (Rails or standalone). Nothing to add.
|
|
@@ -573,6 +594,7 @@ samples of runnable threads:
|
|
|
573
594
|
```ruby
|
|
574
595
|
Visionary.set_user(id, handle: nil, role: nil) # the signed-in user of the current request
|
|
575
596
|
Visionary.set_route("/users/:id") # route pattern, for routers Visionary can't see
|
|
597
|
+
Visionary.login_attempt(params[:email]) # the account a sign-in request tried
|
|
576
598
|
Visionary.span(name, kind: "custom", target: nil, detail: nil) { ... } # a manual span
|
|
577
599
|
Visionary.background(name) { ... } # a thread that stays with the request
|
|
578
600
|
Visionary.capture_exception(e) # a handled error (handled = 1)
|
data/lib/visionary/context.rb
CHANGED
|
@@ -23,6 +23,7 @@ module Visionary
|
|
|
23
23
|
@db_visible = db_visible
|
|
24
24
|
@mutex = Mutex.new
|
|
25
25
|
@user = ["", "", ""]
|
|
26
|
+
@login_account = ""
|
|
26
27
|
@route = ""
|
|
27
28
|
@spans = []
|
|
28
29
|
@errors = []
|
|
@@ -40,6 +41,15 @@ module Visionary
|
|
|
40
41
|
@mutex.synchronize { @user }
|
|
41
42
|
end
|
|
42
43
|
|
|
44
|
+
# The account a sign-in on this request tried (Visionary.login_attempt).
|
|
45
|
+
def login_account=(account)
|
|
46
|
+
@mutex.synchronize { @login_account = account.to_s }
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def login_account
|
|
50
|
+
@mutex.synchronize { @login_account }
|
|
51
|
+
end
|
|
52
|
+
|
|
43
53
|
def route=(pattern)
|
|
44
54
|
@mutex.synchronize { @route = pattern.to_s }
|
|
45
55
|
end
|
data/lib/visionary/middleware.rb
CHANGED
|
@@ -152,7 +152,7 @@ module Visionary
|
|
|
152
152
|
request_id: ctx.request_id, started_at: ctx.started_at, method: ctx.method, path: ctx.path,
|
|
153
153
|
route: route, query: env["QUERY_STRING"].to_s, status: status, duration_ms: duration,
|
|
154
154
|
ip: client_ip(env), user_agent: env["HTTP_USER_AGENT"].to_s,
|
|
155
|
-
user_id: user_id, user_handle: handle, user_role: role, headers: headers,
|
|
155
|
+
user_id: user_id, user_handle: handle, user_role: role, login_account: ctx.login_account, headers: headers,
|
|
156
156
|
request_content_type: env["CONTENT_TYPE"].to_s, request_body: req_capture.bytes,
|
|
157
157
|
request_truncated: req_capture.truncated?,
|
|
158
158
|
request_size: [env["CONTENT_LENGTH"].to_i, req_capture.size].max,
|
|
@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS api_logs (
|
|
|
29
29
|
db_count BIGINT,
|
|
30
30
|
db_ms DOUBLE,
|
|
31
31
|
http_count BIGINT,
|
|
32
|
-
http_ms DOUBLE
|
|
32
|
+
http_ms DOUBLE,
|
|
33
|
+
login_account VARCHAR(255)
|
|
33
34
|
) CHARACTER SET utf8mb4;
|
|
34
35
|
CREATE INDEX idx_api_logs_created_at ON api_logs (created_at);
|
|
35
36
|
CREATE INDEX idx_api_logs_user_created ON api_logs (user_id, created_at);
|
|
@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS api_logs (
|
|
|
29
29
|
db_count BIGINT,
|
|
30
30
|
db_ms DOUBLE PRECISION,
|
|
31
31
|
http_count BIGINT,
|
|
32
|
-
http_ms DOUBLE PRECISION
|
|
32
|
+
http_ms DOUBLE PRECISION,
|
|
33
|
+
login_account TEXT
|
|
33
34
|
);
|
|
34
35
|
CREATE INDEX IF NOT EXISTS idx_api_logs_created_at ON api_logs (created_at);
|
|
35
36
|
CREATE INDEX IF NOT EXISTS idx_api_logs_user_created ON api_logs (user_id, created_at);
|
|
@@ -29,7 +29,8 @@ CREATE TABLE IF NOT EXISTS api_logs (
|
|
|
29
29
|
db_count INTEGER,
|
|
30
30
|
db_ms REAL,
|
|
31
31
|
http_count INTEGER,
|
|
32
|
-
http_ms REAL
|
|
32
|
+
http_ms REAL,
|
|
33
|
+
login_account TEXT
|
|
33
34
|
);
|
|
34
35
|
CREATE INDEX IF NOT EXISTS idx_api_logs_created_at ON api_logs (created_at);
|
|
35
36
|
CREATE INDEX IF NOT EXISTS idx_api_logs_user_created ON api_logs (user_id, created_at);
|
data/lib/visionary/schema.rb
CHANGED
|
@@ -16,7 +16,8 @@ module Visionary
|
|
|
16
16
|
|
|
17
17
|
# api_logs columns added after the first release, in insert order.
|
|
18
18
|
ADDED_REQUEST_COLUMNS = [
|
|
19
|
-
%w[service text], %w[version text], %w[db_count int], %w[db_ms real], %w[http_count int], %w[http_ms real]
|
|
19
|
+
%w[service text], %w[version text], %w[db_count int], %w[db_ms real], %w[http_count int], %w[http_ms real],
|
|
20
|
+
%w[login_account text]
|
|
20
21
|
].freeze
|
|
21
22
|
|
|
22
23
|
SYSTEM_BASE_COLUMNS = %w[
|
data/lib/visionary/version.rb
CHANGED
data/lib/visionary/writer.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Visionary
|
|
|
5
5
|
# user lookup happen on the writer thread, off the request path.
|
|
6
6
|
Entry = Struct.new(
|
|
7
7
|
:request_id, :started_at, :method, :path, :route, :query, :status, :duration_ms, :ip, :user_agent,
|
|
8
|
-
:user_id, :user_handle, :user_role, :headers, :request_content_type, :request_body, :request_truncated,
|
|
8
|
+
:user_id, :user_handle, :user_role, :login_account, :headers, :request_content_type, :request_body, :request_truncated,
|
|
9
9
|
:request_size, :response_content_type, :response_body, :response_truncated, :response_size,
|
|
10
10
|
:totals, :span_rows, :error_rows,
|
|
11
11
|
keyword_init: true
|
|
@@ -180,10 +180,16 @@ module Visionary
|
|
|
180
180
|
e.status, e.duration_ms, nz(e.ip), nz(e.user_agent), nz(e.user_id), nz(handle), nz(role),
|
|
181
181
|
nz(@redactor.headers(e.headers)), nz(e.request_content_type), nz(req_body), e.request_truncated ? 1 : 0,
|
|
182
182
|
e.request_size, nz(e.response_content_type), nz(resp_body), e.response_truncated ? 1 : 0, e.response_size,
|
|
183
|
-
nz(code), nz(key), @cfg.service, @cfg.version, db_count, db_ms, http_count, http_ms
|
|
183
|
+
nz(code), nz(key), @cfg.service, @cfg.version, db_count, db_ms, http_count, http_ms,
|
|
184
|
+
nz(clip_login(e.login_account))
|
|
184
185
|
]
|
|
185
186
|
end
|
|
186
187
|
|
|
188
|
+
# Trims a login identifier to what the column holds.
|
|
189
|
+
def clip_login(s)
|
|
190
|
+
Visionary.utf8(s).strip[0, 255]
|
|
191
|
+
end
|
|
192
|
+
|
|
187
193
|
def nz(s)
|
|
188
194
|
s.nil? || s.empty? ? nil : s
|
|
189
195
|
end
|
data/lib/visionary.rb
CHANGED
|
@@ -88,6 +88,17 @@ module Visionary
|
|
|
88
88
|
nil
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
+
# Records the account a sign-in request tried: the username or email
|
|
92
|
+
# typed, whether or not it exists or the password was right. Call it in
|
|
93
|
+
# the login handler; the security detectors use it to tell one IP trying
|
|
94
|
+
# many accounts, many IPs trying one account, and a signed-in user trying
|
|
95
|
+
# someone else's. No-op outside a request seen by Visionary::Middleware.
|
|
96
|
+
def login_attempt(account)
|
|
97
|
+
ctx = RequestContext.current
|
|
98
|
+
ctx.login_account = account if ctx
|
|
99
|
+
nil
|
|
100
|
+
end
|
|
101
|
+
|
|
91
102
|
# Records the route pattern (e.g. "/users/:id") for routers Visionary
|
|
92
103
|
# can't see. No-op outside a request.
|
|
93
104
|
def set_route(pattern)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: visionary-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.10.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- styropyr0
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-10-
|
|
11
|
+
date: 2026-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: |
|
|
14
14
|
The Ruby collector for Visionary. A Rack middleware (with a Railtie for Rails)
|
|
@@ -61,7 +61,7 @@ files:
|
|
|
61
61
|
- lib/visionary/writer.rb
|
|
62
62
|
homepage: https://github.com/styropyr0/Visionary
|
|
63
63
|
licenses:
|
|
64
|
-
-
|
|
64
|
+
- LicenseRef-VNCL-1.0
|
|
65
65
|
metadata:
|
|
66
66
|
homepage_uri: https://github.com/styropyr0/Visionary
|
|
67
67
|
source_code_uri: https://github.com/styropyr0/Visionary/tree/main/sdks/ruby
|