Skip to content

Commit dc74996

Browse files
authored
Merge pull request #332 from matthiasdg/feature/no_fixed_url
Support for GitHub enterprise
2 parents c41aab7 + 014bfb3 commit dc74996

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

docker-compose.override.example.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ services:
66
# Repo name (normally set automatically by the action) eg.
77
# 'reload/github-security-jira'.
88
GITHUB_REPOSITORY: reload/github-security-jira
9+
# GitHub URLs (normally set automatically by the action)
10+
GITHUB_GRAPHQL_URL: https://api.github.com/graphql
11+
GITHUB_SERVER_URL: https://github.com
912
# In repos, this is the 'GitHubSecurityToken' secret.
1013
GH_SECURITY_TOKEN: github_pat
1114
# In repos, this is the 'JiraApiToken' secret.

src/PullRequestIssue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ public function __construct(array $data)
3333
$this->safeVersion = \preg_filter('/.*to ([^ ]+).*/', '$1', $data['title']) ?? '';
3434

3535
$githubRepo = \getenv('GITHUB_REPOSITORY') ?: '';
36+
$githubUrl = \getenv('GITHUB_SERVER_URL') ?: 'https://github.com';
3637

3738
$body = <<<EOT
38-
- Repository: [{$githubRepo}|https://github.com/{$githubRepo}]
39+
- Repository: [{$githubRepo}|{$githubUrl}/{$githubRepo}]
3940
- Package: {$this->package}
4041
- Secure version: {$this->safeVersion}
4142
- Pull request with more info: [#{$data['number']}|{$data['url']}]

src/SecurityAlertIssue.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ public function __construct(array $data)
7878
$advisory_description = \wordwrap($data['securityVulnerability']['advisory']['description'] ?? '', 100);
7979
$ecosystem = $data['securityVulnerability']['package']['ecosystem'] ?? '';
8080
$githubRepo = \getenv('GITHUB_REPOSITORY') ?: '';
81+
$githubUrl = \getenv('GITHUB_SERVER_URL') ?: 'https://github.com';
8182
$safeVersion = $this->safeVersion ?? 'no fix';
8283

8384
$body = <<<EOT
84-
- Repository: [{$githubRepo}|https://github.com/{$githubRepo}]
85-
- Alert: [{$this->advisorySummary}|https://github.com/{$githubRepo}/security/dependabot/{$this->alertNumber}]
85+
- Repository: [{$githubRepo}|{$githubUrl}/{$githubRepo}]
86+
- Alert: [{$this->advisorySummary}|{$githubUrl}/{$githubRepo}/security/dependabot/{$this->alertNumber}]
8687
- Package: {$this->package} ($ecosystem)
8788
- Vulnerable version: {$this->vulnerableVersionRange}
8889
- Secure version: {$safeVersion}

src/SyncCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ protected function fetchPullRequestData(): array
264264
protected function getGHClient(): GraphQLClient
265265
{
266266
$access_token = \getenv('GH_SECURITY_TOKEN');
267-
268-
return ClientBuilder::build('https://api.github.com/graphql', [
267+
$graphql_url = \getenv('GITHUB_GRAPHQL_URL') ?: 'https://api.github.com/graphql';
268+
return ClientBuilder::build($graphql_url, [
269269
'headers' => [
270270
'Accept' => 'application/json',
271271
'Authorization' => "Bearer {$access_token}",

0 commit comments

Comments
 (0)