Skip to content

Commit 0eb736f

Browse files
authored
Merge pull request #153 from cr-alan/v1.x
added severity and labels
2 parents 45f55d5 + 45f9c50 commit 0eb736f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ It has some required and some optional settings, which are passed to the action
2929
- `JIRA_PROJECT`: The project key for the Jira project where issues should be created, eg `TEST` or `ABC`. (**REQUIRED**)
3030
- `JIRA_ISSUE_TYPE`: Type of issue to create, e.g. `Security`. Defaults to `Bug`. (*Optional*)
3131
- `JIRA_WATCHERS`: Jira users to add as watchers to tickets. Separate multiple watchers with comma (no spaces).
32+
- `JIRA_ISSUE_LABELS`: Jira labels to add to tickets. Separate multiple labels with comma (no spaces).
3233
- `JIRA_RESTRICTED_COMMENT_ROLE`: A comment with restricted visibility
3334
to this role is posted with info about who was added as watchers to
3435
the issue. Defaults to `Developers`. (*Optional*)

src/SecurityAlertIssue.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class SecurityAlertIssue extends JiraSecurityIssue
3434
*/
3535
protected string $id;
3636

37+
/**
38+
* @var string
39+
*/
40+
protected string $severity;
41+
3742
/**
3843
* phpcs:disable SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint.DisallowedMixedTypeHint
3944
*
@@ -47,6 +52,7 @@ public function __construct(array $data)
4752
$this->vulnerableVersionRange = $data['securityVulnerability']['vulnerableVersionRange'];
4853
$this->manifestPath = \pathinfo($data['vulnerableManifestPath'], \PATHINFO_DIRNAME);
4954
$this->id = $data['securityVulnerability']['advisory']['ghsaId'];
55+
$this->severity = $data['securityVulnerability']['severity'];
5056

5157
$references = [];
5258

@@ -87,8 +93,16 @@ public function __construct(array $data)
8793

8894
$this->setKeyLabel($githubRepo);
8995
$this->setKeyLabel($this->uniqueId());
90-
$this->setTitle("{$this->package} ({$safeVersion})");
96+
$this->setTitle("{$this->package} ({$safeVersion}) - {$this->severity}");
9197
$this->setBody($body);
98+
99+
$labels = \getenv('JIRA_ISSUE_LABELS');
100+
101+
if ($labels) {
102+
foreach (\explode(',', $labels) as $label) {
103+
$this->setKeyLabel($label);
104+
}
105+
}
92106
}
93107

94108
/**

0 commit comments

Comments
 (0)