Skip to content

Commit 40ef699

Browse files
Merge pull request #144 from snyk/develop
Merge develop into master for release
2 parents 247722a + 8a46a37 commit 40ef699

17 files changed

+336
-75
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @snyk/hammer
1+
* @snyk/road-runner

.github/CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,49 @@
11
# Contributing
22

3+
## Development
4+
### Setup
5+
Run `npm run build` in the root folder. All tooling prerequisites (Node.js, TypeScript etc.) can be seen [here](https://docs.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops#prerequisites) and should be installed.
6+
7+
### Test and Run
8+
Unit tests can be run via `npm run test:unit` command.
9+
10+
To run the code, a GitHub PR against `develop` should be raised with the committed code to the branch PR. The PR runs deployment script with deploy to development environment. The script builds the code that's added as part of your change and installs it in Azure DevOps organization as an extension that can be added to run a pipeline.
11+
12+
### Local debugging
13+
14+
A number of environment variable are required for debugging, here's an example launch config for `VSCode` that sets mandatory parameters such as `AGENT_TEMPDIRECTORY`, `INPUT_failOnIssues` and `INPUT_authToken`
15+
16+
```
17+
{
18+
"version": "0.2.0",
19+
"configurations": [
20+
{
21+
"type": "node",
22+
"request": "launch",
23+
"name": "Launch Program",
24+
"program": "${workspaceFolder}/snykTask/src/index.ts",
25+
"env": {
26+
"AGENT_TEMPDIRECTORY": "some/temp/path",
27+
"INPUT_failOnIssues": "true",
28+
"INPUT_authToken": "your-auth-token-guid-from-portal",
29+
"INPUT_targetFile": "path-to-visual-studio-solution.sln",
30+
"INPUT_organization": "your-org-guid-from-portal",
31+
"INPUT_monitorWhen": "never",
32+
"INPUT_severityThreshold": "low",
33+
"INPUT_failOnThreshold": "critical",
34+
"NODE_OPTIONS": null
35+
},
36+
"outFiles": [
37+
"${workspaceFolder}/**/*.js"
38+
]
39+
}
40+
]
41+
}
42+
```
43+
44+
## Release
45+
The release process is fully-automated: all you need to do is create a PR to merge `develop` into `master` and call the PR `Merge develop into master for release`.
46+
347
## Contributor Agreement
448
A pull-request will only be considered for merging into the upstream codebase after you have signed our [contributor agreement](https://github.com/snyk/snyk-azure-pipelines-task/blob/master/Contributor-Agreement.md), assigning us the rights to the contributed code and granting you a license to use it in return. If you submit a pull request, you will be prompted to review and sign the agreement with one click (we use [CLA assistant](https://cla-assistant.io/)).
549

@@ -36,6 +80,8 @@ To release a major you need to add `BREAKING CHANGE: ` to the start of the body
3680

3781
Ensure that your code adheres to the included `.eslintrc` config by running `npm run test:checks`.
3882

83+
Fix any `prettier` violations reported before pushing by running `npm run format`
84+
3985
## Sending pull requests
4086

4187
- add tests for newly added code (and try to mirror directory and file structure if possible) or fixes

README.md

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ 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-
| 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 |
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 and reporting. By default, issues of all severity types will be found. | no | "low" | string: "low" or "medium" or "high" or "critical" |
30+
| failOnThreshold | The `severityThreshold` parameter is used to control the interaction with the Snyk CLI and reporting vulnerabilities. The `failOnThreshold` gives you additional control over build failure behaviour. For example, with `failOnIssues` set to `true` and `failOnThreshold` to `critical`, all issues would be reported on but _only_ critical issues would cause a build failure. See Usage Examples for more information | no | "low" | string: "low" or "medium" or "high" or "critical" |
31+
| 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 |
32+
| failOnIssues | This specifies if builds should be failed or continued based on issues found by Snyk. Combine with `failOnThreshold` to control which severity of issues causes the build to fail | 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 |
3738

3839
## Usage Examples
3940

@@ -66,6 +67,19 @@ Here's a full example:
6667
monitorWhen: 'always'
6768
```
6869

70+
An example that specifies a value for `severityThreshold` as medium and configures `failOnThreshold` to critical. This configuration would _only fail_ the build when critical issues are found, but all issues detected at medium, high and critical would be reported back to your snyk project for analysis
71+
72+
```
73+
- task: SnykSecurityScan@1
74+
inputs:
75+
serviceConnectionEndpoint: 'mySnykToken'
76+
testType: 'app'
77+
severityThreshold: 'medium'
78+
failOnIssues: true
79+
failOnThreshold: 'critical'
80+
monitorWhen: 'always'
81+
```
82+
6983
### Simple Container Image Testing Example
7084

7185
```

ops/deploy/get-next-dev-ext-version.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ async function main() {
2626
process.exit(1);
2727
}
2828
} else {
29-
console.error('could not get extension info');
30-
process.exit(1);
29+
// Could not get extension info. The extension must not exist. Returning `0.0.1` for first version of new extension.
30+
console.log('0.0.1');
3131
}
3232
}
3333

ops/deploy/install-extension-to-dev-org.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,22 @@ async function main() {
3232
publisherName,
3333
extensionName,
3434
);
35-
const alreadyInstalledVersion = alreadyInstalledExtensionInfo.version;
36-
console.log(
37-
`Extension version currently installed: ${alreadyInstalledVersion}`,
38-
);
3935

40-
console.log(`Uninstalling previously installed extension`);
41-
await uninstallExtension(webApi, publisherName, extensionName);
36+
if (alreadyInstalledExtensionInfo) {
37+
const alreadyInstalledVersion = alreadyInstalledExtensionInfo.version;
38+
console.log(
39+
`Extension version currently installed: ${alreadyInstalledVersion}`,
40+
);
41+
42+
console.log(`Uninstalling previously installed extension`);
43+
await uninstallExtension(webApi, publisherName, extensionName);
44+
}
4245

4346
console.log(
4447
'Attempting to install latest version of extension into org...',
4548
);
4649
// installExtension will throw an error if it is already installed
47-
const installRes = await installExtension(
48-
webApi,
49-
publisherName,
50-
extensionName,
51-
version,
52-
);
50+
await installExtension(webApi, publisherName, extensionName, version);
5351

5452
const afterInstallExtensionInfo = await getInstalledExtensionInfo(
5553
webApi,

0 commit comments

Comments
 (0)