Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Commit

Permalink
added severities filtering support
Browse files Browse the repository at this point in the history
  • Loading branch information
sami4064 committed Mar 31, 2022
1 parent 2569019 commit 985573d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/fetch-alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ export const fetchAlerts = async (
repositoryName: string,
repositoryOwner: string,
count: number,
severities: string[],
): Promise<Alert[] | []> => {
const octokit = getOctokit(gitHubPersonalAccessToken)
const { repository } = await octokit.graphql<{
repository: Repository
}>(`
query {
repository(owner:"${repositoryOwner}" name:"${repositoryName}") {
vulnerabilityAlerts(last: ${count}) {
vulnerabilityAlerts(filter:{ severity: [${severities.map(severity => `"${severity}"`)}]} last: ${count}) {
edges {
node {
id
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ async function run(): Promise<void> {
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)
Expand Down

0 comments on commit 985573d

Please sign in to comment.