-
Notifications
You must be signed in to change notification settings - Fork 10
Fix: Propagate --insecure parameter #78
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,21 @@ import http from 'http'; | |
import https from 'https'; | ||
import emitter from './emitter'; | ||
|
||
// Snyk CLI allow passing --insecure flag which allows self-signed certificates | ||
// It updates global namespace property ignoreUnknownCA and we can use it in order | ||
// to pass rejectUnauthorized option to https agent | ||
export declare interface Global extends NodeJS.Global { | ||
ignoreUnknownCA: boolean; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Required: Does CA stand for certification Authorities? Could we add a comment explaining that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
declare const global: Global; | ||
|
||
const agentOptions = { | ||
keepAlive: true, | ||
maxSockets: 100, // Maximum number of sockets to allow per host. Defaults to Infinity. | ||
maxFreeSockets: 10, | ||
freeSocketTimeout: 60000, // // Maximum number of sockets to leave open for 60 seconds in a free state. Only relevant if keepAlive is set to true. Defaults to 256. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Arvi3d I am fairly sure this settings does nothing here 😇 It is not supported at https://nodejs.org/docs/latest-v12.x/api/http.html#http_new_agent_options and it looks like it is used only, when https://www.npmjs.com/package/agentkeepalive is around. I'd vote for removing it and typing agentOptions properly. |
||
socketActiveTTL: 1000 * 60 * 10, | ||
rejectUnauthorized: !global.ignoreUnknownCA, | ||
}; | ||
|
||
const axios_ = axios.create({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ describe('Requests to public API', () => { | |
if (response.type === 'error') return; | ||
expect(new Set(response.value.configFiles)).toEqual(new Set(['.dcignore', '.gitignore'])); | ||
expect(new Set(response.value.extensions)).toEqual( | ||
new Set(['.es', '.es6', '.htm', '.html', '.js', '.jsx', '.py', '.ts', '.tsx', '.vue', '.java']), | ||
new Set(['.es', '.es6', '.htm', '.html', '.js', '.jsx', '.py', '.ts', '.tsx', '.vue', '.java', '.java-dummy']), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Why do we now return .java-dummy in this list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ask t-42 ¯_(ツ)_/¯ Looks like something reachability related. |
||
); | ||
}); | ||
|
||
|
@@ -404,8 +404,9 @@ describe('Requests to public API', () => { | |
} while (response.value.status !== AnalysisStatus.done); | ||
|
||
expect(Object.keys(response.value.analysisResults.suggestions).length).toEqual(4); | ||
expect(new Set(Object.keys(response.value.analysisResults.files))) | ||
.toEqual(new Set(['/GitHubAccessTokenScrambler12.java', '/not/ignored/this_should_not_be_ignored.java'])); | ||
expect(new Set(Object.keys(response.value.analysisResults.files))).toEqual( | ||
new Set(['/GitHubAccessTokenScrambler12.java', '/not/ignored/this_should_not_be_ignored.java']), | ||
); | ||
|
||
// Get analysis results without linters but with severity 3 | ||
do { | ||
|
@@ -423,8 +424,9 @@ describe('Requests to public API', () => { | |
} while (response.value.status !== AnalysisStatus.done); | ||
|
||
expect(Object.keys(response.value.analysisResults.suggestions).length).toEqual(2); | ||
expect(new Set(Object.keys(response.value.analysisResults.files))) | ||
.toEqual(new Set(['/GitHubAccessTokenScrambler12.java', '/not/ignored/this_should_not_be_ignored.java'])); | ||
expect(new Set(Object.keys(response.value.analysisResults.files))).toEqual( | ||
new Set(['/GitHubAccessTokenScrambler12.java', '/not/ignored/this_should_not_be_ignored.java']), | ||
); | ||
}, | ||
TEST_TIMEOUT, | ||
); | ||
|
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.
Question: maybe I am lacking some understanding but why do you have to extend the global object? Is this because typescript does not define the property that is already there?
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.
Global is an Interface with defined properties and TypeScript interfaces are closed for additions. So we need to create our own interface.