dependabot-hex 0.400.0 → 0.401.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/helpers/lib/run.exs +27 -14
- data/lib/dependabot/hex/credential_helpers.rb +11 -3
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7f6798814b3d2cfec821cee72650b3daee5a11ce0fee0338d7342b5f5654e1f0
|
|
4
|
+
data.tar.gz: bc88669f4e924f01390b8b1afcdd61e041676fa135b0904fe8c73837a3014d9f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5e4b1bf83ba0d953e0fd787ee41f3ecb284dee877703abddf1e5743eede7e9cf50acbdc876127f72e14f9ac9010fc511d74278994d78fa9d84ba112f2770043
|
|
7
|
+
data.tar.gz: ee94615705c6b28f562404742af836caef582488566be55e6f7c8f44148f91e58cbaf6dbb3c62bdd4be29bfebc4a16f34e627a0e72a737715824cd4be0cf540b
|
data/helpers/lib/run.exs
CHANGED
|
@@ -97,8 +97,8 @@ defmodule DependencyHelper do
|
|
|
97
97
|
set_credentials(tail)
|
|
98
98
|
end
|
|
99
99
|
|
|
100
|
-
defp set_credentials(["hex_repository", repo, url, auth_key, fingerprint | tail]) do
|
|
101
|
-
case
|
|
100
|
+
defp set_credentials(["hex_repository", repo, url, auth_key, fingerprint, public_key | tail]) do
|
|
101
|
+
case resolve_public_key(repo, url, auth_key, fingerprint, public_key) do
|
|
102
102
|
{:ok, public_key} ->
|
|
103
103
|
update_repos(repo, %{auth_key: auth_key, public_key: public_key, url: url})
|
|
104
104
|
|
|
@@ -120,21 +120,21 @@ defmodule DependencyHelper do
|
|
|
120
120
|
|> Hex.Config.update_repos()
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
+
# Some registries (e.g. JFrog Artifactory) don't serve /public_key, so a
|
|
124
|
+
# configured key is used instead of downloading it.
|
|
125
|
+
defp resolve_public_key(repo, url, auth_key, fingerprint, public_key)
|
|
126
|
+
when public_key in [nil, ""] do
|
|
127
|
+
fetch_public_key(repo, url, auth_key, fingerprint)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
defp resolve_public_key(repo, _url, _auth_key, fingerprint, public_key) do
|
|
131
|
+
verify_public_key(repo, public_key, fingerprint)
|
|
132
|
+
end
|
|
133
|
+
|
|
123
134
|
defp fetch_public_key(repo, repo_url, auth_key, fingerprint) do
|
|
124
135
|
case Hex.Repo.get_public_key(%{trusted: true, url: repo_url, auth_key: auth_key}) do
|
|
125
136
|
{:ok, {200, _headers, key}} ->
|
|
126
|
-
|
|
127
|
-
if public_key_matches?(key, fingerprint) do
|
|
128
|
-
{:ok, key}
|
|
129
|
-
else
|
|
130
|
-
{:error, "Public key fingerprint mismatch for repo \"#{repo}\""}
|
|
131
|
-
end
|
|
132
|
-
rescue
|
|
133
|
-
e in FunctionClauseError ->
|
|
134
|
-
{:error,
|
|
135
|
-
"Failed to decode public key for repo \"#{repo}\": " <>
|
|
136
|
-
"#{Exception.message(e)} (#{inspect(e.__struct__)})"}
|
|
137
|
-
end
|
|
137
|
+
verify_public_key(repo, key, fingerprint)
|
|
138
138
|
|
|
139
139
|
{:ok, {code, _headers, _body}} ->
|
|
140
140
|
{:error, "Downloading public key for repo \"#{repo}\" failed with code: #{inspect(code)}"}
|
|
@@ -144,6 +144,19 @@ defmodule DependencyHelper do
|
|
|
144
144
|
end
|
|
145
145
|
end
|
|
146
146
|
|
|
147
|
+
defp verify_public_key(repo, key, fingerprint) do
|
|
148
|
+
if public_key_matches?(key, fingerprint) do
|
|
149
|
+
{:ok, key}
|
|
150
|
+
else
|
|
151
|
+
{:error, "Public key fingerprint mismatch for repo \"#{repo}\""}
|
|
152
|
+
end
|
|
153
|
+
rescue
|
|
154
|
+
e in FunctionClauseError ->
|
|
155
|
+
{:error,
|
|
156
|
+
"Failed to decode public key for repo \"#{repo}\": " <>
|
|
157
|
+
"#{Exception.message(e)} (#{inspect(e.__struct__)})"}
|
|
158
|
+
end
|
|
159
|
+
|
|
147
160
|
defp public_key_matches?(_public_key, _fingerprint = ""), do: true
|
|
148
161
|
|
|
149
162
|
defp public_key_matches?(public_key, fingerprint) do
|
|
@@ -26,12 +26,20 @@ module Dependabot
|
|
|
26
26
|
def self.repo_credentials(credentials)
|
|
27
27
|
# Credentials are serialized as an array that may not have optional fields. Using a
|
|
28
28
|
# default ensures that the array is always the same length, even if values are empty.
|
|
29
|
-
defaults = Dependabot::Credential.new(
|
|
30
|
-
|
|
29
|
+
defaults = Dependabot::Credential.new(
|
|
30
|
+
{ "url" => "", "auth_key" => "", "public_key_fingerprint" => "", "public_key" => "" }
|
|
31
|
+
)
|
|
32
|
+
keys = %w(type repo url auth_key public_key_fingerprint public_key)
|
|
31
33
|
|
|
32
34
|
credentials
|
|
33
35
|
.select { |cred| cred["type"] == "hex_repository" }
|
|
34
|
-
.flat_map { |cred| defaults.merge(cred).slice(*keys).values }
|
|
36
|
+
.flat_map { |cred| defaults.merge(underscore_keys(cred)).slice(*keys).values }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Job credentials use the dependabot.yml spelling of keys (e.g. `public-key-fingerprint`).
|
|
40
|
+
sig { params(credential: Dependabot::Credential).returns(Dependabot::Credential) }
|
|
41
|
+
def self.underscore_keys(credential)
|
|
42
|
+
Dependabot::Credential.new(credential.to_h.transform_keys { |key| key.tr("-", "_") })
|
|
35
43
|
end
|
|
36
44
|
end
|
|
37
45
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dependabot-hex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.401.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dependabot
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - '='
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 0.
|
|
18
|
+
version: 0.401.0
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - '='
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 0.
|
|
25
|
+
version: 0.401.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: debug
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -274,7 +274,7 @@ licenses:
|
|
|
274
274
|
- MIT
|
|
275
275
|
metadata:
|
|
276
276
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
|
277
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
|
277
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.401.0
|
|
278
278
|
rdoc_options: []
|
|
279
279
|
require_paths:
|
|
280
280
|
- lib
|