@@ -14,7 +14,8 @@ export interface CollectorOptions {
1414 enterprise ?: string ; // Enterprise slug to enumerate orgs
1515 org ?: string ; // Single org alternative
1616 repo ?: string ; // Single repo alternative
17- baseUrl ?: string ; // For GHES
17+ baseUrl ?: string ; // For GHES, EMU and Data Residency
18+ ghes ?: boolean ; // Is this a GHES instance?
1819 concurrency ?: number ; // parallel repo SBOM fetches
1920 includePrivate ?: boolean ;
2021 delayMsBetweenRepos ?: number ;
@@ -53,6 +54,7 @@ export class SbomCollector {
5354 this . opts = {
5455 token : o . token ,
5556 enterprise : o . enterprise ,
57+ ghes : o . ghes ?? false ,
5658 org : o . org ,
5759 repo : o . repo ,
5860 baseUrl : o . baseUrl ,
@@ -149,7 +151,7 @@ export class SbomCollector {
149151 process . stderr . write ( chalk . blue ( `Getting list of organizations for enterprise ${ this . opts . enterprise } ` ) + "\n" ) ;
150152 }
151153
152- const orgs = this . opts . org ? [ this . opts . org ] : this . opts . enterprise ? await this . listEnterpriseOrgs ( this . opts . enterprise ! ) : [ this . opts . repo . split ( "/" ) [ 0 ] ] ;
154+ const orgs = this . opts . org ? [ this . opts . org ] : this . opts . enterprise ? await this . listEnterpriseOrgs ( this . opts . enterprise , this . opts . ghes ) : [ this . opts . repo . split ( "/" ) [ 0 ] ] ;
153155 this . summary . orgs = orgs ;
154156
155157 // Pre-list all repos if showing progress bar so we know the total upfront
@@ -368,7 +370,7 @@ export class SbomCollector {
368370 return false ;
369371 }
370372
371- private async listEnterpriseOrgs ( enterprise : string ) : Promise < string [ ] > {
373+ private async listEnterpriseOrgs ( enterprise : string , ghes : boolean ) : Promise < string [ ] > {
372374 if ( ! this . octokit ) throw new Error ( "No Octokit instance" ) ;
373375 interface Org { login : string }
374376 try {
@@ -377,7 +379,7 @@ export class SbomCollector {
377379 let page = 1 ;
378380 let done = false ;
379381 while ( ! done ) {
380- const resp = await this . octokit . request ( "GET /enterprises/{enterprise}/orgs" , { enterprise, per_page, page } ) ;
382+ const resp = await this . octokit . request ( ghes ? "GET /orgs" : "GET /enterprises/{enterprise}/orgs" , { enterprise, per_page, page } ) ;
381383 const items = resp . data as unknown as Org [ ] ;
382384 for ( const o of items ) orgs . push ( o . login ) ;
383385 if ( items . length < per_page ) done = true ; else page ++ ;
0 commit comments