graphql-armory 0.1.0.pre11 → 0.1.0.pre13
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/CHANGELOG.md +24 -1
- data/README.md +4 -4
- data/docs/authorization.md +7 -7
- data/docs/rate-limiting.md +1 -1
- data/docs/versioning.md +540 -0
- data/lib/graphql/armory/authorization/adapters/pundit.rb +26 -1
- data/lib/graphql/armory/authorization/audit/findings.rb +6 -1
- data/lib/graphql/armory/authorization/audit/overrides.rb +8 -2
- data/lib/graphql/armory/authorization/audit/payload_reuse.rb +9 -8
- data/lib/graphql/armory/authorization/definitions.rb +8 -92
- data/lib/graphql/armory/authorization/integration/object.rb +2 -2
- data/lib/graphql/armory/authorization/integration.rb +29 -2
- data/lib/graphql/armory/authorization/rule.rb +3 -3
- data/lib/graphql/armory/authorization.rb +3 -1
- data/lib/graphql/armory/definitions.rb +111 -0
- data/lib/graphql/armory/location.rb +101 -0
- data/lib/graphql/armory/rate_limits/analysis_guard.rb +9 -2
- data/lib/graphql/armory/version.rb +1 -1
- data/lib/graphql/armory/versioning/audit/command.rb +43 -0
- data/lib/graphql/armory/versioning/audit/own_checks.rb +139 -0
- data/lib/graphql/armory/versioning/audit/profiles.rb +123 -0
- data/lib/graphql/armory/versioning/audit/subscription_triggers.rb +98 -0
- data/lib/graphql/armory/versioning/audit.rb +559 -0
- data/lib/graphql/armory/versioning/controls.rb +403 -0
- data/lib/graphql/armory/versioning/decision.rb +89 -0
- data/lib/graphql/armory/versioning/deprecation.rb +95 -0
- data/lib/graphql/armory/versioning/diff/command.rb +49 -0
- data/lib/graphql/armory/versioning/diff.rb +349 -0
- data/lib/graphql/armory/versioning/dump/command.rb +46 -0
- data/lib/graphql/armory/versioning/dump.rb +107 -0
- data/lib/graphql/armory/versioning/gate.rb +140 -0
- data/lib/graphql/armory/versioning/integration.rb +903 -0
- data/lib/graphql/armory/versioning/lifecycle.rb +61 -0
- data/lib/graphql/armory/versioning/profiles.rb +122 -0
- data/lib/graphql/armory/versioning/rspec.rb +38 -0
- data/lib/graphql/armory/versioning/versions.rb +111 -0
- data/lib/graphql/armory/versioning/view.rb +61 -0
- data/lib/graphql/armory/versioning.rb +132 -0
- data/lib/graphql/armory.rb +1 -0
- data/lib/tasks/graphql_armory.rake +20 -0
- metadata +24 -2
- data/lib/graphql/armory/authorization/location.rb +0 -79
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module GraphQL
|
|
4
|
-
module Armory
|
|
5
|
-
module Authorization
|
|
6
|
-
# Where something of the app's schema was written, as "path:line", for the audit's report. graphql-ruby keeps no
|
|
7
|
-
# location for a field or an argument, so the plugin's field and argument classes record the line that declared them,
|
|
8
|
-
# and a type records the line of its `authorize`. Anything else falls back to the line of its class.
|
|
9
|
-
#
|
|
10
|
-
# Limits: a schema built from SDL has no Ruby lines; a field declared by a helper method points to the helper; a class
|
|
11
|
-
# reopened in several files gives the first one.
|
|
12
|
-
module Location
|
|
13
|
-
GRAPHQL_RUBY_PATH = "#{File.dirname(GraphQL::Schema.method(:from_definition).source_location.first)}/"
|
|
14
|
-
ARMORY_PATH = "#{File.expand_path('..', __dir__)}/"
|
|
15
|
-
# The directory the app started in, read once: a later `Dir.chdir` must not change the report's text. None when the
|
|
16
|
-
# directory is gone, and then paths stay absolute.
|
|
17
|
-
ROOT = begin
|
|
18
|
-
"#{Dir.pwd}/"
|
|
19
|
-
rescue SystemCallError
|
|
20
|
-
nil
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# The first line of the caller's stack outside graphql-ruby and this gem: where the app declared it. An `initialize`
|
|
24
|
-
# is skipped too: an app's field or argument class, or another gem's module, may define one that calls super into
|
|
25
|
-
# the plugin's, and its line is the same for every field.
|
|
26
|
-
def self.declared
|
|
27
|
-
found = caller_locations(2, 40)&.find do |location|
|
|
28
|
-
path = location.absolute_path || location.path
|
|
29
|
-
!path.start_with?("<", GRAPHQL_RUBY_PATH, ARMORY_PATH) && location.base_label != "initialize"
|
|
30
|
-
end
|
|
31
|
-
found && "#{found.absolute_path || found.path}:#{found.lineno}"
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# "path:line" for a method, a field, an argument, a type or a class, relative to the directory the app started in
|
|
35
|
-
# when it is inside it, or nil when there is no line to give.
|
|
36
|
-
def self.of(thing)
|
|
37
|
-
relative(absolute(thing))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def self.absolute(thing)
|
|
41
|
-
case thing
|
|
42
|
-
when nil then nil
|
|
43
|
-
when String then thing
|
|
44
|
-
when Method, UnboundMethod then join(thing.source_location)
|
|
45
|
-
when GraphQL::Schema::Field, GraphQL::Schema::Argument
|
|
46
|
-
(thing.armory_location if thing.respond_to?(:armory_location)) || absolute(thing.owner)
|
|
47
|
-
when Module
|
|
48
|
-
(thing.armory_rule_location if thing.respond_to?(:armory_rule_location)) || constant(thing)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
private_class_method :absolute
|
|
52
|
-
|
|
53
|
-
# Only when the name leads back to this class: a class may answer another constant's name. A location is never worth
|
|
54
|
-
# failing the audit, so a `name` that raises gives none.
|
|
55
|
-
def self.constant(mod)
|
|
56
|
-
name = mod.name
|
|
57
|
-
return if !name.is_a?(String) || name.empty? || !Object.const_get(name).equal?(mod)
|
|
58
|
-
|
|
59
|
-
join(Object.const_source_location(name))
|
|
60
|
-
rescue StandardError, NotImplementedError
|
|
61
|
-
nil
|
|
62
|
-
end
|
|
63
|
-
private_class_method :constant
|
|
64
|
-
|
|
65
|
-
def self.join(pair)
|
|
66
|
-
pair && !pair.empty? && pair.first ? "#{pair.first}:#{pair.last}" : nil
|
|
67
|
-
end
|
|
68
|
-
private_class_method :join
|
|
69
|
-
|
|
70
|
-
def self.relative(location)
|
|
71
|
-
return location if location.nil? || ROOT.nil?
|
|
72
|
-
|
|
73
|
-
location.start_with?(ROOT) ? location.delete_prefix(ROOT) : location
|
|
74
|
-
end
|
|
75
|
-
private_class_method :relative
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|