diff --git a/src/fetch-alerts.ts b/src/fetch-alerts.ts index 2f99b797..7a0e7f30 100644 --- a/src/fetch-alerts.ts +++ b/src/fetch-alerts.ts @@ -7,6 +7,7 @@ export const fetchAlerts = async ( repositoryName: string, repositoryOwner: string, count: number, + severities: string[], ): Promise => { const octokit = getOctokit(gitHubPersonalAccessToken) const { repository } = await octokit.graphql<{ @@ -14,7 +15,7 @@ export const fetchAlerts = async ( }>(` query { repository(owner:"${repositoryOwner}" name:"${repositoryName}") { - vulnerabilityAlerts(last: ${count}) { + vulnerabilityAlerts(filter:{ severity: [${severities.map(severity => `"${severity}"`)}]} last: ${count}) { edges { node { id diff --git a/src/main.ts b/src/main.ts index e6830fbf..b4bb171e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -19,9 +19,10 @@ async function run(): Promise { const zenDutyServiceId = getInput('zenduty_service_id') const zenDutyEscalationPolicyId = getInput('zenduty_escalation_policy_id') const count = parseInt(getInput('count')) + const severities = getInput('severities').split(',') || ["Critical","High","Moderate","Low"] const owner = context.repo.owner const repo = context.repo.repo - const alerts = await fetchAlerts(token, repo, owner, count) + const alerts = await fetchAlerts(token, repo, owner, count, severities); if (alerts.length > 0) { if (microsoftTeamsWebhookUrl) { await sendAlertsToMicrosoftTeams(microsoftTeamsWebhookUrl, alerts)