-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 154 Prompt User to Install Code Linters for each Detected Langu…
…age (#332) closes #154 **Overview** Adds functionality to prompt the user to determine if linter based pre-commit hooks should be added to the code repository. The user will be prompted for each detected language during `init`. An example messages will be `Add lint pre-commit(s) for JavaScript? [Y/n]` adding the `--yes` option will bypass the prompting to install linter pre-commit hooks and will automatically add them. **Technical Approach** This pr includes reorganizing the pre-commit templates into a new folder/file structure. Templates will be located under `resources/pre-commit` and will be split into separate folders and files based on if they are linter hooks or not. The user responses and code will determine whether or not the hooks should be combined and saved to the user's repository. Splitting these files out ensures a simple way of knowing which hooks are linters. **Testing** 1. run `secureli init` 2. follow flow to add/ignore linters for each detected language 3. Verify pre-commit linters are added or not added to pre-commit.yaml depending on prompt response Regression testing: Testing `scan` and `update` to ensure both are working as normal.
- Loading branch information
1 parent
5cda63c
commit c63860f
Showing
37 changed files
with
428 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ source = secureli | |
|
||
[report] | ||
fail_under = 90 | ||
show_missing = true | ||
omit = | ||
tests/* | ||
*/__init__.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
secureli/resources/files/pre-commit/base/base-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-ast | ||
- id: check-docstring-first | ||
- id: check-executables-have-shebangs | ||
- id: check-shebang-scripts-are-executable | ||
- id: check-merge-conflict | ||
- id: check-toml | ||
- id: check-json | ||
- id: check-xml | ||
- id: check-yaml | ||
- id: debug-statements | ||
- id: detect-aws-credentials | ||
args: [--allow-missing-credentials] | ||
- id: detect-private-key | ||
- id: name-tests-test | ||
args: [--pytest-test-first] | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: v1.4.0 | ||
hooks: | ||
- id: detect-secrets |
1 change: 1 addition & 0 deletions
1
secureli/resources/files/pre-commit/base/csharp-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repos: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repos: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repos: |
1 change: 1 addition & 0 deletions
1
secureli/resources/files/pre-commit/base/javascript-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repos: |
10 changes: 10 additions & 0 deletions
10
secureli/resources/files/pre-commit/base/python-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pygrep-hooks | ||
rev: v1.9.0 | ||
hooks: | ||
- id: python-use-type-annotations | ||
- repo: https://github.com/PyCQA/bandit | ||
rev: 1.7.4 | ||
hooks: | ||
- id: bandit | ||
args: ["--exclude", "tests/", "--severity-level", "medium"] |
6 changes: 6 additions & 0 deletions
6
secureli/resources/files/pre-commit/base/swift-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
repos: | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: v1.4.0 | ||
hooks: | ||
- id: detect-secrets | ||
exclude: .xcscheme$ |
5 changes: 5 additions & 0 deletions
5
secureli/resources/files/pre-commit/base/terraform-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/Yelp/detect-secrets | ||
rev: v1.4.0 | ||
hooks: | ||
- id: detect-secrets |
1 change: 1 addition & 0 deletions
1
secureli/resources/files/pre-commit/base/typescript-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repos: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repos: |
14 changes: 14 additions & 0 deletions
14
secureli/resources/files/pre-commit/lint/csharp-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
# Note: The dotnet format pre-commit setup combines poorly to be tightly coupled with | ||
# a pre-release version of .net that is old and no one has installed. dotnet format has | ||
# since become a part of .net! So we can use dotnet format already installed on your | ||
# simply. This runs the risk that different folks will run different versions, but | ||
# this is better than nothing. | ||
# see https://github.com/dotnet/format/issues/1350 and the resolution PR at the bottom. | ||
- id: dotnet-format | ||
name: dotnet-format | ||
language: system | ||
entry: dotnet format --include | ||
types: ["c#"] |
2 changes: 1 addition & 1 deletion
2
secureli/resources/files/go-pre-commit.yaml → .../files/pre-commit/lint/go-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
repos: | ||
repos: | ||
- repo: https://github.com/golangci/golangci-lint | ||
rev: v1.53.3 | ||
hooks: | ||
|
5 changes: 5 additions & 0 deletions
5
secureli/resources/files/pre-commit/lint/java-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/slalombuild/pre-commit-mirror-checkstyle | ||
rev: v0.1.1 | ||
hooks: | ||
- id: checkstyle-java |
21 changes: 21 additions & 0 deletions
21
secureli/resources/files/pre-commit/lint/javascript-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: "v8.42.0" | ||
hooks: | ||
- id: eslint | ||
files: \.[j]sx?$ # *.js and *.jsx | ||
types: [file] | ||
args: ["--config", ".secureli/javascript.eslintrc.yaml", "--fix"] | ||
additional_dependencies: | ||
- [email protected] | ||
- [email protected] | ||
- [email protected] | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v2.7.1" | ||
hooks: | ||
- id: prettier | ||
args: | ||
- --single-quote | ||
- --trailing-comma | ||
- all | ||
types_or: [css, javascript] |
5 changes: 5 additions & 0 deletions
5
secureli/resources/files/pre-commit/lint/python-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 22.10.0 | ||
hooks: | ||
- id: black |
5 changes: 5 additions & 0 deletions
5
secureli/resources/files/pre-commit/lint/swift-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/realm/SwiftLint | ||
rev: 0.52.2 | ||
hooks: | ||
- id: swiftlint |
5 changes: 5 additions & 0 deletions
5
secureli/resources/files/pre-commit/lint/terraform-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
repos: | ||
- repo: https://github.com/antonbabenko/pre-commit-terraform | ||
rev: v1.77.0 | ||
hooks: | ||
- id: terraform_tflint |
23 changes: 23 additions & 0 deletions
23
secureli/resources/files/pre-commit/lint/typescript-pre-commit.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: "v8.42.0" | ||
hooks: | ||
- id: eslint | ||
files: \.[t]sx?$ # *.ts and *.tsx | ||
types: [file] | ||
args: ["--config", ".secureli/typescript.eslintrc.yaml", "--fix"] | ||
additional_dependencies: | ||
- [email protected] | ||
- [email protected] | ||
- "@typescript-eslint/[email protected]" | ||
- "@typescript-eslint/[email protected]" | ||
- [email protected] | ||
- [email protected] | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: "v2.7.1" | ||
hooks: | ||
- id: prettier | ||
args: | ||
- --single-quote | ||
- --trailing-comma | ||
- all |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.