@ -21,11 +21,17 @@ function postURL($diffID, $url) {
assert(is_numeric($diffID));
assert(is_numeric($diffID));
assert(strlen($url) > 0);
assert(strlen($url) > 0);
$cmd = 'echo \'{"diff_id": ' . $diffID . ', '
$cmd_args = array(
. '"name":"click here for sandcastle tests for D' . $diffID . '", '
'diff_id' => (int)$diffID,
. '"link":"' . $url . '"}\' | '
'name' => sprintf(
. 'arc call-conduit '
'click here for sandcastle tests for D%d',
. 'differential.updateunitresults';
(int)$diffID
),
'link' => $url
);
$cmd = 'echo ' . escapeshellarg(json_encode($cmd_args))
. ' | arc call-conduit differential.updateunitresults';
shell_exec($cmd);
shell_exec($cmd);
}
}
@ -35,11 +41,15 @@ function buildUpdateTestStatusCmd($diffID, $test, $status) {
assert(strlen($test) > 0);
assert(strlen($test) > 0);
assert(strlen($status) > 0);
assert(strlen($status) > 0);
$cmd = 'echo \'{"diff_id": ' . $diffID . ', '
$cmd_args = array(
. '"name":"' . $test . '", '
'diff_id' => (int)$diffID,
. '"result":"' . $status . '"}\' | '
'name' => $test,
. 'arc call-conduit '
'result' => $status
. 'differential.updateunitresults';
);
$cmd = 'echo ' . escapeshellarg(json_encode($cmd_args))
. ' | arc call-conduit differential.updateunitresults';
return $cmd;
return $cmd;
}
}
@ -68,7 +78,7 @@ function getSteps($applyDiff, $diffID, $username, $test) {
// and authenticate using that in Sandcastle.
// and authenticate using that in Sandcastle.
$setup = array(
$setup = array(
"name" => "Setup arcrc",
"name" => "Setup arcrc",
"shell" => "echo " . $arcrc_content . " | base64 --decode"
"shell" => "echo " . escapeshellarg( $arcrc_content) . " | base64 --decode"
. " | gzip -d > ~/.arcrc",
. " | gzip -d > ~/.arcrc",
"user" => "root"
"user" => "root"
);
);
@ -114,7 +124,7 @@ function getSteps($applyDiff, $diffID, $username, $test) {
$patch = array(
$patch = array(
"name" => "Patch " . $diffID,
"name" => "Patch " . $diffID,
"shell" => "arc --arcrc-file ~/.arcrc "
"shell" => "arc --arcrc-file ~/.arcrc "
. "patch --nocommit --diff " . $diffID,
. "patch --nocommit --diff " . escapeshellarg( $diffID) ,
"user" => "root"
"user" => "root"
);
);
@ -125,8 +135,8 @@ function getSteps($applyDiff, $diffID, $username, $test) {
}
}
// Run the actual command.
// Run the actual command.
$cmd = $cmd . "J=$(nproc) ./build_tools/precommit_checker.py " . $test
$cmd = $cmd . "J=$(nproc) ./build_tools/precommit_checker.py " .
. "; exit_code=$?; ";
escapeshellarg($test) . "; exit_code=$?; ";
if ($applyDiff) {
if ($applyDiff) {
$cmd = $cmd . "([[ \$exit_code -eq 0 ]] & & "
$cmd = $cmd . "([[ \$exit_code -eq 0 ]] & & "
@ -159,7 +169,7 @@ function getSteps($applyDiff, $diffID, $username, $test) {
"name" => "Run " . $test,
"name" => "Run " . $test,
"shell" => $cmd,
"shell" => $cmd,
"user" => "root",
"user" => "root",
"parser" => "python build_tools/error_filter.py " . $test,
"parser" => "python build_tools/error_filter.py " . escapeshellarg( $test) ,
);
);
$steps[] = $run_test;
$steps[] = $run_test;
@ -207,7 +217,7 @@ function getSandcastleConfig() {
if (file_exists(PRIMARY_TOKEN_FILE)) {
if (file_exists(PRIMARY_TOKEN_FILE)) {
$cmd = 'cat ' . PRIMARY_TOKEN_FILE;
$cmd = 'cat ' . PRIMARY_TOKEN_FILE;
} else {
} else {
$cmd = 'cat ' . $cwd_token_file;
$cmd = 'cat ' . escapeshellarg( $cwd_token_file) ;
}
}
assert(strlen($cmd) > 0);
assert(strlen($cmd) > 0);
@ -331,9 +341,11 @@ function getSandcastleConfig() {
$app = $sandcastle_config[0];
$app = $sandcastle_config[0];
$token = $sandcastle_config[1];
$token = $sandcastle_config[1];
$cmd = 'curl -s -k -F app=' . $app . ' '
$cmd = 'curl -s -k '
. '-F token=' . $token . ' -F job=\'' . json_encode($job)
. ' -F app=' . escapeshellarg($app)
.'\' "' . $url . '"';
. ' -F token=' . escapeshellarg($token)
. ' -F job=' . escapeshellarg(json_encode($job))
.' ' . escapeshellarg($url);
$output = shell_exec($cmd);
$output = shell_exec($cmd);
assert(strlen($output) > 0);
assert(strlen($output) > 0);