RunCommandLogs: identify and access via uuid

Using a sha1 of the command combined with the build ID is not a
particularly good or unique identifier:

* A build could fail, be restarted, and then succeed -- assuming no
configuration changes, the sha1 hash of the command as well as the build
ID will be the same. This would lead to an overwritten log file.

* Allowing user input to influence filenames is not the best of ideas.
This commit is contained in:
Cole Helbling
2022-01-26 10:26:28 -08:00
parent dcb0c1425c
commit fc3cf4ecb2
6 changed files with 10 additions and 47 deletions

View File

@ -137,10 +137,10 @@ sub view_log : Chained('buildChain') PathPart('log') {
}
sub view_runcommand_log : Chained('buildChain') PathPart('runcommand-log') {
my ($self, $c, $sha) = @_;
sub view_runcommandlog : Chained('buildChain') PathPart('runcommandlog') {
my ($self, $c, $uuid) = @_;
$c->stash->{log_uri} = $c->uri_for($c->controller('Root')->action_for("runcommandlog"), constructRunCommandLogFilename($sha, $c->stash->{build}->id));
$c->stash->{log_uri} = $c->uri_for($c->controller('Root')->action_for("runcommandlog"), $uuid);
$c->stash->{template} = 'runcommand-log.tt';
}

View File

@ -531,13 +531,13 @@ sub log :Local :Args(1) {
}
sub runcommandlog :Local :Args(1) {
my ($self, $c, $filename) = @_;
my ($self, $c, $uuid) = @_;
my $tail = $c->request->params->{"tail"};
die if defined $tail && $tail !~ /^[0-9]+$/;
my $logFile = constructRunCommandLogPath($filename);
my $logFile = constructRunCommandLogPath($uuid);
if (-f $logFile) {
serveLogFile($c, $logFile, $tail);
return;