@@ -61,7 +61,7 @@ export class UiProvider implements vscode.WebviewViewProvider {
6161 this . checkCodeQLEnabled ( ) ;
6262 break ;
6363 case "updateRepositoryInfo" :
64- this . updateRepositoryInfo ( message . owner , message . repo ) ;
64+ this . updateRepositoryInfo ( message . owner , message . repo , message . url ) ;
6565 break ;
6666 case "runLocalScan" :
6767 this . runLocalScan ( ) ;
@@ -98,6 +98,7 @@ export class UiProvider implements vscode.WebviewViewProvider {
9898 `Saving configuration: ${ JSON . stringify ( config , null , 2 ) } `
9999 ) ;
100100
101+ // Update the standard workspace configuration
101102 await Promise . all ( [
102103 workspaceConfig . update (
103104 "suites" ,
@@ -115,6 +116,38 @@ export class UiProvider implements vscode.WebviewViewProvider {
115116 vscode . ConfigurationTarget . Workspace
116117 ) ,
117118 ] ) ;
119+
120+ // Update GitHub URL if provided
121+ if ( config . githubUrl ) {
122+ let apiUrl = "https://api.github.com" ;
123+
124+ if ( config . githubUrl ) {
125+ if ( config . githubUrl === "github.com" || config . githubUrl === "https://github.com" ) {
126+ apiUrl = "https://api.github.com" ;
127+ } else {
128+ // Remove https:// prefix if present
129+ const cleanUrl = config . githubUrl . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
130+
131+ // For GitHub Enterprise, convert to API URL format
132+ apiUrl = `https://${ cleanUrl } ` ;
133+ if ( ! apiUrl . includes ( '/api/v3' ) ) {
134+ apiUrl = apiUrl . endsWith ( '/' ) ? `${ apiUrl } api/v3` : `${ apiUrl } /api/v3` ;
135+ }
136+ }
137+ }
138+
139+ this . logger . info (
140+ "UiProvider" ,
141+ "Updating GitHub base URL configuration" ,
142+ { userInput : config . githubUrl , apiUrl }
143+ ) ;
144+
145+ await workspaceConfig . update (
146+ "github.baseUrl" ,
147+ apiUrl ,
148+ vscode . ConfigurationTarget . Global
149+ ) ;
150+ }
118151
119152 this . logger . logServiceCall (
120153 "UiProvider" ,
@@ -219,6 +252,7 @@ export class UiProvider implements vscode.WebviewViewProvider {
219252 githubToken : config . get < string > ( "github.token" , "" ) ,
220253 githubOwner : config . get < string > ( "github.owner" , "" ) ,
221254 githubRepo : config . get < string > ( "github.repo" , "" ) ,
255+ githubUrl : config . get < string > ( "github.baseUrl" , "https://api.github.com" ) ,
222256 githubLanguages : config . get < string [ ] > ( "github.languages" , [ ] ) ,
223257 suites : config . get < string [ ] > ( "suites" , [ "default" ] ) ,
224258 languages : languages ,
@@ -251,8 +285,10 @@ export class UiProvider implements vscode.WebviewViewProvider {
251285 }
252286
253287 try {
254- // Update the service with the current token
255- this . _githubService . updateToken ( token ) ;
288+ const baseUrl = config . get < string > ( "github.baseUrl" ) ;
289+
290+ // Update the service with the current token and base URL
291+ this . _githubService . updateToken ( token , baseUrl ) ;
256292
257293 // Test the connection by getting repository info
258294 await this . _githubService . getRepositoryInfo ( ) ;
@@ -1115,9 +1151,9 @@ export class UiProvider implements vscode.WebviewViewProvider {
11151151 * @param owner Repository owner
11161152 * @param repo Repository name
11171153 */
1118- private async updateRepositoryInfo ( owner : string , repo : string ) : Promise < void > {
1154+ private async updateRepositoryInfo ( owner : string , repo : string , url ?: string ) : Promise < void > {
11191155 this . logger . logServiceCall ( "UiProvider" , "updateRepositoryInfo" , "started" , {
1120- owner, repo
1156+ owner, repo, url
11211157 } ) ;
11221158
11231159 if ( ! owner || ! repo ) {
@@ -1157,6 +1193,30 @@ export class UiProvider implements vscode.WebviewViewProvider {
11571193 this . logger . debug ( "UiProvider" , "Updating github.repo setting" , { repo } ) ;
11581194 await config . update ( "github.repo" , repo , vscode . ConfigurationTarget . Workspace ) ;
11591195
1196+ // Update GitHub URL if provided
1197+ if ( url ) {
1198+ // Convert web URL to API URL
1199+ let apiUrl = "https://api.github.com" ; // Default API URL
1200+
1201+ if ( url ) {
1202+ if ( url === "github.com" || url === "https://github.com" ) {
1203+ apiUrl = "https://api.github.com" ;
1204+ } else {
1205+ // Remove https:// prefix if present
1206+ const cleanUrl = url . replace ( / ^ h t t p s ? : \/ \/ / , '' ) ;
1207+
1208+ // For GitHub Enterprise, convert to API URL
1209+ apiUrl = `https://${ cleanUrl } ` ;
1210+ if ( ! apiUrl . includes ( '/api/v3' ) ) {
1211+ apiUrl = apiUrl . endsWith ( '/' ) ? `${ apiUrl } api/v3` : `${ apiUrl } /api/v3` ;
1212+ }
1213+ }
1214+ }
1215+
1216+ this . logger . debug ( "UiProvider" , "Updating github.baseUrl setting" , { url, apiUrl } ) ;
1217+ await config . update ( "github.baseUrl" , apiUrl , vscode . ConfigurationTarget . Global ) ;
1218+ }
1219+
11601220 this . logger . info (
11611221 "UiProvider" ,
11621222 `Repository information updated from ${ oldOwner } /${ oldRepo } to ${ owner } /${ repo } `
@@ -2350,11 +2410,17 @@ export class UiProvider implements vscode.WebviewViewProvider {
23502410
23512411 <div class="section" id="repo-settings" style="display: block;">
23522412 <h3 class="collapsible-header" onclick="toggleRepoSection()">🔗 GitHub Repository <span class="toggle-icon">▼</span></h3>
2353- <div id="codeqlStatusMessage" style="margin-bottom: 15px; padding: 10px; border-radius: 6px; display: none;">
2354- <!-- CodeQL status will be shown here -->
2355- </div>
2356-
23572413 <div id="repo-content" class="collapsible-content">
2414+ <div id="codeqlStatusMessage" style="margin-bottom: 15px; padding: 10px; border-radius: 6px; display: none;">
2415+ <!-- CodeQL status will be shown here -->
2416+ </div>
2417+
2418+ <div class="form-group">
2419+ <label for="githubUrl">GitHub URL:</label>
2420+ <input type="text" id="githubUrl" placeholder="e.g., https://github.com or https://github.yourenterprise.com">
2421+ <div class="help-text">The base URL of your GitHub instance (leave empty for github.com)</div>
2422+ </div>
2423+
23582424 <div class="form-group">
23592425 <label for="githubOwner">Repository Owner/Organization:</label>
23602426 <input type="text" id="githubOwner" placeholder="e.g., octocat">
@@ -2520,10 +2586,15 @@ export class UiProvider implements vscode.WebviewViewProvider {
25202586
25212587 function saveConfig() {
25222588 console.log('Saving configuration...');
2589+
2590+ // Get GitHub URL
2591+ const githubUrl = document.getElementById('githubUrl').value.trim();
2592+
25232593 const config = {
25242594 suites: [getSelectedSuite()],
25252595 languages: getSelectedLanguages(),
2526- threatModel: getSelectedThreatModel()
2596+ threatModel: getSelectedThreatModel(),
2597+ githubUrl: githubUrl
25272598 };
25282599
25292600 console.log('Configuration to save:', config);
@@ -2736,6 +2807,7 @@ export class UiProvider implements vscode.WebviewViewProvider {
27362807 function updateRepositoryInfo() {
27372808 const owner = document.getElementById('githubOwner').value.trim();
27382809 const repo = document.getElementById('githubRepo').value.trim();
2810+ const githubUrl = document.getElementById('githubUrl').value.trim();
27392811
27402812 if (!owner || !repo) {
27412813 showMessage('Repository owner and name are required', 'error');
@@ -2749,7 +2821,8 @@ export class UiProvider implements vscode.WebviewViewProvider {
27492821 vscode.postMessage({
27502822 command: 'updateRepositoryInfo',
27512823 owner: owner,
2752- repo: repo
2824+ repo: repo,
2825+ url: githubUrl
27532826 });
27542827 }
27552828
@@ -3040,6 +3113,11 @@ export class UiProvider implements vscode.WebviewViewProvider {
30403113 console.log('No languages found in config, defaulting to empty selection');
30413114 }
30423115
3116+ // Set GitHub URL if available
3117+ if (config.githubUrl) {
3118+ document.getElementById('githubUrl').value = config.githubUrl.replace('https://api.github.com', '');
3119+ }
3120+
30433121 // Check CodeQL status automatically if repository is configured
30443122 if (config.githubOwner && config.githubRepo) {
30453123 setRepositoryInfo(config.githubOwner, config.githubRepo);
0 commit comments