entitlements-github-plugin 1.2.3 → 1.2.5

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: 39178775eee3074e73cc8fa83b13e6047b67f0b8aa05932f41254a9e74265b60
4
- data.tar.gz: 3b73afc1b8e2685adddecc9a9943f96816209d545519c925c0f1080342defa5b
3
+ metadata.gz: 7866f5cc065f837d70b4a18815f786f9ce5ce0cf24e22330f48db4fadb2bfb8d
4
+ data.tar.gz: e09e3c17719fb411cc96326370f2a9cbbe4cdaa87fa6a94329deab2081379b1a
5
5
  SHA512:
6
- metadata.gz: 593b0ccbbb09c47864290d1c9ec1f7ac519e769628159a0cff2357ba48167c2843a9c29e8d52a51f4e5a2d2545eb8f7b9fa6b613e01d149d04d1082e25d9468b
7
- data.tar.gz: 698ee25bc5878a969bafbda9e591409c3c7152b4052b1d3de0fc9c1eaa264d8868378a1b20bd88414ec5c9e6923501ce4d550935940031cef31c455a7da2bad1
6
+ metadata.gz: c690243acde1d9ee347a14ea5fb205bf5e54bbc51dd6cf02c6670aa9fee3f6dd325eb94b069a752e9d0690c06f80b1599d1fd24a227f5f58faaaff381d142a4b
7
+ data.tar.gz: c91f6a53cc2389628839edf45f8994c81f20919d4a88b5a3ae6f8946142f0708d6e8f8f24120df8f98f01d3011ca51548d3cad46246cfd8e0ea8c7387dda5f6f
@@ -104,7 +104,8 @@ module Entitlements
104
104
  # Returns an Entitlements::Models::Group object.
105
105
  Contract String => Entitlements::Models::Group
106
106
  def role_to_group(role)
107
- members = github.org_members.keys.select { |username| github.org_members[username] == role }
107
+ org_members = github.org_members
108
+ members = org_members.select { |_, member_role| member_role == role }.keys
108
109
  Entitlements::Models::Group.new(
109
110
  dn: role_dn(role),
110
111
  members: Set.new(members),
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "../config/retry"
4
4
 
5
+ require "faraday/net_http_persistent"
5
6
  require "net/http"
6
7
  require "octokit"
7
8
  require "uri"
@@ -169,6 +170,9 @@ module Entitlements
169
170
  def octokit
170
171
  @octokit ||= begin
171
172
  client = Octokit::Client.new(access_token: token)
173
+ middleware = Octokit::Default.middleware.dup
174
+ middleware.adapter :net_http_persistent
175
+ client.middleware = middleware
172
176
  client.api_endpoint = addr if addr
173
177
  client.auto_paginate = true
174
178
  client.per_page = 100
@@ -369,9 +373,7 @@ module Entitlements
369
373
  # Returns { code: <Integer>, data: <response data structure> }
370
374
  Contract String => { code: Integer, data: C::Or[nil, Hash] }
371
375
  def graphql_http_post_real(query)
372
- uri = URI.parse(File.join(octokit.api_endpoint, "graphql"))
373
- http = Net::HTTP.new(uri.host, uri.port)
374
- http.use_ssl = uri.scheme == "https"
376
+ uri = graphql_uri
375
377
 
376
378
  request = Net::HTTP::Post.new(uri)
377
379
  request.add_field("Authorization", "bearer #{token}")
@@ -379,7 +381,7 @@ module Entitlements
379
381
  request.body = JSON.generate("query" => query)
380
382
 
381
383
  begin
382
- response = http.request(request)
384
+ response = graphql_http.request(request)
383
385
 
384
386
  if response.code != "200"
385
387
  # The retry wrapper retries on 5xx, so log those at WARN to avoid misleading
@@ -411,11 +413,41 @@ module Entitlements
411
413
  # Catch-all for any unexpected exception (network blip OR local code bug).
412
414
  # We retry below via the synthesized 500, but log at ERROR because this
413
415
  # branch can mask programming errors that operators must see.
416
+ reset_graphql_http
414
417
  Entitlements.logger.error "Caught #{e.class} POSTing to #{uri}: #{e.message}"
415
418
  { code: 500, data: nil }
416
419
  end
417
420
  end
418
421
 
422
+ # Return the URI used for GraphQL requests.
423
+ Contract C::None => URI::Generic
424
+ def graphql_uri
425
+ @graphql_uri ||= URI.parse(File.join(octokit.api_endpoint, "graphql"))
426
+ end
427
+
428
+ # Return a started HTTP connection that can be reused across GraphQL requests.
429
+ Contract C::None => Net::HTTP
430
+ def graphql_http
431
+ @graphql_http ||= begin
432
+ uri = graphql_uri
433
+ http = Net::HTTP.new(uri.host, uri.port)
434
+ http.use_ssl = uri.scheme == "https"
435
+ http.start
436
+ http
437
+ end
438
+ end
439
+
440
+ # Discard a failed GraphQL connection so the retry wrapper creates a new one.
441
+ Contract C::None => nil
442
+ def reset_graphql_http
443
+ http, @graphql_http = @graphql_http, nil
444
+ http.finish if http&.started?
445
+ nil
446
+ rescue IOError, SystemCallError => e
447
+ Entitlements.logger.warn "Failed to close GraphQL connection: #{e.message}"
448
+ nil
449
+ end
450
+
419
451
  # Create a unique signature for this GitHub instance to identify it in a global cache.
420
452
  #
421
453
  # Takes no arguments.
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Entitlements
4
4
  module Version
5
- VERSION = "1.2.3"
5
+ VERSION = "1.2.5"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entitlements-github-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub, Inc. Security Ops
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-08-03 00:00:00.000000000 Z
11
+ date: 2026-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: contracts
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday-net_http_persistent
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.3'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.3'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: faraday-retry
43
57
  requirement: !ruby/object:Gem::Requirement