-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
174 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# TODO: Add a more thorough explanation of the dependency confusion | ||
# vulnerability and how this guideline mitigates it. | ||
|
||
const guideline_dependency_confusion = | ||
Guideline("No UUID conflict with other registries.", | ||
data -> has_no_dependency_confusion(data.pkg, | ||
data.registry_head, | ||
data.public_registries)) | ||
|
||
# TODO: Needs a strategy to handle connection failures for the public | ||
# registries. Preferably they should also be cloned only once and then | ||
# just updated to mitigate the effect of them being temporarily | ||
# offline. This could be implemented with the help of the Scratch | ||
# package, but requires Julia >= 1.5. | ||
function has_no_dependency_confusion(pkg, registry_head, public_registries) | ||
# We know the name of this package but not its uuid. Look it up in | ||
# the registry that includes the current PR. | ||
packages = Pkg.TOML.parsefile(joinpath(registry_head, "Registry.toml"))["packages"] | ||
filter!(packages) do (key, value) | ||
value["name"] == pkg | ||
end | ||
# For Julia >= 1.4 this can be simplified with the `only` function. | ||
always_assert(length(packages) == 1) | ||
uuid = first(keys(packages)) | ||
# Also need to find out the package repository. | ||
package_repo = Pkg.TOML.parsefile(joinpath(registry_head, packages[uuid]["path"], "Package.toml"))["repo"] | ||
for repo in public_registries | ||
registry = clone_repo(repo) | ||
registry_toml = Pkg.TOML.parsefile(joinpath(registry, "Registry.toml")) | ||
packages = registry_toml["packages"] | ||
if haskey(packages, uuid) | ||
message = string("UUID $uuid conflicts with the package ", | ||
packages[uuid]["name"], " in registry ", | ||
registry_toml["name"], " at $repo.\n", | ||
"This could be a dependency confusion attack.") | ||
# Conflict detected. This is benign if the package name | ||
# *and* the package URL matches. | ||
if packages[uuid]["name"] != pkg | ||
return false, message | ||
end | ||
package_path = packages[uuid]["path"] | ||
other_package_repo = Pkg.TOML.parsefile(joinpath(registry, package_path, "Package.toml"))["repo"] | ||
if package_repo != other_package_repo | ||
return false, message | ||
end | ||
end | ||
end | ||
|
||
return true, "" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
["0.5.3-0"] | ||
julia = "1" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = "Example" | ||
uuid = "7876af07-990d-54b4-ab0e-23690620f79a" | ||
repo = "https://github.com/JuliaLang/Example.jl.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
["0.5.3"] | ||
git-tree-sha1 = "46e44e869b4d90b96bd8ed1fdcf32244fddfb6cc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name = "PublicRegistry" | ||
uuid = "1003c4b9-3c72-409d-ba60-5578a18ea1a7" | ||
repo = "" | ||
|
||
description = "This is a test registry for the AutoMerge integration tests." | ||
|
||
[packages] | ||
7876af07-990d-54b4-ab0e-23690620f79a = { name = "Example", path = "E/Example" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[1-2] | ||
julia = "1" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = "Req" | ||
uuid = "ae029012-a4dd-5104-9daa-d747884805df" | ||
repo = "https://github.com/MikeInnes/Requires.jl.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
["1.0.0"] | ||
git-tree-sha1 = "999513b7dea8ac17359ed50ae8ea089e4464e35e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name = "PublicRegistry" | ||
uuid = "1003c4b9-3c72-409d-ba60-5578a18ea1a7" | ||
repo = "" | ||
|
||
description = "This is a test registry for the AutoMerge integration tests." | ||
|
||
[packages] | ||
ae029012-a4dd-5104-9daa-d747884805df = { name = "Req", path = "R/Req" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[1-2] | ||
julia = "1" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = "Requires" | ||
uuid = "ae029012-a4dd-5104-9daa-d747884805df" | ||
repo = "https://github.com/JuliaLang/Example.jl.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
["1.0.0"] | ||
git-tree-sha1 = "999513b7dea8ac17359ed50ae8ea089e4464e35e" | ||
|
||
["2.0.0"] | ||
git-tree-sha1 = "999513b7dea8ac17359ed50ae8ea089e4464e35e" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name = "PublicRegistry" | ||
uuid = "1003c4b9-3c72-409d-ba60-5578a18ea1a7" | ||
repo = "" | ||
|
||
description = "This is a test registry for the AutoMerge integration tests." | ||
|
||
[packages] | ||
ae029012-a4dd-5104-9daa-d747884805df = { name = "Requires", path = "R/Requires" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[0-1] | ||
julia = "1" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name = "Requires" | ||
uuid = "ae029012-a4dd-5104-9daa-d747884805df" | ||
repo = "https://github.com/MikeInnes/Requires.jl.git" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
["0.5.2"] | ||
git-tree-sha1 = "f6fbf4ba64d295e146e49e021207993b6b48c7d1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
name = "PublicRegistry" | ||
uuid = "1003c4b9-3c72-409d-ba60-5578a18ea1a7" | ||
repo = "" | ||
|
||
description = "This is a test registry for the AutoMerge integration tests." | ||
|
||
[packages] | ||
ae029012-a4dd-5104-9daa-d747884805df = { name = "Requires", path = "R/Requires" } |