Skip to content

Commit 2687514

Browse files
authored
Merge pull request #127 from snyk/develop
Merge develop into master for release
2 parents f9ae783 + 31a7806 commit 2687514

File tree

6 files changed

+67
-157
lines changed

6 files changed

+67
-157
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,21 @@ This extension requires that Node.js and npm be installed on the build agent. Th
1919

2020
## Task Parameters
2121

22-
| Parameter | Description | Required | Default | Type |
23-
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | --------------- | --------------------------------------------------------------------------------- |
24-
| serviceConnectionEndpoint | The Azure DevOps service connection endpoint where your Snyk API token is defined. Define this within your Azure DevOps project settings / S | no | none | String / Azure Service Connection Endpoint of type SnykAuth / Snyk Authentication |
25-
| testType | Used by the task UI only | no | "application" | string: "app" or "container" |
26-
| dockerImageName | The name of the container image to test. | yes, if container image test | none | string |
27-
| dockerfilePath | The path to the Dockerfile corresponding to the `dockerImageName` | yes, if container image test | none | string |
28-
| targetFile | Applicable to application type tests ony. The path to the manifest file to be used by Snyk. Should only be provided if non-standard. | no | none | string |
29-
| severityThreshold | The severity-threshold to use when testing. By default, issues of all severity types will be found. | no | "low" | string: "low" or "medium" or "high" or "critical" |
30-
| monitorOnBuild | Whether or not to capture the dependencies of the application / container image and monitor them within Snyk. | yes | true | boolean |
31-
| monitorWhen | When to run `snyk monitor`. Valid options are `never`, `noIssuesFound` (default), and `always`. If set, this option overrides the value of `monitorOnBuild`. | no | 'noIssuesFound' | boolean |
32-
| failOnIssues | This specifies if builds should be failed or continued based on issues found by Snyk. | yes | true | boolean |
33-
| projectName | A custom name for the Snyk project to be created on snyk.io | no | none | string |
34-
| organization | Name of the Snyk organisation name, under which this project should be tested and monitored | no | none | string |
35-
| testDirectory | Alternate working directory. For example, if you want to test a manifest file in a directory other than the root of your repo, you would put in relative path to that directory. | no | none | string |
36-
| ignoreUnknownCA | Use to ignore unknown or self-signed certificates. This might be useful in for self-hosted build agents with unusual network configurations or for Snyk on-prem installs configured with a self-signed certificate. | no | false | boolean |
37-
| additionalArguments | Additional Snyk CLI arguments to be passed in. Refer to the Snyk CLI help page for information on additional arguments. | no | none | string |
22+
| Parameter | Description | Required | Default | Type |
23+
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------- | --------------------------------------------------------------------------------- |
24+
| serviceConnectionEndpoint | The Azure DevOps service connection endpoint where your Snyk API token is defined. Define this within your Azure DevOps project settings / S | no | none | String / Azure Service Connection Endpoint of type SnykAuth / Snyk Authentication |
25+
| testType | Used by the task UI only | no | "application" | string: "app" or "container" |
26+
| dockerImageName | The name of the container image to test. | yes, if container image test | none | string |
27+
| dockerfilePath | The path to the Dockerfile corresponding to the `dockerImageName` | yes, if container image test | none | string |
28+
| targetFile | Applicable to application type tests ony. The path to the manifest file to be used by Snyk. Should only be provided if non-standard. | no | none | string |
29+
| severityThreshold | The severity-threshold to use when testing. By default, issues of all severity types will be found. | no | "low" | string: "low" or "medium" or "high" or "critical" |
30+
| monitorWhen | When to run `snyk monitor`. Valid options are `always` (default), `noIssuesFound`, and `never`. If set, this option overrides the value of `monitorOnBuild`. | no | "always" | boolean |
31+
| failOnIssues | This specifies if builds should be failed or continued based on issues found by Snyk. | yes | true | boolean |
32+
| projectName | A custom name for the Snyk project to be created on snyk.io | no | none | string |
33+
| organization | Name of the Snyk organisation name, under which this project should be tested and monitored | no | none | string |
34+
| testDirectory | Alternate working directory. For example, if you want to test a manifest file in a directory other than the root of your repo, you would put in relative path to that directory. | no | none | string |
35+
| ignoreUnknownCA | Use to ignore unknown or self-signed certificates. This might be useful in for self-hosted build agents with unusual network configurations or for Snyk on-prem installs configured with a self-signed certificate. | no | false | boolean |
36+
| additionalArguments | Additional Snyk CLI arguments to be passed in. Refer to the Snyk CLI help page for information on additional arguments. | no | none | string |
3837

