diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 7aa959680..fd0698c9b 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -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 diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 339a96dd6..991618754 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -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 @@ -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 @@ -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 }} @@ -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 @@ -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 @@ -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 @@ -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 }} diff --git a/.github/workflows/jira_close.yml b/.github/workflows/jira_close.yml index dfcb8bc73..0dacf7fab 100644 --- a/.github/workflows/jira_close.yml +++ b/.github/workflows/jira_close.yml @@ -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 diff --git a/.github/workflows/jira_issue.yml b/.github/workflows/jira_issue.yml index dd4b717bc..94a0a0890 100644 --- a/.github/workflows/jira_issue.yml +++ b/.github/workflows/jira_issue.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 87a48ab4b..8708c72a8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/snyk-issue.yml b/.github/workflows/snyk-issue.yml index ec96a2e4e..abcb2f980 100644 --- a/.github/workflows/snyk-issue.yml +++ b/.github/workflows/snyk-issue.yml @@ -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 }} diff --git a/.github/workflows/snyk-pr.yml b/.github/workflows/snyk-pr.yml index e21815ecf..51f952539 100644 --- a/.github/workflows/snyk-pr.yml +++ b/.github/workflows/snyk-pr.yml @@ -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 }} diff --git a/lib/util.js b/lib/util.js index dd1a3be07..90db5d079 100644 --- a/lib/util.js +++ b/lib/util.js @@ -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){ @@ -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), diff --git a/test/unit/util_test.js b/test/unit/util_test.js index feaa48541..e48e8f400 100644 --- a/test/unit/util_test.js +++ b/test/unit/util_test.js @@ -1357,7 +1357,7 @@ describe('Util', function () { { name: 'HTTP PROXY with authentication', isHttps: false, - httpProxy: 'http://hello:world@proxy.example.com:8080', + httpProxy: 'http://hello:world@proxy.example.com:8080', //# pragma: allowlist secret httpsProxy: undefined, noProxy: '*.amazonaws.com,*.my_company.com', result: { @@ -1372,7 +1372,7 @@ describe('Util', function () { { name: 'HTTPS PROXY with authentication without NO proxy', isHttps: true, - httpsProxy: 'https://user:pass@myproxy.server.com:1234', + httpsProxy: 'https://user:pass@myproxy.server.com:1234', //# pragma: allowlist secret result: { host: 'myproxy.server.com', user: 'user', @@ -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 }) => {