From 2d3d4683d373c70f190a945ee4c4e647cd50ab67 Mon Sep 17 00:00:00 2001 From: kunalnagar <2741371+kunalnagar@users.noreply.github.com> Date: Wed, 29 Jun 2022 22:42:57 -0400 Subject: [PATCH] fix: Dismissed or Fixed alerts should not be included in the list (#94) --- package-lock.json | 14 +++++++------- package.json | 2 +- src/entities/alert.ts | 12 ++++++++++++ src/fetch-alerts.ts | 6 ++++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 050fb079..b435ef84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,7 +18,7 @@ "nodemailer": "^6.7.5" }, "devDependencies": { - "@octokit/graphql-schema": "10.73.0", + "@octokit/graphql-schema": "^10.74.1", "@semantic-release/changelog": "6.0.1", "@semantic-release/commit-analyzer": "9.0.2", "@semantic-release/git": "10.0.1", @@ -1206,9 +1206,9 @@ } }, "node_modules/@octokit/graphql-schema": { - "version": "10.73.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql-schema/-/graphql-schema-10.73.0.tgz", - "integrity": "sha512-0pHfbnl3n+b5mtTwP6nmMYlMwLgUvGZjndKVqPS2uyR1Vh8WGMldVW4sFXxDxOPY8RyznLGg44m8sDQT+vAbnw==", + "version": "10.74.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql-schema/-/graphql-schema-10.74.1.tgz", + "integrity": "sha512-FeaXZH/xwZ8aTtBBMvVg7slRTgvRZGsf407coLjl4pLTirWkN/PQ6DxZUSEeXsYJcYiMim4C1rSaPNzjhBx98w==", "dev": true, "dependencies": { "graphql": "^15.0.0", @@ -12642,9 +12642,9 @@ } }, "@octokit/graphql-schema": { - "version": "10.73.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql-schema/-/graphql-schema-10.73.0.tgz", - "integrity": "sha512-0pHfbnl3n+b5mtTwP6nmMYlMwLgUvGZjndKVqPS2uyR1Vh8WGMldVW4sFXxDxOPY8RyznLGg44m8sDQT+vAbnw==", + "version": "10.74.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql-schema/-/graphql-schema-10.74.1.tgz", + "integrity": "sha512-FeaXZH/xwZ8aTtBBMvVg7slRTgvRZGsf407coLjl4pLTirWkN/PQ6DxZUSEeXsYJcYiMim4C1rSaPNzjhBx98w==", "dev": true, "requires": { "graphql": "^15.0.0", diff --git a/package.json b/package.json index 3213a627..e0f6a388 100644 --- a/package.json +++ b/package.json @@ -53,7 +53,7 @@ "nodemailer": "^6.7.5" }, "devDependencies": { - "@octokit/graphql-schema": "10.73.0", + "@octokit/graphql-schema": "^10.74.1", "@semantic-release/changelog": "6.0.1", "@semantic-release/commit-analyzer": "9.0.2", "@semantic-release/git": "10.0.1", diff --git a/src/entities/alert.ts b/src/entities/alert.ts index e43464d4..1060aced 100644 --- a/src/entities/alert.ts +++ b/src/entities/alert.ts @@ -27,3 +27,15 @@ export const toAlert = ( manifest: repositoryVulnerabilityAlert.vulnerableManifestFilename, createdAt: repositoryVulnerabilityAlert.createdAt, }) + +export const isActiveAlert = ( + repositoryVulnerabilityAlert: RepositoryVulnerabilityAlert, +): boolean => { + if ( + repositoryVulnerabilityAlert.dismissedAt === null && + repositoryVulnerabilityAlert.fixedAt === null + ) { + return true + } + return false +} diff --git a/src/fetch-alerts.ts b/src/fetch-alerts.ts index 2f99b797..e76d78de 100644 --- a/src/fetch-alerts.ts +++ b/src/fetch-alerts.ts @@ -1,4 +1,4 @@ -import { Alert, toAlert } from './entities' +import { Alert, toAlert, isActiveAlert } from './entities' import { Repository } from '@octokit/graphql-schema' import { getOctokit } from '@actions/github' @@ -18,6 +18,8 @@ export const fetchAlerts = async ( edges { node { id + dismissedAt + fixedAt repository { name owner { @@ -62,7 +64,7 @@ export const fetchAlerts = async ( if (gitHubAlerts) { const alerts: Alert[] = [] for (const gitHubAlert of gitHubAlerts) { - if (gitHubAlert && gitHubAlert.node) { + if (gitHubAlert && gitHubAlert.node && isActiveAlert(gitHubAlert.node)) { alerts.push(toAlert(gitHubAlert.node)) } }