Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
# slack_webhook: ${{ secrets.SLACK_WEBHOOK }}
# severity: low,medium
# ecosystem: npm,rubygems
# ignore_packages: foo#CVE-2021-21291,foo#CVE-2021-21292,bar
# count: 20
# pager_duty_integration_key: ${{ secrets.PAGER_DUTY_INTEGRATION_KEY }}
# zenduty_api_key: ${{ secrets.ZENDUTY_API_KEY }}
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ inputs:
description: 'Comma separated list of severities. E.g. low,medium,high,critical (NO SPACES BETWEEN COMMA AND SEVERITY)'
ecosystem:
description: 'A comma-separated list of ecosystems. If specified, only alerts for these ecosystems will be returned.'
ignore_packages:
description: 'A comma-separated list of package names with CVEs name (optional). If specified without CVE, alerts for this package will be ignored. If specified with CVE, only specified CVE for package will be ignored. E.g. foo#CVE-2021-21291,foo#CVE-2021-21292,bar'
branding:
icon: 'alert-octagon'
color: 'red'
Expand Down
263 changes: 191 additions & 72 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions src/alerts/enterprise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Octokit } from '@octokit/rest'

import { Alert, toEnterpriseAlert, PackageCveMap } from '../entities'

import { filterPackages } from './filters'

export const fetchEnterpriseAlerts = async (
gitHubPersonalAccessToken: string,
enterprise: string,
severity: string,
ecosystem: string,
ignorePackages: PackageCveMap,
count: number,
): Promise<Alert[] | []> => {
const octokit = new Octokit({
auth: gitHubPersonalAccessToken,
request: {
fetch,
},
})
const response = await octokit.dependabot.listAlertsForEnterprise({
enterprise,
state: 'open',
severity,
ecosystem: ecosystem.length > 0 ? ecosystem : undefined,
per_page: count,
})

return response.data
.filter((dependabotAlert) =>
filterPackages(dependabotAlert, ignorePackages),
)
.map(toEnterpriseAlert)
}
Loading