Skip to content

Commit 30d09c4

Browse files
committed
feat(github): include full 2fa username list in summary
1 parent 558ae63 commit 30d09c4

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

packages/integration-platform/src/manifests/github/checks/two-factor-auth.ts

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ interface GitHubOrgMember {
1818
html_url: string;
1919
}
2020

21-
const MAX_USERNAMES_IN_DESCRIPTION = 20;
22-
const MAX_USERNAMES_IN_EVIDENCE = 100;
23-
2421
const getHttpStatus = (error: unknown): number | null => {
2522
if (
2623
typeof error === 'object' &&
@@ -72,15 +69,8 @@ const isRateLimitError = (error: unknown, errorMsg: string): boolean => {
7269
);
7370
};
7471

75-
const formatUsernamesPreview = (members: GitHubOrgMember[]): string => {
76-
const preview = members.slice(0, MAX_USERNAMES_IN_DESCRIPTION).map((member) => `@${member.login}`);
77-
const remaining = members.length - preview.length;
78-
79-
if (remaining > 0) {
80-
return `${preview.join(', ')} and ${remaining} more`;
81-
}
82-
return preview.join(', ');
83-
};
72+
const formatUsernames = (members: GitHubOrgMember[]): string =>
73+
members.map((member) => `@${member.login}`).join(', ');
8474

8575
export const twoFactorAuthCheck: IntegrationCheck = {
8676
id: 'two_factor_auth',
@@ -237,18 +227,15 @@ export const twoFactorAuthCheck: IntegrationCheck = {
237227
// Also emit a summary
238228
ctx.fail({
239229
title: `${without2FACount} member(s) without 2FA in ${org.login}`,
240-
description: `${without2FACount} member(s) in the ${org.login} organization do not have two-factor authentication enabled: ${formatUsernamesPreview(membersWithout2FA)}`,
230+
description: `${without2FACount} member(s) in the ${org.login} organization do not have two-factor authentication enabled: ${formatUsernames(membersWithout2FA)}`,
241231
resourceType: 'organization',
242232
resourceId: `${org.login}/2fa-summary`,
243233
severity: 'high',
244234
remediation: `1. Go to https://github.com/organizations/${org.login}/settings/security\n2. Under "Authentication security", check "Require two-factor authentication for everyone"\n3. This will require all existing and future members to enable 2FA`,
245235
evidence: {
246236
organization: org.login,
247237
membersWithout2FA: without2FACount,
248-
sampleUsernames: membersWithout2FA
249-
.slice(0, MAX_USERNAMES_IN_EVIDENCE)
250-
.map((member) => member.login),
251-
usernamesTruncated: membersWithout2FA.length > MAX_USERNAMES_IN_EVIDENCE,
238+
usernames: membersWithout2FA.map((member) => member.login),
252239
checkedAt,
253240
},
254241
});

0 commit comments

Comments
 (0)