3938
## Usage Examples
4039

@@ -45,7 +44,7 @@ This extension requires that Node.js and npm be installed on the build agent. Th
4544
inputs:
4645
serviceConnectionEndpoint: 'mySnykToken'
4746
testType: 'app'
48-
monitorOnBuild: true
47+
monitorWhen: 'always'
4948
failOnIssues: true
5049
```
5150

@@ -58,7 +57,7 @@ This extension requires that Node.js and npm be installed on the build agent. Th
5857
testType: 'container'
5958
dockerImageName: 'my-container-image-name'
6059
dockerfilePath: 'Dockerfile'
61-
monitorOnBuild: true
60+
monitorWhen: 'always'
6261
failOnIssues: true
6362
```
6463

snykTask/src/__tests__/task-lib.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ afterAll(() => {
3434

3535
test('getOptionsToExecuteSnyk builds IExecOptions like we need it', () => {
3636
const taskArgs: TaskArgs = new TaskArgs({
37-
monitorOnBuild: true,
3837
failOnIssues: true,
3938
});
4039
taskArgs.testDirectory = '/some/path';
@@ -51,7 +50,6 @@ test('getOptionsToExecuteSnykCLICommand builds IExecOptions like we need it', ()
5150
const version = '1.2.3';
5251

5352
const taskArgs: TaskArgs = new TaskArgs({
54-
monitorOnBuild: true,
5553
failOnIssues: true,
5654
});
5755
taskArgs.testDirectory = '/some/path';
@@ -74,7 +72,6 @@ test('getOptionsToExecuteSnykCLICommand builds IExecOptions like we need it', ()
7472
describe('getOptionsForSnykToHtml', () => {
7573
it('builds IExecOptions for running snyk-to-html', async () => {
7674
const taskArgs: TaskArgs = new TaskArgs({
77-
monitorOnBuild: true,
7875
failOnIssues: true,
7976
});
8077
taskArgs.testDirectory = '/some/path';

snykTask/src/__tests__/test-task-args.ts

Lines changed: 31 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { TaskArgs } from '../task-args';
77

88
function defaultTaskArgs(): TaskArgs {
99
return new TaskArgs({
10-
monitorOnBuild: true,
1110
failOnIssues: true,
1211
});
1312
}
@@ -83,13 +82,13 @@ describe('TaskArgs.setMonitorWhen', () => {
8382

8483
it('defaults to `noIssuesFound` when undefined, empty string, or invalid value', () => {
8584
args.setMonitorWhen(undefined);
86-
expect(args.monitorWhen).toBeUndefined();
85+
expect(args.monitorWhen).toBe('always');
8786

8887
args.setMonitorWhen('');
89-
expect(args.monitorWhen).toBeUndefined();
88+
expect(args.monitorWhen).toBe('always');
9089

9190
args.setMonitorWhen('invalid-option');
92-
expect(args.monitorWhen).toBeUndefined();
91+
expect(args.monitorWhen).toBe('always');
9392
});
9493

9594
it('works for valid inputs', () => {
@@ -107,12 +106,8 @@ describe('TaskArgs.setMonitorWhen', () => {
107106
const SNYK_TEST_SUCCESS_TRUE = true;
108107
const SNYK_TEST_SUCCESS_FALSE = false;
109108

110-
function argsFrom(params: {
111-
monitorOnBuild: boolean;
112-
monitorWhen?: string;
113-
}): TaskArgs {
109+
function argsFrom(params: { monitorWhen: string }): TaskArgs {
114110
const args = new TaskArgs({
115-
monitorOnBuild: params.monitorOnBuild,
116111
failOnIssues: true,
117112
});
118113
if (params.monitorWhen) {
@@ -122,113 +117,39 @@ function argsFrom(params: {
122117
}
123118

124119
describe('TaskArgs.shouldRunMonitor', () => {
125-
describe('when `monitorWhen` is not set', () => {
126-
describe('and `monitorOnBuild` is false', () => {
127-
const args = argsFrom({
128-
monitorOnBuild: false,
129-
});
130-
it('return false when snykTestSuccess is false', () => {
131-
expect(args.shouldRunMonitor(false)).toBe(false);
132-
});
133-
it('return false when snykTestSuccess is true', () => {
134-
expect(args.shouldRunMonitor(true)).toBe(false);
135-
});
120+
describe('when `monitorWhen` is `always`', () => {
121+
const args = argsFrom({
122+
monitorWhen: 'always',
136123
});
137-
138-
describe('and `monitorOnBuild` is true', () => {
139-
const args = argsFrom({
140-
monitorOnBuild: true,
141-
});
142-
it('return false when snykTestSuccess is false', () => {
143-
expect(args.shouldRunMonitor(false)).toBe(false);
144-
});
145-
it('return true when snykTestSuccess is true', () => {
146-
expect(args.shouldRunMonitor(true)).toBe(true);
147-
});
124+
it('returns true when snykTestSuccess is false', () => {
125+
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(true);
126+
});
127+
it('returns true when snykTestSuccess is true', () => {
128+
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(true);
148129
});
149130
});
150131

151-
describe('when `monitorWhen` is set', () => {
152-
describe('and `monitorOnBuild` is false', () => {
153-
describe('and `monitorWhen` is `always`', () => {
154-
const args = argsFrom({
155-
monitorOnBuild: false,
156-
monitorWhen: 'always',
157-
});
158-
it('returns true when snykTestSuccess is false', () => {
159-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(true);
160-
});
161-
it('returns true when snykTestSuccess is true', () => {
162-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(true);
163-
});
164-
});
165-
166-
describe('and `monitorWhen` is `never`', () => {
167-
const args = argsFrom({
168-
monitorOnBuild: false,
169-
monitorWhen: 'never',
170-
});
171-
it('returns false when snykTestSuccess is false', () => {
172-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(false);
173-
});
174-
it('returns false when snykTestSuccess is true', () => {
175-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(false);
176-
});
177-
});
178-
179-
describe('and `monitorWhen` is `noIssuesFound`', () => {
180-
const args = argsFrom({
181-
monitorOnBuild: false,
182-
monitorWhen: 'noIssuesFound',
183-
});
184-
it('returns false when snykTestSuccess is false', () => {
185-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(false);
186-
});
187-
it('returns true when snykTestSuccess is true', () => {
188-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(true);
189-
});
190-
});
132+
describe('and `monitorWhen` is `never`', () => {
133+
const args = argsFrom({
134+
monitorWhen: 'never',
191135
});
136+
it('returns false when snykTestSuccess is false', () => {
137+
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(false);
138+
});
139+
it('returns false when snykTestSuccess is true', () => {
140+
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(false);
141+
});
142+
});
192143

193-
describe('and `monitorOnBuild` is true', () => {
194-
describe('and `monitorWhen` is `always`', () => {
195-
const args = argsFrom({
196-
monitorOnBuild: true,
197-
monitorWhen: 'always',
198-
});
199-
it('returns true when snykTestSuccess is false', () => {
200-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(true);
201-
});
202-
it('returns true when snykTestSuccess is true', () => {
203-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(true);
204-
});
205-
});
206-
207-
describe('and `monitorWhen` is `never`', () => {
208-
const args = argsFrom({
209-
monitorOnBuild: true,
210-
monitorWhen: 'never',
211-
});
212-
it('returns false when snykTestSuccess is false', () => {
213-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(false);
214-
});
215-
it('returns false when snykTestSuccess is true', () => {
216-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(false);
217-
});
218-
});
219-
220-
describe('and `monitorWhen` is `noIssuesFound`', () => {
221-
const args = argsFrom({
222-
monitorOnBuild: true,
223-
monitorWhen: 'noIssuesFound',
224-
});
225-
it('returns false when snykTestSuccess is false', () => {
226-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(false);
227-
});
228-
it('returns true when snykTestSuccess is true', () => {
229-
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(true);
230-
});
231-
});
144+
describe('and `monitorWhen` is `noIssuesFound`', () => {
145+
const args = argsFrom({
146+
monitorWhen: 'noIssuesFound',
147+
});
148+
it('returns false when snykTestSuccess is false', () => {
149+
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_FALSE)).toBe(false);
150+
});
151+
it('returns true when snykTestSuccess is true', () => {
152+
expect(args.shouldRunMonitor(SNYK_TEST_SUCCESS_TRUE)).toBe(true);
232153
});
233154
});
234155
});

0 commit comments

Comments
 (0)