-
Notifications
You must be signed in to change notification settings - Fork 1
Audit-log #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Audit-log #11
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,130 @@ | ||||||
| import { Octokit } from 'octokit'; | ||||||
|
|
||||||
| /* | ||||||
|
|
||||||
| action:repo.remove_member | ||||||
| org:software | ||||||
| created:>=2025-11-17T22:00:00Z | ||||||
| created:<2025-11-17T23:00:00Z | ||||||
| repo:software/dtc-release-cicd | ||||||
|
|
||||||
| */ | ||||||
| /** | ||||||
| * Get audit log activity for a repository filtered by usernames and optional criteria | ||||||
| * @param octokit - The Octokit instance | ||||||
| * @param orgName - The organization name | ||||||
| * @param repoName - The repository name | ||||||
| * @param usernames - Array of usernames to filter audit log events by | ||||||
| * @param sinceIso - Optional ISO date string to filter events after this date | ||||||
| * @param action - Optional action type to filter by (e.g., "repo.create", "repo.destroy") | ||||||
| * @param created - Optional creation date filter (e.g., ">=2025-11-17T22:00:00Z") | ||||||
| * @param include - Filter by event source: "all", "web", or "git". Defaults to "all" | ||||||
| * @yields Objects containing actor username, action type, and event date | ||||||
| */ | ||||||
| export async function* getAuditLogActivity({ | ||||||
| octokit, | ||||||
| orgName, | ||||||
| enterpriseName, | ||||||
| repoName, | ||||||
| usernames, | ||||||
| sinceIso, | ||||||
| action, | ||||||
| created, | ||||||
| include = 'all', | ||||||
| type = 'org', | ||||||
| }: { | ||||||
| octokit: Octokit; | ||||||
| orgName?: string; | ||||||
| enterpriseName?: string; | ||||||
| repoName?: string; | ||||||
| usernames?: string[]; | ||||||
| sinceIso?: string; | ||||||
| action?: string | string[]; | ||||||
| created?: string | string[]; | ||||||
| include?: 'all' | 'web' | 'git'; | ||||||
| type: 'org' | 'enterprise'; | ||||||
| }): AsyncGenerator<{ actor: string; action: string; date: Date; props: any }> { | ||||||
| if (type == 'org' && !orgName) { | ||||||
|
||||||
| throw new Error('orgName is required'); | ||||||
| } | ||||||
| if (type == 'enterprise' && !enterpriseName) { | ||||||
|
||||||
| if (type == 'enterprise' && !enterpriseName) { | |
| if (type === 'enterprise' && !enterpriseName) { |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential bug when repoName is provided without orgName. The repoPhrase construction assumes orgName is available when repoName is provided (line 78), but orgName is optional. This could result in an invalid phrase like repo:undefined/repoName if repoName is provided but orgName is not.
| const repoPhrase = repoName ? `repo:${orgName}/${repoName}` : ''; | |
| const repoPhrase = repoName && orgName ? `repo:${orgName}/${repoName}` : ''; |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use strict equality operators. Should use === instead of == for type-safe comparison.
| type == 'org' | |
| type === 'org' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated documentation. The JSDoc comment does not mention the
enterpriseName,type,created, orincludeparameters, but these are part of the function signature. The documentation should be updated to reflect all parameters.