Skip to content

Commit 1657da3

Browse files
authored
feat: Added github.com/dependabot annotation (#2646)
* added github.com/dependabot annotation * remove const * Added github.com/dependabot annotation
1 parent 5d4f070 commit 1657da3

5 files changed

Lines changed: 10 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dependabot': patch
3+
---
4+
5+
Added github.com/dependabot annotation

workspaces/scorecard/examples/components/dependabot-scorecard-only.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ metadata:
66
name: dependabot-scorecard-only
77
annotations:
88
github.com/project-slug: redhat-developer/rhdh-plugins
9+
github.com/dependabot: 'true'
910
backstage.io/source-location: url:https://github.com/redhat-developer/rhdh-plugins
1011
spec:
1112
type: service

workspaces/scorecard/plugins/scorecard-backend-module-dependabot/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Adds Dependabot alerts as a scorecard metric (`dependabot.alerts`, 0–9 from se
44

55
**Install:** `yarn workspace backend add @red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dependabot` then `backend.add(import('@red-hat-developer-hub/backstage-plugin-scorecard-backend-module-dependabot'))`.
66

7-
**Setup:** Entities need `github.com/project-slug: owner/repo`. GitHub token must have `security_events` (or Dependabot read) so the backend can call the Dependabot API.
7+
**Setup:** Entities need `github.com/project-slug: owner/repo` and `github.com/dependabot: 'true'` (exact string) to opt in. GitHub token must have `security_events` (or Dependabot read) so the backend can call the Dependabot API.
88

99
**How it works:** **DependabotClient** fetches open alerts from the GitHub API (by severity, with pagination). **DependabotMetricProvider** (one per severity) uses the client to score entities. The **factory** (`createDependabotMetricProvider` / `createDependabotMetricProviders`) builds single or all-four providers; the module registers the four (critical, high, medium, low) with the scorecard backend.

workspaces/scorecard/plugins/scorecard-backend-module-dependabot/src/metricProviders/DependabotMetricProvider.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('DependabotMetricProvider', () => {
130130
});
131131

132132
describe('getCatalogFilter', () => {
133-
it('requires github.com/project-slug annotation', () => {
133+
it('requires project-slug and dependabot annotation value true', () => {
134134
const provider = new DependabotMetricProvider(
135135
mockConfig,
136136
mockLogger,
@@ -140,6 +140,7 @@ describe('DependabotMetricProvider', () => {
140140
expect(
141141
filter['metadata.annotations.github.com/project-slug'],
142142
).toBeDefined();
143+
expect(filter['metadata.annotations.github.com/dependabot']).toBe('true');
143144
});
144145
});
145146

workspaces/scorecard/plugins/scorecard-backend-module-dependabot/src/metricProviders/DependabotMetricProvider.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class DependabotMetricProvider implements MetricProvider<'number'> {
8888
getCatalogFilter(): Record<string, string | symbol | (string | symbol)[]> {
8989
return {
9090
'metadata.annotations.github.com/project-slug': CATALOG_FILTER_EXISTS,
91+
'metadata.annotations.github.com/dependabot': 'true',
9192
};
9293
}
9394

0 commit comments

Comments
 (0)