Skip to content

Commit

Permalink
fix: remove auth headers from bare clone of upstream repository @msagi
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieSlome committed May 9, 2024
1 parent 0be8da8 commit 4258c0c
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/proxy/processors/push-action/pullRemote.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,9 @@ const exec = async (req, action) => {

const cmd = `git clone ${action.url} --bare`;

// Retrieve authorization headers
const authorizationHeader = req.headers?.authorization;

// Validate the authorization headers
const authorizationValid =
authorizationHeader &&
typeof authorizationHeader === 'string' &&
authorizationHeader.includes('Basic ');

// Construct clone URL depending on presence of authorization headers
const cloneUrl = authorizationValid
? `https://${Buffer.from(authorizationHeader.split(' ')[1], 'base64')}@${action.url.replace(
/https*:\/\//,
'',
)}`
: action.url;

step.log(`Exectuting ${cmd}${authorizationValid ? ' with credentials' : ''}`);

const response = spawnSync('git', ['clone', cloneUrl, '--bare', '--progress'], {
step.log(`Exectuting ${cmd}`);

const response = spawnSync('git', ['clone', action.url, '--bare', '--progress'], {
cwd: action.proxyGitPath,
encoding: 'utf-8',
});
Expand Down

0 comments on commit 4258c0c

Please sign in to comment.