Skip to content

Commit

Permalink
Merge branch 'master' into SNOW-1825607
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jy authored Nov 27, 2024
2 parents d280e02 + 753aa3d commit f746eae
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Install dependencies
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
WHITESOURCE_API_KEY: ${{ secrets.WHITESOURCE_API_KEY }}
run: ./ci/build.sh
- name: Upload Build Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts
Expand All @@ -52,14 +52,14 @@ jobs:
nodeVersion: [ '14.x', '16.x', '18.x', '20.x', '22.x']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodeVersion }}
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
- name: Download Build Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
Expand All @@ -73,7 +73,7 @@ jobs:
CLOUD_PROVIDER: ${{ matrix.cloud }}
run: /usr/local/bin/bash ./ci/test_mac.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
Expand All @@ -90,15 +90,15 @@ jobs:
nodeVersion: [ '14.x', '16.x', '18.x', '20.x', '22.x']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodeVersion }}
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.7'
architecture: 'x64'
- name: Download Build Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
Expand All @@ -121,7 +121,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
Expand All @@ -145,12 +145,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Tests
Expand All @@ -160,7 +160,7 @@ jobs:
CLOUD_PROVIDER: ${{ matrix.cloud }}
run: ./ci/test_ubuntu.sh
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
# without the token code cov may fail because of Github limits https://github.com/codecov/codecov-action/issues/557
token: ${{ secrets.CODE_COV_UPLOAD_TOKEN }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jira_close.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: snowflakedb/gh-actions
ref: jira_v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/jira_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: ((github.event_name == 'issue_comment' && github.event.comment.body == 'recreate jira' && github.event.comment.user.login == 'sfc-gh-mkeller') || (github.event_name == 'issues' && github.event.pull_request.user.login != 'whitesource-for-github-com[bot]'))
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
repository: snowflakedb/gh-actions
ref: jira_v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '18.x'
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout action
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: snowflakedb/whitesource-actions
token: ${{ secrets.WHITESOURCE_ACTION_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/snyk-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
if: ${{ github.event.pull_request.user.login == 'sfc-gh-snyk-sca-sa' }}
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0

- name: checkout action
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: snowflakedb/whitesource-actions
token: ${{ secrets.WHITESOURCE_ACTION_TOKEN }}
Expand Down
11 changes: 10 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,14 @@ exports.validateEmptyString = function (value) {
};

exports.getProxyFromEnv = function (isHttps = true) {
const getDefaultPortIfNotSet = (proxyFromEnv) => {
const isProxyProtocolHttps = proxyFromEnv.protocol === 'https:';
if (!proxyFromEnv.port) {
return isProxyProtocolHttps ? 443 : 80;
} else {
return proxyFromEnv.port;
}
};
const protocol = isHttps ? 'https' : 'http';
let proxyFromEnv = this.getEnvVar(`${protocol}_proxy`);
if (!proxyFromEnv){
Expand All @@ -874,9 +882,10 @@ exports.getProxyFromEnv = function (isHttps = true) {
proxyFromEnv = 'http' + '://' + proxyFromEnv;
}
proxyFromEnv = new URL(proxyFromEnv);
const port = getDefaultPortIfNotSet(proxyFromEnv);
const proxy = {
host: this.validateEmptyString(proxyFromEnv.hostname),
port: Number(this.validateEmptyString(proxyFromEnv.port)),
port: Number(port),
user: this.validateEmptyString(proxyFromEnv.username),
password: this.validateEmptyString(proxyFromEnv.password),
protocol: this.validateEmptyString(proxyFromEnv.protocol),
Expand Down
40 changes: 38 additions & 2 deletions test/unit/util_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ describe('Util', function () {
{
name: 'HTTP PROXY with authentication',
isHttps: false,
httpProxy: 'http://hello:[email protected]:8080',
httpProxy: 'http://hello:[email protected]:8080', //# pragma: allowlist secret
httpsProxy: undefined,
noProxy: '*.amazonaws.com,*.my_company.com',
result: {
Expand All @@ -1372,7 +1372,7 @@ describe('Util', function () {
{
name: 'HTTPS PROXY with authentication without NO proxy',
isHttps: true,
httpsProxy: 'https://user:[email protected]:1234',
httpsProxy: 'https://user:[email protected]:1234', //# pragma: allowlist secret
result: {
host: 'myproxy.server.com',
user: 'user',
Expand All @@ -1394,6 +1394,42 @@ describe('Util', function () {
noProxy: '*.amazonaws.com|*.my_company.com|*.test.com',
},
},
{
name: 'HTTPS PROXY with authentication without port and protocol',
isHttps: true,
noProxy: '*.amazonaws.com,*.my_company.com,*.test.com',
httpsProxy: 'myproxy.server.com',
result: {
host: 'myproxy.server.com',
port: 80,
protocol: 'http:',
noProxy: '*.amazonaws.com|*.my_company.com|*.test.com',
},
},
{
name: 'HTTP PROXY with authentication without port and protocol',
isHttps: false,
noProxy: '*.amazonaws.com,*.my_company.com,*.test.com',
httpProxy: 'myproxy.server.com',
result: {
host: 'myproxy.server.com',
port: 80,
protocol: 'http:',
noProxy: '*.amazonaws.com|*.my_company.com|*.test.com',
},
},
{
name: 'HTTPS PROXY with authentication without port',
isHttps: true,
noProxy: '*.amazonaws.com,*.my_company.com,*.test.com',
httpsProxy: 'https://myproxy.server.com',
result: {
host: 'myproxy.server.com',
port: 443,
protocol: 'https:',
noProxy: '*.amazonaws.com|*.my_company.com|*.test.com',
},
},
];

testCases.forEach(({ name, isHttps, httpsProxy, httpProxy, noProxy, result }) => {
Expand Down

0 comments on commit f746eae

Please sign in to comment.