Repository navigation
fix(task): handle azure devops remote git includes #11768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,10 +5,18 @@ static SSH_GIT_REGEX: Lazy<Regex> = Lazy::new(|| { | |
| Regex::new(r"^git::(?P<url>ssh://((?P<user>[^@]+)@)?(?P<host>[^/]+)/(?P<repo>.+)\.git)//(?P<path>[^?]+)(\?ref=(?P<ref>[^?&]+)(&.*)?)?$").unwrap() | ||
| }); | ||
|
|
||
| static AZURE_DEVOPS_SSH_GIT_REGEX: Lazy<Regex> = Lazy::new(|| { | ||
| Regex::new(r"^git::(?P<url>ssh://((?P<user>[^@]+)@)?(?P<host>[^/]+)/(?P<org>[^/]+)/(?P<project>[^/]+)/_git/(?P<repo>[^/]+))//(?P<path>[^?]+)(\?ref=(?P<ref>[^?&]+)(&.*)?)?$").unwrap() | ||
| }); | ||
|
Comment on lines
+8
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 6 'repo_structure\.path|full_path|destination\.join' \
src/task/task_file_providers/remote_task_git.rsRepository: jdx/mise Length of output: 1612 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== candidate files =="
fd -a 'remote_source\.rs|remote_task_git\.rs' . | sed 's#^\./##'
echo "== remote_source outline =="
if [ -f src/remote_source.rs ]; then
ast-grep outline src/remote_source.rs --match AzureDevOpsSshGitRegex --view expanded || true
wc -l src/remote_source.rs
sed -n '1,90p' src/remote_source.rs
fi
echo "== remote_task_git outline and relevant sections =="
if [ -f src/task/task_file_providers/remote_task_git.rs ]; then
wc -l src/task/task_file_providers/remote_task_git.rs
ast-grep outline src/task/task_file_providers/remote_task_git.rs --view expanded || true
sed -n '1,230p' src/task/task_file_providers/remote_task_git.rs
fi
echo "== search for path validation / confinement patterns =="
rg -n -C 4 'sanitize|normalize|RUSTSEC-2020-0071|relative|canonical|path\(|backslash|\\\\|validate|repo_file_path|full_path|storage_path' src/task src/remote_source.rs 2>/dev/null || trueRepository: jdx/mise Length of output: 50365 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== exact target file sizes =="
wc -l src/remote_source.rs src/task/task_file_providers/remote_task_git.rs
echo "== src/remote_source.rs outline =="
ast-grep outline src/remote_source.rs --view expanded
echo
echo "== target regex and parse sections =="
rg -n -C 8 'AZURE_(DEVOPS_SSH_GIT_REGEX|DEVOPS_HTTP_GIT_REGEX)|fn parse|regex|matches' src/remote_source.rs
echo
echo "== exact target path construction/validation sections =="
rg -n -C 12 'get_repo_structure|repo_structure|destination\.join|path\.components|validate|split\(|full_path|get_local_path' src/task/task_file_providers/remote_task_git.rs
echo
echo "== focused path validation search =="
rg -n -C 4 'components\.any|PathBuf::from|\.to_path_buf\(|\\\.join\(|RUSTSEC-2020-0071|normalize|canonicalize|contains\(\[.*\\]' src/task/task_file_providers/remote_task_git.rsRepository: jdx/mise Length of output: 13530 Reject backslash path traversal before joining
🤖 Prompt for AI Agents🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== repo files =="
git ls-files | sed -n '1,120p'
echo "== locate remote_source =="
fd -a 'remote_source\.rs$' . || true
echo "== search Azure regex and parse_git_with =="
rg -n "AZURE_DEVOPS_SSH_GIT_REGEX|AZURE_DEVOPS|parse_git_with|_git|_git/(?P<repo>|\\([^/\\]\\+\\))|v3|azure.com" . || true
echo "== file outline if present =="
if [ -f src/remote_source.rs ]; then
ast-grep outline src/remote_source.rs || true
echo "== src/remote_source.rs sample =="
cat -n src/remote_source.rs | sed -n '1,220p'
fiRepository: jdx/mise Length of output: 14229 🌐 Web query:
💡 Result: To authenticate with Azure DevOps using SSH, you must use the Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
cat -n src/remote_source.rs | sed -n '220,320p'
python3 - <<'PY'
import re
pattern = re.compile(r"^git::(?P<url>ssh://((?P<user>[^@]+)@)?(?P<host>[^/]+)/(?P<org>[^/]+)/(?P<project>[^/]+)/_git/(?P<repo>[^/]+))//(?P<path>[^?]+)(\?ref=(?P<ref>[^?&]+)(&.*)?)?$")
for url in [
"git::ssh://git@dev.azure/myorg/myproj/_git/example//terraform/myfile?ref=master",
"git::ssh://git@ssh.dev.azure.com/v3/orG/prOj/ecH/example//terraform/myfile?ref=master",
"git::ssh://git@ssh.dev.azure.com/g/v3/orG/prOj/ecH/example//terraform/myfile?ref=master",
]:
m = pattern.match(url)
print(f"url={url!r}")
print(" match=", bool(m))
if m:
print(" url=", m.group("url"))
print(" path=", m.group("path"))
print(" ref=", m.group("ref"))
PYRepository: jdx/mise Length of output: 1390 Support the Azure DevOps v3 SSH layout. Azure DevOps SSH remotes use 🤖 Prompt for AI Agents |
||
|
|
||
| static HTTPS_GIT_REGEX: Lazy<Regex> = Lazy::new(|| { | ||
| Regex::new(r"^git::(?P<url>https?://(?P<host>[^/]+)/(?P<repo>.+)\.git)//(?P<path>[^?]+)(\?ref=(?P<ref>[^?&]+)(&.*)?)?$").unwrap() | ||
| }); | ||
|
|
||
| static AZURE_DEVOPS_HTTPS_GIT_REGEX: Lazy<Regex> = Lazy::new(|| { | ||
| Regex::new(r"^git::(?P<url>https?://(?P<host>[^/]+)/(?P<org>[^/]+)/(?P<project>[^/]+)/_git/(?P<repo>[^/]+))//(?P<path>[^?]+)(\?ref=(?P<ref>[^?&]+)(&.*)?)?$").unwrap() | ||
| }); | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub struct RemoteGitSource { | ||
| pub url: String, | ||
|
|
@@ -30,10 +38,12 @@ impl RemoteSource { | |
|
|
||
| pub(crate) fn parse_git_ssh(file: &str) -> Option<RemoteGitSource> { | ||
| parse_git_with(&SSH_GIT_REGEX, file) | ||
| .or_else(|| parse_git_with(&AZURE_DEVOPS_SSH_GIT_REGEX, file)) | ||
| } | ||
|
|
||
| pub(crate) fn parse_git_https(file: &str) -> Option<RemoteGitSource> { | ||
| parse_git_with(&HTTPS_GIT_REGEX, file) | ||
| .or_else(|| parse_git_with(&AZURE_DEVOPS_HTTPS_GIT_REGEX, file)) | ||
| } | ||
|
|
||
| pub fn parse_http(file: &str) -> Option<RemoteHttpSource> { | ||
|
|
@@ -135,6 +145,89 @@ mod tests { | |
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parses_azure_devops_git_ssh_sources() { | ||
| let source = RemoteSource::parse_git( | ||
| "git::ssh://git@dev.azure/myorg/myproj/_git/example//terraform/myfile?ref=master", | ||
| ) | ||
| .unwrap(); | ||
| assert_eq!(source.url, "ssh://git@dev.azure/myorg/myproj/_git/example"); | ||
| assert_eq!(source.path, "terraform/myfile"); | ||
| assert_eq!(source.git_ref, Some("master".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parses_azure_devops_git_ssh_sources_without_user() { | ||
| let source = RemoteSource::parse_git( | ||
| "git::ssh://dev.azure/myorg/myproj/_git/example//terraform/myfile", | ||
| ) | ||
| .unwrap(); | ||
| assert_eq!(source.url, "ssh://dev.azure/myorg/myproj/_git/example"); | ||
| assert_eq!(source.path, "terraform/myfile"); | ||
| assert_eq!(source.git_ref, None); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parses_azure_devops_git_https_sources() { | ||
| let source = RemoteSource::parse_git( | ||
| "git::https://dev.azure:8080/myorg/myproj/_git/example//terraform/myfile?ref=master", | ||
| ) | ||
| .unwrap(); | ||
| assert_eq!( | ||
| source.url, | ||
| "https://dev.azure:8080/myorg/myproj/_git/example" | ||
| ); | ||
| assert_eq!(source.path, "terraform/myfile"); | ||
| assert_eq!(source.git_ref, Some("master".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parses_azure_devops_git_ref_before_additional_query_params() { | ||
| let source = RemoteSource::parse_git( | ||
| "git::https://dev.azure/myorg/myproj/_git/example//terraform/myfile?ref=master&depth=1", | ||
| ) | ||
| .unwrap(); | ||
| assert_eq!(source.git_ref, Some("master".to_string())); | ||
| } | ||
|
|
||
| #[test] | ||
| fn rejects_azure_devops_git_sources_without_paths() { | ||
| assert!( | ||
| RemoteSource::parse_git("git::https://dev.azure/myorg/myproj/_git/example?ref=master") | ||
| .is_none() | ||
| ); | ||
| assert!( | ||
| RemoteSource::parse_git("git::ssh://user@dev.azure/myorg/myproj/_git/example") | ||
| .is_none() | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn rejects_azure_devops_git_sources_with_unsafe_paths() { | ||
| assert!( | ||
| RemoteSource::parse_git("git::https://dev.azure/myorg/myproj/_git/example//../plugin") | ||
| .is_none() | ||
| ); | ||
| assert!( | ||
| RemoteSource::parse_git( | ||
| "git::https://dev.azure/myorg/myproj/_git/example//plugin/../other" | ||
| ) | ||
| .is_none() | ||
| ); | ||
| assert!( | ||
| RemoteSource::parse_git( | ||
| "git::https://dev.azure/myorg/myproj/_git/example//plugin//other" | ||
| ) | ||
| .is_none() | ||
| ); | ||
| assert!( | ||
| RemoteSource::parse_git( | ||
| "git::https://dev.azure/myorg/myproj/_git/example//plugin/./other" | ||
| ) | ||
| .is_none() | ||
| ); | ||
| } | ||
|
|
||
| #[test] | ||
| fn parses_http_sources() { | ||
| assert!(RemoteSource::parse_http("http://myhost.com/test.txt").is_some()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -250,6 +250,12 @@ mod tests { | |
| "git::ssh://git@myserver.com/example.git//terraform/myfile", | ||
| "git::ssh://user@myserver.com/example.git//myfile?ref=master", | ||
| "git::ssh://myserver.com/example.git//myfile?ref=master", | ||
| "git::ssh://git@dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "git::ssh://git@dev.azure/org/project/_git/example//terraform/myfile?ref=master", | ||
| "git::ssh://git@dev.azure:1222/org/project/_git/example//terraform/myfile?ref=master", | ||
| "git::ssh://git@dev.azure/org/project/_git/example//terraform/myfile", | ||
| "git::ssh://user@dev.azure/org/project/_git/example//myfile?ref=master", | ||
| "git::ssh://dev.azure/org/project/_git/example//myfile?ref=master", | ||
| ]; | ||
|
|
||
| for url in test_cases { | ||
|
|
@@ -267,6 +273,9 @@ mod tests { | |
| "git::ssh://user@myserver.com/example.git?ref=master", | ||
| "git::ssh://user@myserver.com/example.git", | ||
| "git::https://github.com/myorg/example.git//myfile?ref=v1.0.0", | ||
| "git::ssh://user@dev.azure/org/project/_git/example?ref=master", | ||
| "git::ssh://user@dev.azure/org/project/_git/example", | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| ]; | ||
|
|
||
| for url in test_cases { | ||
|
|
@@ -287,6 +296,12 @@ mod tests { | |
| "git::https://myserver.com/example.git//terraform/myfile", | ||
| "git::https://myserver.com/example.git//myfile?ref=master", | ||
| "git::http://localhost:8080/repo.git//xtasks/lint/remote-task", // HTTP support for local testing | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "git::https://dev.azure/org/project/_git/example//terraform/myfile?ref=master", | ||
| "git::https://dev.azure:8080/org/project/_git/example//terraform/myfile?ref=master", | ||
| "git::https://dev.azure/org/project/_git/example//terraform/myfile", | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=master", | ||
| "git::http://localhost:8080/org/project/_git/example//xtasks/lint/remote-task", // HTTP support for local testing | ||
| ]; | ||
|
|
||
| for url in test_cases { | ||
|
|
@@ -304,6 +319,9 @@ mod tests { | |
| "git::https://myserver.com/example.git?ref=master", | ||
| "git::https://user@myserver.com/example.git", | ||
| "git::ssh://git@github.com/myorg/example.git//myfile?ref=v1.0.0", | ||
| "git::https://dev.azure/org/project/_git/example?ref=master", | ||
| "git::https://user@dev.azure/org/project/_git/example", | ||
| "git::ssh://git@dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
|
Comment on lines
+322
to
+324
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate and inspect the relevant Rust source and tests around the referenced lines.
if [ -f src/task/task_file_providers/remote_task_git.rs ]; then
echo "== file exists =="
wc -l src/task/task_file_providers/remote_task_git.rs
echo "== outline =="
ast-grep outline src/task/task_file_providers/remote_task_git.rs --view compact || true
echo "== lines 280-345 =="
sed -n '280,345p' src/task/task_file_providers/remote_task_git.rs | nl -ba -v280
else
echo "== file missing =="
fd -a 'remote_task_git.rs' .
fi
echo "== search parse_https and credential-related tests/code =="
rg -n "parse_https|credential|user@|test|assert|invalid" src/task/task_file_providers/remote_task_git.rs src || trueRepository: jdx/mise Length of output: 442 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== file stats =="
wc -l src/task/task_file_providers/remote_task_git.rs
echo "== ast outline expanded/main sections =="
ast-grep outline src/task/task_file_providers/remote_task_git.rs --view signatures || true
echo "== lines 280-345 with line numbers =="
awk 'NR>=280 && NR<=345 {printf "%5d\t%s\n", NR, $0}' src/task/task_file_providers/remote_task_git.rs
echo "== search parse_https and credential-related code/tests =="
rg -n "parse_https|credential|user@|test|assert" src/task/task_file_providers/remote_task_git.rs || true
echo "== deterministic URL path split check from source text =="
python3 - <<'PY'
from pathlib import Path
s = Path('src/task/task_file_providers/remote_task_git.rs').read_text()
for needle in [
'fn parse_https',
'git::https://user@dev.azure/org/project/_git/example',
'git::ssh://git@dev.azure/org/project/_git/example//myfile?ref=v1.0.0'
]:
print(needle, 'present=', needle in s)
if needle in s:
idx = s.index(needle)
start=max(0, idx-800); end=min(len(s), idx+800)
print("context:")
for i, line in enumerate(s[start:].splitlines(), max(1, s[:start].count('\n')+1)):
if idx <= start + sum(len(l)+1 for l in s[start:].splitlines()[:i-1]) < idx+800:
pass
print(f"{i}\t{line}")
PYRepository: jdx/mise Length of output: 47400 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== locate RemoteSource implementation =="
rg -n "struct RemoteSource|impl RemoteSource|parse_git_https|parse_git_ssh|credential|https://user|ssh://user" --glob '*.rs' . || true
echo "== read likely files around RemoteSource =="
while IFS= read -r line; do
file="${line##*:}"
echo "--- $file"
wc -l "$file"
ast-grep outline "$file" --view signatures || true
sed -n '1,520p' "$file" | awk 'NR>=1 && NR<=520 {printf "%5d\t%s\n", NR, $0}'
done < <(rg -l "parse_git_https|parse_git_ssh" --glob '*.rs' .)Repository: jdx/mise Length of output: 21165 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== src/remote_source.rs =="
wc -l src/remote_source.rs
sed -n '1,150p' src/remote_source.rs | awk 'NR>=1 && NR<=150 {printf "%5d\t%s\n", NR, $0}'
echo "== src/remote_source.rs tests around credential cases =="
sed -n '110,220p' src/remote_source.rs | awk 'NR>=1 && NR<=110 {printf "%5d\t%s\n", NR+109, $0}'Repository: jdx/mise Length of output: 10870 Add an Azure HTTPS credential case with a
🤖 Prompt for AI Agents |
||
| ]; | ||
|
|
||
| for url in test_cases { | ||
|
|
@@ -367,6 +385,24 @@ mod tests { | |
| "terraform/myfile", | ||
| None, | ||
| ), | ||
| ( | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "https://dev.azure/org/project/_git/example", | ||
| "myfile", | ||
| Some("v1.0.0".to_string()), | ||
| ), | ||
| ( | ||
| "git::https://dev.azure/org/project/_git/example//terraform/myfile?ref=master", | ||
| "https://dev.azure/org/project/_git/example", | ||
| "terraform/myfile", | ||
| Some("master".to_string()), | ||
| ), | ||
| ( | ||
| "git::https://dev.azure/org/project/_git/example//terraform/myfile", | ||
| "https://dev.azure/org/project/_git/example", | ||
| "terraform/myfile", | ||
| None, | ||
| ), | ||
| ]; | ||
|
|
||
| for (url, expected_repo, expected_path, expected_branch) in test_cases { | ||
|
|
@@ -392,6 +428,11 @@ mod tests { | |
| "git::ssh://user@myserver.com/example.git//myfile?ref=master", | ||
| false, | ||
| ), | ||
| ( | ||
| "git::ssh://git@dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "git::ssh://git@dev.azure/org/project/_git/example//myfile?ref=v2.0.0", | ||
| false, | ||
| ), | ||
| ( | ||
| "git::ssh://git@github.com/example.git//myfile?ref=v1.0.0", | ||
| "git::ssh://git@github.com/example.git//subfolder/mysecondfile?ref=v1.0.0", | ||
|
|
@@ -402,6 +443,11 @@ mod tests { | |
| "git::ssh://git@github.com/myorg/example.git//subfolder/mysecondfile?ref=v1.0.0", | ||
| true, | ||
| ), | ||
| ( | ||
| "git::ssh://git@dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "git::ssh://git@dev.azure/org/project/_git/example//subfolder/mysecondfile?ref=v1.0.0", | ||
| true, | ||
| ), | ||
| ]; | ||
|
|
||
| for (first_url, second_url, expected) in test_cases { | ||
|
|
@@ -428,6 +474,11 @@ mod tests { | |
| "git::https://bitbucket.com/myorg/example.git//myfile?ref=v1.0.0", | ||
| false, | ||
| ), | ||
| ( | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=v2.0.0", | ||
| false, | ||
| ), | ||
| ( | ||
| "git::https://github.com/myorg/example.git//myfile?ref=v1.0.0", | ||
| "git::https://github.com/myorg/example.git//subfolder/myfile?ref=v1.0.0", | ||
|
|
@@ -438,6 +489,11 @@ mod tests { | |
| "git::https://github.com/example.git//subfolder/myfile?ref=v1.0.0", | ||
| true, | ||
| ), | ||
| ( | ||
| "git::https://dev.azure/org/project/_git/example//myfile?ref=v1.0.0", | ||
| "git::https://dev.azure/org/project/_git/example//subfolder/myfile?ref=v1.0.0", | ||
| true, | ||
| ), | ||
| ]; | ||
|
|
||
| for (first_url, second_url, expected) in test_cases { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a remote task uses an Azure DevOps SSH clone URL such as
git::ssh://git@ssh.dev.azure.com/v3/org/project/repository//path/to/task, neither the generic.git-suffixed parser nor this new/_git/parser recognizes it, causing task fetching to fail with “No provider found for file”.Knowledge Base Used: Task Runner (
mise run/mise tasks)