Skip to content

Commit

Permalink
Merge pull request #5 from reload/harden
Browse files Browse the repository at this point in the history
Harden code against non existing variables
  • Loading branch information
arnested authored Jan 13, 2020
2 parents 6a322cf + 43ca587 commit 0df4bd9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/SyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
$github_repo = getenv('GITHUB_REPOSITORY');

$issue_type = getenv('JIRA_ISSUE_TYPE');
$watchers = explode("\n", getenv('JIRA_WATCHERS')) ?? [];

$watchers = [];
if (is_string(getenv('JIRA_WATCHERS'))) {
$watchers = explode("\n", getenv('JIRA_WATCHERS')) ?? [];
}

$res_group = getenv('JIRA_RESTRICTED_GROUP');
$res_comment = getenv('JIRA_RESTRICTED_COMMENT');

Expand Down Expand Up @@ -126,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$issue->setField('restricted_comment', $res_comment ?? []);

$timestamp = gmdate(DATE_ISO8601);
$this->log($output, "{$timestamp} - {$project} - {$package}:{$vulnerableVersionRange} - ");
$this->log($output, "{$timestamp} - {$jira_project} - {$package}:{$vulnerableVersionRange} - ");

// Determine whether there is an issue for this alert already.
try {
Expand All @@ -151,7 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
$this->logLine($output, "Created issue {$key}");
} else {
$this->logLine($output, "Would have created an issue in {$project} if not a dry run.");
$this->logLine($output, "Would have created an issue in {$jira_project} if not a dry run.");
}
}
}
Expand Down

0 comments on commit 0df4bd9

Please sign in to comment.