Skip to content

Commit 7abf19a

Browse files
committed
feat: configure CVE issue assignees per repository
1 parent afe1994 commit 7abf19a

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

.github/workflows/vulnerability-triage.yml

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ on:
4343
required: false
4444
type: boolean
4545
default: false
46+
linear_assignee_id:
47+
description: 'Linear user UUID to assign. Leave empty to use assign_to_api_key_owner behavior.'
48+
required: false
49+
type: string
50+
default: ''
51+
assign_to_api_key_owner:
52+
description: 'Assign issues to the Linear API key owner when linear_assignee_id is empty.'
53+
required: false
54+
type: boolean
55+
default: true
4656
secrets:
4757
LINEAR_API_KEY:
4858
required: true
@@ -674,13 +684,19 @@ jobs:
674684
REPO_LABEL_ID: ${{ steps.match.outputs.repo_label_id }}
675685
STATE_ID: ${{ steps.match.outputs.state_id }}
676686
VIEWER_ID: ${{ steps.match.outputs.viewer_id }}
687+
CONFIGURED_ASSIGNEE_ID: ${{ inputs.linear_assignee_id }}
688+
ASSIGN_TO_API_KEY_OWNER: ${{ inputs.assign_to_api_key_owner }}
677689
run: |
678690
set -uo pipefail
679-
# Team UUID, the "CVE" + repository labels, "Triage" state, and the API key
680-
# owner's user ID were already resolved by the "Match existing Linear issues"
681-
# step and passed in as env.
691+
# Team UUID, the "CVE" + repository labels, "Triage" state, and assignee
692+
# metadata were already resolved by the "Match existing Linear issues" step.
682693
STRUCTURED_OUTPUT=$(cat findings.json)
683694
695+
TARGET_ASSIGNEE_ID="$CONFIGURED_ASSIGNEE_ID"
696+
if [ -z "$TARGET_ASSIGNEE_ID" ] && [ "$ASSIGN_TO_API_KEY_OWNER" = "true" ]; then
697+
TARGET_ASSIGNEE_ID="$VIEWER_ID"
698+
fi
699+
684700
if [ -z "$LABEL_ID" ]; then
685701
echo "::warning::Could not find 'CVE' label in Linear team. Creating issues without label."
686702
fi
@@ -690,8 +706,8 @@ jobs:
690706
if [ -z "$STATE_ID" ]; then
691707
echo "::warning::Could not find 'Triage' state in Linear team. Using default state."
692708
fi
693-
if [ -z "$VIEWER_ID" ]; then
694-
echo "::warning::Could not resolve Linear API key owner. Issues will be created unassigned."
709+
if [ -z "$TARGET_ASSIGNEE_ID" ]; then
710+
echo "Issues will be created or reopened unassigned."
695711
fi
696712
697713
# Map severity to Linear priority
@@ -751,8 +767,10 @@ jobs:
751767
--arg issueId "$LINEAR_ISSUE_ID" \
752768
--arg stateId "$STATE_ID" \
753769
'{issueId: $issueId, stateId: $stateId}')
754-
if [ -n "$VIEWER_ID" ]; then
755-
REOPEN_VARIABLES=$(echo "$REOPEN_VARIABLES" | jq --arg aid "$VIEWER_ID" '. + {assigneeId: $aid}')
770+
if [ -n "$TARGET_ASSIGNEE_ID" ]; then
771+
REOPEN_VARIABLES=$(echo "$REOPEN_VARIABLES" | jq --arg aid "$TARGET_ASSIGNEE_ID" '. + {assigneeId: $aid}')
772+
else
773+
REOPEN_VARIABLES=$(echo "$REOPEN_VARIABLES" | jq '. + {assigneeId: null}')
756774
fi
757775
REOPEN_PAYLOAD=$(jq -n --arg query "$REOPEN_MUTATION" --argjson vars "$REOPEN_VARIABLES" '{query: $query, variables: $vars}')
758776
@@ -796,8 +814,10 @@ jobs:
796814
if [ -n "$STATE_ID" ]; then
797815
VARIABLES=$(echo "$VARIABLES" | jq --arg sid "$STATE_ID" '. + {stateId: $sid}')
798816
fi
799-
if [ -n "$VIEWER_ID" ]; then
800-
VARIABLES=$(echo "$VARIABLES" | jq --arg aid "$VIEWER_ID" '. + {assigneeId: $aid}')
817+
if [ -n "$TARGET_ASSIGNEE_ID" ]; then
818+
VARIABLES=$(echo "$VARIABLES" | jq --arg aid "$TARGET_ASSIGNEE_ID" '. + {assigneeId: $aid}')
819+
else
820+
VARIABLES=$(echo "$VARIABLES" | jq '. + {assigneeId: null}')
801821
fi
802822
803823
PAYLOAD=$(jq -n --arg query "$MUTATION" --argjson vars "$VARIABLES" '{query: $query, variables: $vars}')
@@ -827,4 +847,4 @@ jobs:
827847
if [ "$FAILED_COUNT" -gt 0 ]; then
828848
echo "::error::Failed to create $FAILED_COUNT Linear issue(s)"
829849
exit 1
830-
fi
850+
fi

0 commit comments

Comments
 (0)