@@ -618,10 +618,8 @@ jobs:
618618 --arg teamId "$LINEAR_TEAM_ID" \
619619 --arg stateName "$LINEAR_STATE_NAME" \
620620 '{query: $query, variables: {teamId: $teamId, stateName: $stateName}}')
621- METADATA_RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
622- -H "Content-Type: application/json" \
623- -H "Authorization: $LINEAR_API_KEY" \
624- -d "$METADATA_PAYLOAD")
621+ METADATA_RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
622+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$METADATA_PAYLOAD")
625623
626624 if [ "$(echo "$METADATA_RESPONSE" | jq 'has("errors") or (.data.team == null)')" = "true" ]; then
627625 echo "::error::Could not load Linear team metadata: $(echo "$METADATA_RESPONSE" | jq -c '.errors // .')"
@@ -645,21 +643,17 @@ jobs:
645643 REPO_LABEL_QUERY='query($teamId: String!, $name: String!) { team(id: $teamId) { labels(filter: { name: { eq: $name } }) { nodes { id } } } }'
646644 REPO_LABEL_PAYLOAD=$(jq -n --arg query "$REPO_LABEL_QUERY" --arg teamId "$TEAM_UUID" --arg name "$REPOSITORY" \
647645 '{query: $query, variables: {teamId: $teamId, name: $name}}')
648- REPO_LABEL_RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
649- -H "Content-Type: application/json" \
650- -H "Authorization: $LINEAR_API_KEY" \
651- -d "$REPO_LABEL_PAYLOAD")
646+ REPO_LABEL_RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
647+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$REPO_LABEL_PAYLOAD")
652648 REPO_LABEL_ID=$(echo "$REPO_LABEL_RESPONSE" | jq -r '.data.team.labels.nodes[0].id // empty')
653649
654650 if [ -z "$REPO_LABEL_ID" ]; then
655651 echo "No '$REPOSITORY' label in Linear team — creating it."
656652 CREATE_LABEL_MUTATION='mutation($teamId: String!, $name: String!) { issueLabelCreate(input: { teamId: $teamId, name: $name }) { success issueLabel { id } } }'
657653 CREATE_LABEL_PAYLOAD=$(jq -n --arg query "$CREATE_LABEL_MUTATION" --arg teamId "$TEAM_UUID" --arg name "$REPOSITORY" \
658654 '{query: $query, variables: {teamId: $teamId, name: $name}}')
659- CREATE_LABEL_RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
660- -H "Content-Type: application/json" \
661- -H "Authorization: $LINEAR_API_KEY" \
662- -d "$CREATE_LABEL_PAYLOAD")
655+ CREATE_LABEL_RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
656+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$CREATE_LABEL_PAYLOAD")
663657 REPO_LABEL_ID=$(echo "$CREATE_LABEL_RESPONSE" | jq -r '.data.issueLabelCreate.issueLabel.id // empty')
664658 if [ -z "$REPO_LABEL_ID" ]; then
665659 echo "::warning::Could not create '$REPOSITORY' label: $(echo "$CREATE_LABEL_RESPONSE" | jq -c '.errors // .')"
@@ -693,10 +687,8 @@ jobs:
693687 --arg teamId "$TEAM_UUID" \
694688 '{titlePrefix: $titlePrefix, teamId: $teamId}')
695689 PAYLOAD=$(jq -n --arg query "$SEARCH_QUERY" --argjson vars "$VARS" '{query: $query, variables: $vars}')
696- RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
697- -H "Content-Type: application/json" \
698- -H "Authorization: $LINEAR_API_KEY" \
699- -d "$PAYLOAD")
690+ RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
691+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$PAYLOAD")
700692
701693 # A failed search is not "no match": treating it as one could create
702694 # a duplicate issue, so stop before any Linear mutations.
@@ -854,10 +846,13 @@ jobs:
854846 fi
855847 REOPEN_PAYLOAD=$(jq -n --arg query "$REOPEN_MUTATION" --argjson vars "$REOPEN_VARIABLES" '{query: $query, variables: $vars}')
856848
857- REOPEN_RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
858- -H "Content-Type: application/json" \
859- -H "Authorization: $LINEAR_API_KEY" \
860- -d "$REOPEN_PAYLOAD")
849+ if ! REOPEN_RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
850+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$REOPEN_PAYLOAD"); then
851+ echo "::error::Linear request failed while reopening $LINEAR_IDENTIFIER for $CVE_ID"
852+ echo "- **FAILED** to reopen [$LINEAR_IDENTIFIER]($LINEAR_URL) for **$CVE_ID**" >> "$GITHUB_STEP_SUMMARY"
853+ FAILED_COUNT=$((FAILED_COUNT + 1))
854+ continue
855+ fi
861856
862857 REOPEN_URL=$(echo "$REOPEN_RESPONSE" | jq -r '.data.issueUpdate.issue.url // empty')
863858 REOPEN_IDENTIFIER=$(echo "$REOPEN_RESPONSE" | jq -r '.data.issueUpdate.issue.identifier // empty')
@@ -905,10 +900,13 @@ jobs:
905900
906901 PAYLOAD=$(jq -n --arg query "$MUTATION" --argjson vars "$VARIABLES" '{query: $query, variables: $vars}')
907902
908- RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
909- -H "Content-Type: application/json" \
910- -H "Authorization: $LINEAR_API_KEY" \
911- -d "$PAYLOAD")
903+ if ! RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
904+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$PAYLOAD"); then
905+ echo "::error::Linear request failed while creating an issue for $CVE_ID"
906+ echo "- **FAILED** to create issue for **$CVE_ID** — $TITLE" >> "$GITHUB_STEP_SUMMARY"
907+ FAILED_COUNT=$((FAILED_COUNT + 1))
908+ continue
909+ fi
912910
913911 ISSUE_URL=$(echo "$RESPONSE" | jq -r '.data.issueCreate.issue.url // empty')
914912 ISSUE_IDENTIFIER=$(echo "$RESPONSE" | jq -r '.data.issueCreate.issue.identifier // empty')
@@ -966,10 +964,8 @@ jobs:
966964 '{prefix: $prefix, teamId: $teamId, after: $after}')
967965 fi
968966 PAYLOAD=$(jq -n --arg query "$SEARCH_QUERY" --argjson vars "$VARS" '{query: $query, variables: $vars}')
969- RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
970- -H "Content-Type: application/json" \
971- -H "Authorization: $LINEAR_API_KEY" \
972- -d "$PAYLOAD")
967+ RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
968+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$PAYLOAD")
973969
974970 if [ "$(echo "$RESPONSE" | jq 'has("errors") or (.data.issues == null)')" = "true" ]; then
975971 echo "::error::Failed to fetch open Linear issues: $(echo "$RESPONSE" | jq -c '.errors // .')"
@@ -1014,10 +1010,8 @@ jobs:
10141010
10151011 CLOSE_VARS=$(jq -n --arg issueId "$ISSUE_ID" --arg stateId "$DONE_STATE_ID" '{issueId: $issueId, stateId: $stateId}')
10161012 CLOSE_PAYLOAD=$(jq -n --arg query "$CLOSE_MUTATION" --argjson vars "$CLOSE_VARS" '{query: $query, variables: $vars}')
1017- CLOSE_RESPONSE=$(curl -s -X POST https://api.linear.app/graphql \
1018- -H "Content-Type: application/json" \
1019- -H "Authorization: $LINEAR_API_KEY" \
1020- -d "$CLOSE_PAYLOAD")
1013+ CLOSE_RESPONSE=$(LINEAR_API_KEY="$LINEAR_API_KEY" \
1014+ .vulnerability-triage-workflow/.github/scripts/linear-graphql-request.sh <<<"$CLOSE_PAYLOAD")
10211015
10221016 if [ "$(echo "$CLOSE_RESPONSE" | jq -r '.data.issueUpdate.success // false')" = "true" ]; then
10231017 echo "Closed $ISSUE_IDENTIFIER — $FINDING_ID is no longer reported"
0 commit comments