Skip to content

Commit

Permalink
fix: Dismissed or Fixed alerts should not be included in the list (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
kunalnagar authored Jun 30, 2022
1 parent 8a24022 commit 2d3d468
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions src/entities/alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
6 changes: 4 additions & 2 deletions src/fetch-alerts.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -18,6 +18,8 @@ export const fetchAlerts = async (
edges {
node {
id
dismissedAt
fixedAt
repository {
name
owner {
Expand Down Expand Up @@ -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))
}
}
Expand Down

0 comments on commit 2d3d468

Please sign in to comment.