mirror of
				https://code.forgejo.org/actions/checkout.git
				synced 2025-10-31 04:52:29 +00:00 
			
		
		
		
	.
This commit is contained in:
		
							parent
							
								
									adfd38e27a
								
							
						
					
					
						commit
						b2405e40be
					
				
					 2 changed files with 6 additions and 70 deletions
				
			
		
							
								
								
									
										35
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										35
									
								
								dist/index.js
									
										
									
									
										vendored
									
									
								
							|  | @ -5469,12 +5469,10 @@ function getSource(settings) { | ||||||
|             if (!(yield git.tryDisableAutomaticGarbageCollection())) { |             if (!(yield git.tryDisableAutomaticGarbageCollection())) { | ||||||
|                 core.warning(`Unable to turn off git automatic garbage collection. The git fetch operation may trigger garbage collection and cause a delay.`); |                 core.warning(`Unable to turn off git automatic garbage collection. The git fetch operation may trigger garbage collection and cause a delay.`); | ||||||
|             } |             } | ||||||
|             // Remove possible previous proxy and extraheader
 |             // Remove possible previous extraheader
 | ||||||
|             // await removeGitConfig(git, proxyConfigKey)
 |  | ||||||
|             yield removeGitConfig(git, authConfigKey); |             yield removeGitConfig(git, authConfigKey); | ||||||
|             try { |             try { | ||||||
|                 // Config proxy and extraheader
 |                 // Config extraheader
 | ||||||
|                 // await configureProxy(git)
 |  | ||||||
|                 yield configureAuthToken(git, settings.authToken); |                 yield configureAuthToken(git, settings.authToken); | ||||||
|                 // LFS install
 |                 // LFS install
 | ||||||
|                 if (settings.lfs) { |                 if (settings.lfs) { | ||||||
|  | @ -5498,7 +5496,6 @@ function getSource(settings) { | ||||||
|             } |             } | ||||||
|             finally { |             finally { | ||||||
|                 if (!settings.persistCredentials) { |                 if (!settings.persistCredentials) { | ||||||
|                     // await removeGitConfig(git, proxyConfigKey)
 |  | ||||||
|                     yield removeGitConfig(git, authConfigKey); |                     yield removeGitConfig(git, authConfigKey); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  | @ -5513,7 +5510,6 @@ function cleanup(repositoryPath) { | ||||||
|             !fsHelper.fileExistsSync(path.join(repositoryPath, '.git', 'config'))) { |             !fsHelper.fileExistsSync(path.join(repositoryPath, '.git', 'config'))) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // Remove proxy and extraheader
 |  | ||||||
|         let git; |         let git; | ||||||
|         try { |         try { | ||||||
|             git = yield gitCommandManager.CreateCommandManager(repositoryPath, false); |             git = yield gitCommandManager.CreateCommandManager(repositoryPath, false); | ||||||
|  | @ -5521,7 +5517,7 @@ function cleanup(repositoryPath) { | ||||||
|         catch (_a) { |         catch (_a) { | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // await removeGitConfig(git, proxyConfigKey)
 |         // Remove extraheader
 | ||||||
|         yield removeGitConfig(git, authConfigKey); |         yield removeGitConfig(git, authConfigKey); | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  | @ -5613,31 +5609,6 @@ function prepareExistingDirectory(git, repositoryPath, repositoryUrl, clean) { | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
| // async function configureProxy(git: IGitCommandManager): Promise<void> {
 |  | ||||||
| //   const proxyUrl = httpClient.getProxyUrl(serverUrl)
 |  | ||||||
| //   const parsedUrl = url.parse(proxyUrl)
 |  | ||||||
| //   const placeholder = parsedUrl.auth
 |  | ||||||
| //     ? proxyUrl.replace(parsedUrl.auth, '***')
 |  | ||||||
| //     : ''
 |  | ||||||
| //   // Configure a placeholder value. This approach avoids the credential being captured
 |  | ||||||
| //   // by process creation audit events, which are commonly logged. For more information,
 |  | ||||||
| //   // refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
 |  | ||||||
| //   await git.config(proxyConfigKey, placeholder || proxyUrl)
 |  | ||||||
| //   if (placeholder) {
 |  | ||||||
| //     // Replace the value in the config file
 |  | ||||||
| //     const configPath = path.join(git.getWorkingDirectory(), '.git', 'config')
 |  | ||||||
| //     let content = (await fs.promises.readFile(configPath)).toString()
 |  | ||||||
| //     const placeholderIndex = content.indexOf(placeholder)
 |  | ||||||
| //     if (
 |  | ||||||
| //       placeholderIndex < 0 ||
 |  | ||||||
| //       placeholderIndex != content.lastIndexOf(placeholder)
 |  | ||||||
| //     ) {
 |  | ||||||
| //       throw new Error('Unable to replace auth placeholder in .git/config')
 |  | ||||||
| //     }
 |  | ||||||
| //     content = content.replace(placeholder, proxyUrl)
 |  | ||||||
| //     await fs.promises.writeFile(configPath, content)
 |  | ||||||
| //   }
 |  | ||||||
| // }
 |  | ||||||
| function configureAuthToken(git, authToken) { | function configureAuthToken(git, authToken) { | ||||||
|     return __awaiter(this, void 0, void 0, function* () { |     return __awaiter(this, void 0, void 0, function* () { | ||||||
|         // Configure a placeholder value. This approach avoids the credential being captured
 |         // Configure a placeholder value. This approach avoids the credential being captured
 | ||||||
|  |  | ||||||
|  | @ -3,17 +3,14 @@ import * as fs from 'fs' | ||||||
| import * as fsHelper from './fs-helper' | import * as fsHelper from './fs-helper' | ||||||
| import * as gitCommandManager from './git-command-manager' | import * as gitCommandManager from './git-command-manager' | ||||||
| import * as githubApiHelper from './github-api-helper' | import * as githubApiHelper from './github-api-helper' | ||||||
| import * as httpClient from '@actions/http-client' |  | ||||||
| import * as io from '@actions/io' | import * as io from '@actions/io' | ||||||
| import * as path from 'path' | import * as path from 'path' | ||||||
| import * as refHelper from './ref-helper' | import * as refHelper from './ref-helper' | ||||||
| import * as stateHelper from './state-helper' | import * as stateHelper from './state-helper' | ||||||
| import * as url from 'url' |  | ||||||
| import {IGitCommandManager} from './git-command-manager' | import {IGitCommandManager} from './git-command-manager' | ||||||
| 
 | 
 | ||||||
| const serverUrl = 'https://github.com/' | const serverUrl = 'https://github.com/' | ||||||
| const authConfigKey = `http.${serverUrl}.extraheader` | const authConfigKey = `http.${serverUrl}.extraheader` | ||||||
| // const proxyConfigKey = `http.${serverUrl}.proxy`
 |  | ||||||
| 
 | 
 | ||||||
| export interface ISourceSettings { | export interface ISourceSettings { | ||||||
|   repositoryPath: string |   repositoryPath: string | ||||||
|  | @ -95,13 +92,11 @@ export async function getSource(settings: ISourceSettings): Promise<void> { | ||||||
|       ) |       ) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // Remove possible previous proxy and extraheader
 |     // Remove possible previous extraheader
 | ||||||
|     // await removeGitConfig(git, proxyConfigKey)
 |  | ||||||
|     await removeGitConfig(git, authConfigKey) |     await removeGitConfig(git, authConfigKey) | ||||||
| 
 | 
 | ||||||
|     try { |     try { | ||||||
|       // Config proxy and extraheader
 |       // Config extraheader
 | ||||||
|       // await configureProxy(git)
 |  | ||||||
|       await configureAuthToken(git, settings.authToken) |       await configureAuthToken(git, settings.authToken) | ||||||
| 
 | 
 | ||||||
|       // LFS install
 |       // LFS install
 | ||||||
|  | @ -134,7 +129,6 @@ export async function getSource(settings: ISourceSettings): Promise<void> { | ||||||
|       await git.log1() |       await git.log1() | ||||||
|     } finally { |     } finally { | ||||||
|       if (!settings.persistCredentials) { |       if (!settings.persistCredentials) { | ||||||
|         // await removeGitConfig(git, proxyConfigKey)
 |  | ||||||
|         await removeGitConfig(git, authConfigKey) |         await removeGitConfig(git, authConfigKey) | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|  | @ -150,7 +144,6 @@ export async function cleanup(repositoryPath: string): Promise<void> { | ||||||
|     return |     return | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // Remove proxy and extraheader
 |  | ||||||
|   let git: IGitCommandManager |   let git: IGitCommandManager | ||||||
|   try { |   try { | ||||||
|     git = await gitCommandManager.CreateCommandManager(repositoryPath, false) |     git = await gitCommandManager.CreateCommandManager(repositoryPath, false) | ||||||
|  | @ -158,7 +151,7 @@ export async function cleanup(repositoryPath: string): Promise<void> { | ||||||
|     return |     return | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // await removeGitConfig(git, proxyConfigKey)
 |   // Remove extraheader
 | ||||||
|   await removeGitConfig(git, authConfigKey) |   await removeGitConfig(git, authConfigKey) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -268,34 +261,6 @@ async function prepareExistingDirectory( | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // async function configureProxy(git: IGitCommandManager): Promise<void> {
 |  | ||||||
| //   const proxyUrl = httpClient.getProxyUrl(serverUrl)
 |  | ||||||
| //   const parsedUrl = url.parse(proxyUrl)
 |  | ||||||
| //   const placeholder = parsedUrl.auth
 |  | ||||||
| //     ? proxyUrl.replace(parsedUrl.auth, '***')
 |  | ||||||
| //     : ''
 |  | ||||||
| 
 |  | ||||||
| //   // Configure a placeholder value. This approach avoids the credential being captured
 |  | ||||||
| //   // by process creation audit events, which are commonly logged. For more information,
 |  | ||||||
| //   // refer to https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/manage/component-updates/command-line-process-auditing
 |  | ||||||
| //   await git.config(proxyConfigKey, placeholder || proxyUrl)
 |  | ||||||
| 
 |  | ||||||
| //   if (placeholder) {
 |  | ||||||
| //     // Replace the value in the config file
 |  | ||||||
| //     const configPath = path.join(git.getWorkingDirectory(), '.git', 'config')
 |  | ||||||
| //     let content = (await fs.promises.readFile(configPath)).toString()
 |  | ||||||
| //     const placeholderIndex = content.indexOf(placeholder)
 |  | ||||||
| //     if (
 |  | ||||||
| //       placeholderIndex < 0 ||
 |  | ||||||
| //       placeholderIndex != content.lastIndexOf(placeholder)
 |  | ||||||
| //     ) {
 |  | ||||||
| //       throw new Error('Unable to replace auth placeholder in .git/config')
 |  | ||||||
| //     }
 |  | ||||||
| //     content = content.replace(placeholder, proxyUrl)
 |  | ||||||
| //     await fs.promises.writeFile(configPath, content)
 |  | ||||||
| //   }
 |  | ||||||
| // }
 |  | ||||||
| 
 |  | ||||||
| async function configureAuthToken( | async function configureAuthToken( | ||||||
|   git: IGitCommandManager, |   git: IGitCommandManager, | ||||||
|   authToken: string |   authToken: string | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue