Skip to content
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

fix for SCA proxy bugs #80

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/services/clients/cxClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export class CxClient {

if (!httpClient)
{
if (this.config.enableProxy && this.config.proxyConfig && (this.proxyConfig.proxyHost != '' || this.proxyConfig.proxyUrl != '' || this.proxyConfig.sastProxyUrl != ''))
if (this.config.enableProxy && this.config.proxyConfig && this.proxyConfig.sastProxyUrl != '')
{
sastProxyConfig.proxyUrl = this.proxyConfig.sastProxyUrl != '' ? this.proxyConfig.sastProxyUrl : this.proxyConfig.proxyUrl;
sastProxyConfig.proxyUrl = this.proxyConfig.sastProxyUrl;
sastProxyConfig.sastProxyUrl = '';
sastProxyConfig.scaProxyUrl = '';
this.httpClient = new HttpClient(baseUrl, this.config.cxOrigin, this.config.cxOriginUrl, this.log, sastProxyConfig, this.sastConfig.cacert_chainFilePath);
Expand Down Expand Up @@ -158,12 +158,10 @@ export class CxClient {
let scaHttpClient: HttpClient;
let scaProxyConfig = JSON.parse(JSON.stringify(this.config.proxyConfig));

if (this.config.enableProxy && this.config.proxyConfig && (this.proxyConfig.proxyHost != '' || this.proxyConfig.proxyUrl != '' || this.proxyConfig.scaProxyUrl != ''))
if (this.config.enableProxy && this.config.proxyConfig && this.proxyConfig.scaProxyUrl != '')
{
scaProxyConfig.proxyUrl = this.proxyConfig.scaProxyUrl != '' ? this.proxyConfig.scaProxyUrl : this.proxyConfig.proxyUrl;
scaProxyConfig.sastProxyUrl = '';
scaProxyConfig.scaProxyUrl = '';
this.log.info("Overriten URL "+this.config.proxyConfig.sastProxyUrl);
scaProxyConfig.proxyUrl = this.proxyConfig.scaProxyUrl;
this.log.info("Overwritten URL " + scaProxyConfig.proxyUrl);
scaHttpClient = new HttpClient(this.scaConfig.apiUrl, this.config.cxOrigin, this.config.cxOriginUrl,this.log, scaProxyConfig, this.scaConfig.cacert_chainFilePath);
}
else
Expand Down
17 changes: 15 additions & 2 deletions src/services/clients/scaClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,24 @@ export class ScaClient {
this.log.debug(`Sending PUT request to ${uploadUrl}`);
const child_process = require('child_process');
let command;

if (this.scanConfig.enableProxy) {
this.log.info(`scanConfig.enableProxy is TRUE`);
}
if (this.proxyConfig){
this.log.info(`proxyConfig is TRUE`);
this.log.info(`SCA proxy URL: ` + this.proxyConfig.scaProxyUrl);
}
if (this.proxyConfig.scaProxyUrl){
this.log.info(`proxyConfig.scaProxyUrl is TRUE`);
}

if ( this.scanConfig.enableProxy && this.proxyConfig && this.proxyConfig.scaProxyUrl) {
let proxyUrl=ProxyHelper.getFormattedProxy(this.proxyConfig);
command = `curl -x ${proxyUrl} -X PUT -L "${uploadUrl}" -H "Content-Type:" -T "${file}"`;
command = `curl -x ${proxyUrl} -X PUT -L "${uploadUrl}" -H "Content-Type:" -T "${file}" --ssl-no-revoke`;
} else {
command = `curl -X PUT -L "${uploadUrl}" -H "Content-Type:" -T "${file}"`;
this.log.info(`No proxy being used to AWS upload`);
command = `curl -X PUT -L "${uploadUrl}" -H "Content-Type:" -T "${file}" --ssl-no-revoke`;
}
child_process.execSync(command, { stdio: 'pipe' });
}
Expand Down