Skip to content

Commit

Permalink
feat: add support for snippets and toolbar button for action command
Browse files Browse the repository at this point in the history
Signed-off-by: Owen Rumney <[email protected]>
  • Loading branch information
owenrumney committed Mar 28, 2022
1 parent 5e34d3e commit 92780a4
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to the "tfsec" extension will be documented in this file.

### 1.8.0
- Add snippets support
- using `tfsec-check-file` in a yaml file to create custom check
- using `tfsec-custom-check` in the existing check file to add a new custom check
- Add icon on toolbar to get the version

### 1.7.5
- Update the severity icons inline with Aqua colours
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ Ignore codes will be automatically resolved and the description of the error wil

## Release Notes

### 1.8.0
- Add snippets support
- using `tfsec-check-file` in a yaml file to create custom check
- using `tfsec-custom-check` in the existing check file to add a new custom check
- Add icon on toolbar to get the version

### 1.7.5
- Update the severity icons inline with Aqua colours

Expand Down
21 changes: 18 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "tfsec",
"publisher": "tfsec",
"description": "tfsec integration for Visual Studio Code",
"version": "1.7.5",
"version": "1.8.0",
"engines": {
"vscode": "^1.54.0"
},
Expand Down Expand Up @@ -101,7 +101,11 @@
},
{
"command": "tfsec.version",
"title": "tfsec: Get the current version of tfsec"
"title": "tfsec: Get the current version of tfsec",
"icon": {
"light": "resources/light/help.svg",
"dark": "resources/dark/help.svg"
}
}
],
"viewsContainers": {
Expand Down Expand Up @@ -156,6 +160,11 @@
"command": "tfsec.updatebinary",
"when": "view == tfsec.issueview",
"group": "navigation@2"
},
{
"command": "tfsec.version",
"when": "view == tfsec.issueview",
"group": "navigation@2"
}
],
"view/item/context": [
Expand All @@ -172,7 +181,13 @@
"when": "view == tfsec.issueview && viewItem == TFSEC_SEVERITY"
}
]
}
},
"snippets": [
{
"language": "yaml",
"path": "./src/snippets/custom_checks.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run esbuild-base -- --minify",
Expand Down
3 changes: 3 additions & 0 deletions resources/dark/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions resources/light/help.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 48 additions & 0 deletions src/snippets/custom_checks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"custom_checks_yaml": {
"prefix": [
"tfsec-check-file"
],
"body": [
"---",
"checks:",
" - code: ${1}",
" description: ${2}",
" requiredTypes:",
" - ${3:resource}",
" requiredLabels:",
" - ${4}",
" severity: ${5:MEDIUM}",
" matchSpec:",
" name: ${6}",
" action: ${7}",
" value: ${8}",
" errorMessage: ${9}",
" relatedLinks:",
" - ${10}"
],
"description": "Add the body for custom checks file."
},
"custom_check": {
"prefix": [
"tfsec-custom-check"
],
"body": [
" - code: ${1}",
" description: ${2}",
" requiredTypes:",
" - ${3:resource}",
" requiredLabels:",
" - ${4}",
" severity: ${5:MEDIUM}",
" matchSpec:",
" name: ${6}",
" action: ${7}",
" value: ${8}",
" errorMessage: ${9}",
" relatedLinks:",
" - ${10}"
],
"description": "Add the body for an individual custom check."
}
}
3 changes: 2 additions & 1 deletion src/tfsec_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class TfsecWrapper {
return;
}

var files = readdirSync(this.resultsStoragePath).filter(fn => fn.endsWith('_results.json') || fn.endsWith('_results.json.json') );
var files = readdirSync(this.resultsStoragePath).filter(fn => fn.endsWith('_results.json') || fn.endsWith('_results.json.json'));
files.forEach(file => {
let deletePath = path.join(this.resultsStoragePath, file);
unlinkSync(deletePath);
Expand All @@ -59,6 +59,7 @@ export class TfsecWrapper {
execution.on('exit', function (code) {
if (code !== 0) {
vscode.window.showErrorMessage("tfsec failed to run");
outputChannel.show();
return;
};
vscode.window.showInformationMessage('tfsec ran successfully, updating results');
Expand Down

0 comments on commit 92780a4

Please sign in to comment.