ree_lib 1.3.14 → 1.3.15
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/Gemfile.lock +1 -1
- data/lib/ree_lib/packages/ree_audit/README.md +7 -1
- data/lib/ree_lib/packages/ree_audit/package/ree_audit/beans/audit.rb +14 -5
- data/lib/ree_lib/packages/ree_audit/package/ree_audit/event.rb +1 -1
- data/lib/ree_lib/packages/ree_audit/spec/ree_audit/beans/audit_spec.rb +14 -0
- data/lib/ree_lib/version.rb +1 -1
- 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: 2ecb6d379981355aad60ca8e7f67493643cc351e3f5232c2d8baa326a7630d07
|
|
4
|
+
data.tar.gz: 2530c228029eb4df4e96d6208f7a0c13c22aeb263c573e69372683f4f195449f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b1cc7a1ffbb0a4946d8359bb24ac0340c567fe9631dd389c70dc78fba3b5812d963d7174352a0e50ea7c918e7004a2ffa9c989797673978687c7865199179eb0
|
|
7
|
+
data.tar.gz: 815c690e32475a28c02dc3bbf8b4b8808b0b23302dd0cb8e5f35322b688f26ed68f4e1d98a0c4e10a9b6d80194a5fafec15fa76d8a0e60895b394918c4446754
|
data/Gemfile.lock
CHANGED
|
@@ -115,7 +115,7 @@ Annotating before the check, not after, keeps a refusal in the trail as well:
|
|
|
115
115
|
| `request_method`, `path`, `request_path` | `path` is the DSL template (stable), `request_path` is the actual path (shows the object) |
|
|
116
116
|
| `params` | what the action received, after filtering |
|
|
117
117
|
| `accessor` | the authenticated object — the application decides how to read it |
|
|
118
|
-
| `status` | `:ok`, `:denied`, `:error` |
|
|
118
|
+
| `status` | `:ok`, `:denied`, `:not_found`, `:error` |
|
|
119
119
|
| `error_type`, `error_message` | present when the call failed; message truncated to 512 chars |
|
|
120
120
|
| `started_at`, `duration_ms` | timing (monotonic clock) |
|
|
121
121
|
| `annotations` | whatever the application attached during the call |
|
|
@@ -124,6 +124,12 @@ Annotating before the check, not after, keeps a refusal in the trail as well:
|
|
|
124
124
|
`:permission`. A refusal to show client data is as much an audit fact as
|
|
125
125
|
showing it.
|
|
126
126
|
|
|
127
|
+
`:denied` and `:not_found` are split out of `:error` on purpose. A refusal by
|
|
128
|
+
permission and an ordinary "there was nothing to show" are both normal outcomes;
|
|
129
|
+
filing them next to a crash makes a compliance report say something broke when
|
|
130
|
+
nothing did. The split follows the domain error type, so an application gets it
|
|
131
|
+
without classifying anything itself.
|
|
132
|
+
|
|
127
133
|
There is **no HTTP status** on the event, and that is not an oversight: the
|
|
128
134
|
wrapper sits around the action call, while Roda sets the status afterwards (and,
|
|
129
135
|
on an exception, in the application's `error` block). Observing it here is
|
|
@@ -47,7 +47,7 @@ class ReeAudit::Audit
|
|
|
47
47
|
event.status = :ok
|
|
48
48
|
result
|
|
49
49
|
rescue StandardError => e
|
|
50
|
-
event.status =
|
|
50
|
+
event.status = status_for(e)
|
|
51
51
|
event.error_type = e.class.name
|
|
52
52
|
event.error_message = e.message.to_s[0, MAX_ERROR_MESSAGE_LENGTH]
|
|
53
53
|
raise
|
|
@@ -62,11 +62,20 @@ class ReeAudit::Audit
|
|
|
62
62
|
|
|
63
63
|
private
|
|
64
64
|
|
|
65
|
-
# A refusal to show client data is as much an audit fact as showing it
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
# A refusal to show client data is as much an audit fact as showing it — and
|
|
66
|
+
# it must not be filed next to a crash. Neither must "there was nothing to
|
|
67
|
+
# show": a domain 404 is an ordinary outcome, and reading it as a failure in a
|
|
68
|
+
# compliance report tells the reader something broke when nothing did.
|
|
69
|
+
def status_for(e)
|
|
70
|
+
return :error if !e.is_a?(ReeErrors::Error)
|
|
71
|
+
|
|
72
|
+
case e.type
|
|
73
|
+
when :permission then :denied
|
|
74
|
+
when :not_found then :not_found
|
|
75
|
+
else :error
|
|
76
|
+
end
|
|
68
77
|
rescue StandardError
|
|
69
|
-
|
|
78
|
+
:error
|
|
70
79
|
end
|
|
71
80
|
|
|
72
81
|
# The trail must never be the reason a request fails.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# enriched by the application through ReeAudit.annotate, and handed to a sink
|
|
5
5
|
# once the call is over.
|
|
6
6
|
class ReeAudit::Event
|
|
7
|
-
STATUSES = [:ok, :denied, :error].freeze
|
|
7
|
+
STATUSES = [:ok, :denied, :not_found, :error].freeze
|
|
8
8
|
|
|
9
9
|
attr_accessor :action_name, :package_name, :summary, :sections,
|
|
10
10
|
:request_method, :path, :request_path, :params, :accessor,
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
package_require('ree_audit/beans/audit')
|
|
4
4
|
package_require('ree_audit/event')
|
|
5
5
|
package_require('ree_errors/permission_error')
|
|
6
|
+
package_require('ree_errors/not_found_error')
|
|
6
7
|
|
|
7
8
|
RSpec.describe :audit do
|
|
8
9
|
link :audit, from: :ree_audit
|
|
9
10
|
link :config, from: :ree_audit
|
|
10
11
|
link :permission_error, from: :ree_errors
|
|
12
|
+
link :not_found_error, from: :ree_errors
|
|
11
13
|
link :logger, from: :ree_logger
|
|
12
14
|
|
|
13
15
|
# Captures what the application would have persisted.
|
|
@@ -89,6 +91,18 @@ RSpec.describe :audit do
|
|
|
89
91
|
expect(written.error_message).to eq("not allowed")
|
|
90
92
|
end
|
|
91
93
|
|
|
94
|
+
# 404 предметной области — обычный исход, а не поломка: строка «нечего
|
|
95
|
+
# показать» в отчёте соответствия не должна читаться как сбой.
|
|
96
|
+
it "records a domain not-found as its own outcome, not as a failure" do
|
|
97
|
+
klass = not_found_error(:missing)
|
|
98
|
+
|
|
99
|
+
expect {
|
|
100
|
+
audit.around(event) { raise klass.new("nothing here") }
|
|
101
|
+
}.to raise_error(klass)
|
|
102
|
+
|
|
103
|
+
expect(test_sink.events.first.status).to eq(:not_found)
|
|
104
|
+
end
|
|
105
|
+
|
|
92
106
|
it "records an arbitrary failure as an error and lets it through" do
|
|
93
107
|
expect {
|
|
94
108
|
audit.around(event) { raise ArgumentError.new("boom") }
|
data/lib/ree_lib/version.rb
CHANGED