Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ It has some required and some optional settings, which are passed to the action
- `JIRA_RESTRICTED_COMMENT_ROLE`: A comment with restricted visibility
to this role is posted with info about who was added as watchers to
the issue. Defaults to `Developers`. (*Optional*)
- `JIRA_PRIORITY_MAPPING`: Map Dependabot severity levels to Jira priorities. Format: `SEVERITY:Priority` pairs separated by commas. Severities are: `CRITICAL`, `HIGH`, `MODERATE`, `LOW`. Example: `CRITICAL:P0,HIGH:P1,MODERATE:P2,LOW:P3`. (*Optional*)
- `JIRA_PRIORITY_DEFAULT`: Default Jira priority when severity is not found in the mapping. (*Optional*)

Here is an example setup which runs this action every 6 hours.

Expand All @@ -57,6 +59,7 @@ jobs:
JIRA_PROJECT: ABC
JIRA_ISSUE_TYPE: Security
JIRA_WATCHERS: someuser@reload.dk,someotheruser@reload.dk
JIRA_PRIORITY_MAPPING: "CRITICAL:P0,HIGH:P1,MODERATE:P2,LOW:P3"
```

## Local development
Expand Down
20 changes: 20 additions & 0 deletions src/SecurityAlertIssue.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,26 @@ public function __construct(array $data)
$this->setComponent(\trim($defaultComponent));
}
}

$priorityMapping = \getenv('JIRA_PRIORITY_MAPPING');

if ($priorityMapping) {
$mappings = [];

foreach (\explode(',', $priorityMapping) as $mapping) {
$parts = \explode(':', $mapping, 2);

if (\count($parts) === 2) {
$mappings[\trim($parts[0])] = \trim($parts[1]);
}
}

if (isset($mappings[$this->severity])) {
$this->priority = $mappings[$this->severity];
} elseif ($defaultPriority = \getenv('JIRA_PRIORITY_DEFAULT')) {
$this->priority = \trim($defaultPriority);
}
}
}

/**
Expand Down