-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: setting to override trusted sites list (#1819)
* Make trusted sites list configurable * Fix Windows test failures * Update user-changes.md * Review
- Loading branch information
Showing
18 changed files
with
302 additions
and
33 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
Submodule ada-toml
updated
10 files
+1 −1 | run-tests.py | |
+63 −26 | src/toml-generic_parse.adb | |
+93 −34 | src/toml.adb | |
+47 −18 | src/toml.ads | |
+1 −0 | tests/error-eof/input.toml | |
+2 −0 | tests/error-eof/test.yaml | |
+24 −0 | tests/locations/example.toml | |
+48 −0 | tests/locations/main.adb | |
+54 −0 | tests/locations/test.out | |
+1 −0 | tests/locations/test.yaml |
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
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
10 changes: 10 additions & 0 deletions
10
testsuite/tests/index/untrusted-host/my_index/index/cr/crate/crate-1.0.0.toml
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,10 @@ | ||
description = "Sample crate" | ||
name = "crate" | ||
version = "1.0.0" | ||
licenses = "GPL-3.0-only" | ||
maintainers = ["any@bo.dy"] | ||
maintainers-logins = ["someone"] | ||
|
||
[origin] | ||
url = "git+https://some.host/path/to/repo" | ||
commit = "0000000000000000000000000000000000000000" |
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 @@ | ||
version = "1.1" |
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,77 @@ | ||
""" | ||
Check detection of untrusted hosts when running `alr index --check` | ||
""" | ||
|
||
|
||
import os | ||
|
||
from drivers.alr import run_alr, alr_settings_set | ||
from drivers.asserts import assert_eq, assert_match | ||
from drivers.helpers import replace_in_file | ||
|
||
|
||
# `alr index --check` should fail due to untrusted host. | ||
p = run_alr("index", "--check", quiet=False, complain_on_error=False) | ||
assert_match( | ||
( | ||
r"Warning: Release crate=1\.0\.0 has URL not in known hosts: " | ||
r"https://some\.host/path/to/repo" | ||
r".*ERROR: Issues were found in index contents" | ||
), | ||
p.out | ||
) | ||
|
||
# Configure the untrusted host as trusted. | ||
alr_settings_set("origins.git.trusted_sites", "github.com some.host gitlab.com") | ||
|
||
# `alr index --check` should now succeed. | ||
p = run_alr("index", "--check", quiet=False) | ||
assert_eq("Success: No issues found in index contents.\n", p.out) | ||
|
||
# Change the index manifest to use a new untrusted host, and check that | ||
# `alr index --check` fails again. | ||
manifest_path = os.path.join( | ||
"my_index", "index", "cr", "crate", "crate-1.0.0.toml" | ||
) | ||
replace_in_file( | ||
manifest_path, | ||
"git+https://some.host/path/to/repo", | ||
"git+https://untrusted.host/path/to/repo" | ||
) | ||
p = run_alr("index", "--check", quiet=False, complain_on_error=False) | ||
assert_match( | ||
( | ||
r"Warning: Release crate=1\.0\.0 has URL not in known hosts: " | ||
r"https://untrusted\.host/path/to/repo" | ||
r".*ERROR: Issues were found in index contents" | ||
), | ||
p.out | ||
) | ||
|
||
# Verify that it still fails when the host has a trailing dot (note the double | ||
# space in the setting value, which was causing the empty string to be | ||
# considered a trusted host, and hence `untrusted.host.` to be considered a | ||
# trusted subdomain thereof). | ||
replace_in_file( | ||
manifest_path, | ||
"git+https://untrusted.host/path/to/repo", | ||
"git+https://untrusted.host./path/to/repo" | ||
) | ||
p = run_alr("index", "--check", quiet=False, complain_on_error=False) | ||
assert_match( | ||
( | ||
r"Warning: Release crate=1\.0\.0 has URL not in known hosts: " | ||
r"https://untrusted\.host\./path/to/repo" | ||
r".*ERROR: Issues were found in index contents" | ||
), | ||
p.out | ||
) | ||
|
||
# Set 'origins.git.trusted_sites' to '...' and verify that all hosts are now | ||
# permitted. | ||
alr_settings_set("origins.git.trusted_sites", "...") | ||
p = run_alr("index", "--check", quiet=False) | ||
assert_eq("Success: No issues found in index contents.\n", p.out) | ||
|
||
|
||
print("SUCCESS") |
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,4 @@ | ||
driver: python-script | ||
indexes: | ||
my_index: | ||
in_fixtures: false |
Oops, something went wrong.