-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only pull packages to descendants of duniverse dir
Previously, certain adversarial dev repo names (e.g. "", "..") would cause `opam monorepo pull` to create and delete files outside the duniverse directory, or to place package source code directly inside the duniverse directory instead of a subdirectory. This change adds a check which prevents code being pulled into directories which are not descendants of the duniverse directory. Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
- Loading branch information
Showing
4 changed files
with
89 additions
and
10 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
21 changes: 21 additions & 0 deletions
21
test/bin/pull-invalid-path.t/lockfile-refers-to-duniverse-directory.opam.locked
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,21 @@ | ||
opam-version: "2.0" | ||
synopsis: "opam-monorepo generated lockfile" | ||
maintainer: "opam-monorepo" | ||
depends: [ | ||
"foo" {= "1" & ?vendor} | ||
"ocaml" {= "4.14.0"} | ||
] | ||
pin-depends: [ | ||
["foo.1" "https://foo.com/foo.tbz"] | ||
] | ||
x-opam-monorepo-duniverse-dirs: [ | ||
[ | ||
"https://foo.com/foo.tbz" | ||
"" # <--------------------------- repo name is the empty string | ||
[ | ||
"sha256=0000000000000000000000000000000000000000000000000000000000000000" | ||
] | ||
] | ||
] | ||
x-opam-monorepo-root-packages: ["foo"] | ||
x-opam-monorepo-version: "0.3" |
21 changes: 21 additions & 0 deletions
21
test/bin/pull-invalid-path.t/lockfile-refers-to-parent-directory.opam.locked
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,21 @@ | ||
opam-version: "2.0" | ||
synopsis: "opam-monorepo generated lockfile" | ||
maintainer: "opam-monorepo" | ||
depends: [ | ||
"foo" {= "1" & ?vendor} | ||
"ocaml" {= "4.14.0"} | ||
] | ||
pin-depends: [ | ||
["foo.1" "https://foo.com/foo.tbz"] | ||
] | ||
x-opam-monorepo-duniverse-dirs: [ | ||
[ | ||
"https://foo.com/foo.tbz" | ||
".." # <--------------------------- repo name is ".." | ||
[ | ||
"sha256=0000000000000000000000000000000000000000000000000000000000000000" | ||
] | ||
] | ||
] | ||
x-opam-monorepo-root-packages: ["foo"] | ||
x-opam-monorepo-version: "0.3" |
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,18 @@ | ||
Running `opam monorepo pull` uses dev repo names (usually derived from the | ||
dev_repo field in the package's opam file) to name the directories that will | ||
contain the source code of packages inside the "duniverse" directory. We want to | ||
make sure that adversarial dev repo names don't cause files to be created or | ||
deleted outside the duniverse directory. | ||
|
||
Attempt to pull with a lockfile containing a package whose name is the empty | ||
string: | ||
$ opam-monorepo pull --lockfile=lockfile-refers-to-duniverse-directory.opam.locked | ||
==> Using lockfile lockfile-refers-to-duniverse-directory.opam.locked | ||
opam-monorepo: [ERROR] Refusing to pull https://foo.com/foo.tbz into directory $TESTCASE_ROOT/duniverse/ as it is not inside the directory $TESTCASE_ROOT/duniverse | ||
[1] | ||
|
||
Attempt to pull with a lockfile containinga package whose name is "..": | ||
$ opam-monorepo pull --lockfile=lockfile-refers-to-parent-directory.opam.locked | ||
==> Using lockfile lockfile-refers-to-parent-directory.opam.locked | ||
opam-monorepo: [ERROR] Refusing to pull https://foo.com/foo.tbz into directory $TESTCASE_ROOT/duniverse/.. as it is not inside the directory $TESTCASE_ROOT/duniverse | ||
[1] |