-
Notifications
You must be signed in to change notification settings - Fork 642
fix: [CLI-859] Replace global-agent
from ts-binary-wrapper
with proxy-agent
#6085
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
base: main
Are you sure you want to change the base?
fix: [CLI-859] Replace global-agent
from ts-binary-wrapper
with proxy-agent
#6085
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) ✅ code/snyk check is complete. No issues have been found. (View Details) |
|
42cec1f
to
2d7018e
Compare
global-agent
from ts-binary-wrapper
global-agent
from ts-binary-wrapper
with proxy-agent
2d7018e
to
5212c00
Compare
process.env.GLOBAL_AGENT_ENVIRONMENT_VARIABLE_NAMESPACE = ''; | ||
process.env.HTTPS_PROXY = | ||
process.env.HTTPS_PROXY ?? process.env.https_proxy ?? ''; | ||
process.env.HTTP_PROXY = process.env.HTTP_PROXY ?? process.env.http_proxy ?? ''; | ||
process.env.NO_PROXY = process.env.NO_PROXY ?? process.env.no_proxy ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d074860
to
0574624
Compare
0574624
to
2d1a918
Compare
"rootDir": "./src", | ||
"esModuleInterop": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this wasn't needed before. But I would get TypeScript errors about https
and lru-cache
both on CircleCI and locally.
node_modules/get-uri/dist/http.d.ts:5:8 - error TS1192: Module '"http"' has no default export.
5 import http_ from 'http';
~~~~~
node_modules/get-uri/dist/http.d.ts:6:8 - error TS1192: Module '"https"' has no default export.
6 import https from 'https';
~~~~~
node_modules/proxy-agent/dist/index.d.ts:3:8 - error TS1259: Module '"/Users/kasparmoss/git/snyk/cli/ts-binary-wrapper/node_modules/proxy-agent/node_modules/lru-cache/index"' can only be default-imported using the 'esModuleInterop' flag
3 import LRUCache from 'lru-cache';
449bab1
to
c833b4f
Compare
688a3e0
to
11936cf
Compare
11936cf
to
a0739ab
Compare
Makefile
Outdated
@@ -187,7 +187,7 @@ $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt: | |||
.PHONY: build-binary-wrapper | |||
build-binary-wrapper: pre-build-binary-wrapper $(BINARY_WRAPPER_DIR)/src/generated/version $(BINARY_WRAPPER_DIR)/src/generated/sha256sums.txt | |||
@echo "-- Building Typescript Binary Wrapper ($(BINARY_WRAPPER_DIR)/dist/)" | |||
@cd $(BINARY_WRAPPER_DIR); npm run build | |||
@cd $(BINARY_WRAPPER_DIR); npm install --ignore-scripts && npm run build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command worked previously without an install step, as all dependencies was already installed from the CLI project.
Now we're adding proxy-agent
, not currently present in the CLI project.
The --ignore-scripts
is to avoid the bootstrapping mechanism of ts-binary-wrapper
to come into effect, causing a failed installation.
a0739ab
to
296d2e4
Compare
.circleci/config.yml
Outdated
@@ -1249,6 +1247,9 @@ jobs: | |||
CC: << parameters.c_compiler >> | |||
CGO_ENABLED: 1 | |||
command: make << parameters.make_target >> GOOS=<< parameters.go_target_os >> GOARCH=<< parameters.go_arch >> | |||
- run: | |||
name: Create a shasum file of the Snyk binary | |||
command: find binary-releases -name "snyk-*" -exec make {}.sha256 \; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I can make a more specific command due to
Line 39 in eede406
# the platform string used by the deployed binaries is not excatly OS-ARCH so we need to translate a bit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I am adding this step is for the testing of ts-binary-wrapper
inside the acceptance tests.
I didn't add the sha256
step there, as the executors don't all contain an environment to run make
.
I further tried to keep the Makefile
intact, since previous attempts at changing the logic here all caused side-effects I had trouble overlooking in the CCI steps.
296d2e4
to
599bb78
Compare
599bb78
to
0c3b353
Compare
Issue: This change introduces a new minimum Node version requirement! The currently available version can be installed with node 12.0.0, the package from this branch can't.
It errors with
it seems to work with version 14.0.0 and generally more recent versions. But the change in minimum node version is the same as the other branch that used axios. The branch with axios has the minimum node version 12.17.0. |
…2b421dfdb0107d799c6
…da2c39fe0c4ebb7470f
@dotkas let's please mark this PR as draft until we have the data to decide |
Pull Request Submission Checklist
are release-note ready, emphasizing
what was changed, not how.
What does this PR do?
The NPM package
global-agent
is not maintained and is causing deprecation errors to show up. This PR removes the package all together and relies on the[proxy-agent](https://www.npmjs.com/package/proxy-agent)
package instead, which handles the same logic.Where should the reviewer start?
The
ts-binary-wrapper
has somewhat straightforward logic and you could start there. A new test has been added to highlight the change that needs to be covered.Further, the
ts-binary-wrapper
build script was not buildable outside of the CLI context. This has been fixed in theMakefile
. It was needed to make the tests forts-binary-wrapper
run in CircleCI as a part of the build process.How should this be manually tested?
Do an
npm run build
in thets-binary-wrapper
folder and try to download the CLI from the built executable.What's the product update that needs to be communicated to CLI users?
N/A, this is an implementation change.
Risk assessment (Low | Medium | High)?
HIGH, this changes the way customers download Snyk when running behind HTTP(S) proxies and could introduce breaking changes making customers unable to use Snyk in their environments. This change should be reviewed and tested carefully.
Further, there has been some changes to the
Makefile
which I believe was needed to adequately ensurets-binary-wrapper
installed as a part of the build and test steps. This should probably also be reviewed a bit more carefully.