Skip to content

Commit 0df4bd9

Browse files
authored
Merge pull request reload#5 from reload/harden
Harden code against non existing variables
2 parents 6a322cf + 43ca587 commit 0df4bd9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/SyncCommand.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
8181
$github_repo = getenv('GITHUB_REPOSITORY');
8282

8383
$issue_type = getenv('JIRA_ISSUE_TYPE');
84-
$watchers = explode("\n", getenv('JIRA_WATCHERS')) ?? [];
84+
85+
$watchers = [];
86+
if (is_string(getenv('JIRA_WATCHERS'))) {
87+
$watchers = explode("\n", getenv('JIRA_WATCHERS')) ?? [];
88+
}
89+
8590
$res_group = getenv('JIRA_RESTRICTED_GROUP');
8691
$res_comment = getenv('JIRA_RESTRICTED_COMMENT');
8792

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

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

131136
// Determine whether there is an issue for this alert already.
132137
try {
@@ -151,7 +156,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
151156
}
152157
$this->logLine($output, "Created issue {$key}");
153158
} else {
154-
$this->logLine($output, "Would have created an issue in {$project} if not a dry run.");
159+
$this->logLine($output, "Would have created an issue in {$jira_project} if not a dry run.");
155160
}
156161
}
157162
}

0 commit comments

Comments
 (0)