diff --git a/.secureli.yaml b/.secureli.yaml index 542f0dc6..f349d78c 100644 --- a/.secureli.yaml +++ b/.secureli.yaml @@ -3,6 +3,7 @@ echo: repo_files: exclude_file_patterns: - .idea/ + - tests/end-to-end/test-data/ ignored_file_extensions: - .pyc - .drawio diff --git a/.secureli/.pre-commit-config.yaml b/.secureli/.pre-commit-config.yaml index b369b74d..ecff9309 100644 --- a/.secureli/.pre-commit-config.yaml +++ b/.secureli/.pre-commit-config.yaml @@ -1,18 +1,136 @@ -# See https://pre-commit.com for more information -# See https://pre-commit.com/hooks.html for more hooks repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files -- repo: https://github.com/psf/black-pre-commit-mirror - rev: 24.3.0 - hooks: - - id: black -- repo: https://github.com/yelp/detect-secrets - rev: v1.4.0 - hooks: - - id: detect-secrets +- hooks: + - id: python-use-type-annotations + repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.10.0 +- hooks: + - args: + - --exclude + - tests/ + - --severity-level + - medium + id: bandit + repo: https://github.com/PyCQA/bandit + rev: 1.7.8 +- hooks: + - id: black + repo: https://github.com/psf/black + rev: 24.3.0 +- hooks: + - entry: dotnet format --include + id: dotnet-format + language: system + name: dotnet-format + types: + - c# + repo: local +- hooks: + - id: golangci-lint + repo: https://github.com/golangci/golangci-lint + rev: v1.57.2 +- hooks: + - additional_dependencies: + - eslint@8.42.0 + - eslint-plugin-prettier@4.2.1 + args: + - --config + - javascript.eslintrc.yaml + - --fix + files: \.[j]sx?$ + id: eslint + types: + - file + repo: https://github.com/pre-commit/mirrors-eslint + rev: v9.0.0 +- hooks: + - args: + - --single-quote + - --trailing-comma + - all + id: prettier + types_or: + - css + - javascript + repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 +- hooks: + - id: detekt + repo: https://github.com/quwac/pre-commit-detekt + rev: v1.23.4 +- hooks: + - args: + - --autofix + id: pretty-format-kotlin + repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: v2.13.0 +- hooks: + - exclude: .xcscheme$ + id: detect-secrets + repo: https://github.com/Yelp/detect-secrets + rev: v1.4.0 +- hooks: + - id: swiftlint + repo: https://github.com/realm/SwiftLint + rev: 0.54.0 +- hooks: + - id: detect-secrets + repo: https://github.com/Yelp/detect-secrets + rev: v1.4.0 +- hooks: + - id: terraform_tflint + repo: https://github.com/antonbabenko/pre-commit-terraform + rev: v1.88.4 +- hooks: + - additional_dependencies: + - eslint@8.42.0 + - '@typescript-eslint/eslint-plugin@5.59.11' + - '@typescript-eslint/parser@5.59.11' + - typescript@5.1.3 + - eslint-config-prettier@8.8.0 + - eslint-plugin-prettier@4.2.1 + args: + - --config + - typescript.eslintrc.yaml + - --fix + files: \.[t]sx?$ + id: eslint + types: + - file + repo: https://github.com/pre-commit/mirrors-eslint + rev: v9.0.0 +- hooks: + - args: + - --single-quote + - --trailing-comma + - all + id: prettier + repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 +- 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 + - args: + - --allow-missing-credentials + id: detect-aws-credentials + - id: detect-private-key + - args: + - --pytest-test-first + id: name-tests-test + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 +- hooks: + - id: detect-secrets + repo: https://github.com/Yelp/detect-secrets + rev: v1.4.0 diff --git a/tests/end-to-end/test-data/CloudFormation_Sample/main.yaml b/tests/end-to-end/test-data/CloudFormation_Sample/main.yaml new file mode 100644 index 00000000..2c796de6 --- /dev/null +++ b/tests/end-to-end/test-data/CloudFormation_Sample/main.yaml @@ -0,0 +1,5 @@ +Resources: + HelloWorld: + Type: AWS::S3::Bucket + Properties: + BucketName: "hello-world-bucket" diff --git a/tests/end-to-end/test-data/Csharp_Sample/src/Program.cs b/tests/end-to-end/test-data/Csharp_Sample/src/Program.cs new file mode 100644 index 00000000..39ce3bde --- /dev/null +++ b/tests/end-to-end/test-data/Csharp_Sample/src/Program.cs @@ -0,0 +1,9 @@ +using System; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine("Hello, World!"); + } +} diff --git a/tests/end-to-end/test-data/Go_Sample/src/main.go b/tests/end-to-end/test-data/Go_Sample/src/main.go new file mode 100644 index 00000000..ef25884d --- /dev/null +++ b/tests/end-to-end/test-data/Go_Sample/src/main.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Println("Hello, world!") +} diff --git a/tests/end-to-end/test-data/JavaScript_Sample/public/index.html b/tests/end-to-end/test-data/JavaScript_Sample/public/index.html new file mode 100644 index 00000000..080cb0eb --- /dev/null +++ b/tests/end-to-end/test-data/JavaScript_Sample/public/index.html @@ -0,0 +1,11 @@ + + + + + + JavaScript_Sample + + + + + diff --git a/tests/end-to-end/test-data/JavaScript_Sample/src/index.js b/tests/end-to-end/test-data/JavaScript_Sample/src/index.js new file mode 100644 index 00000000..a8141d3b --- /dev/null +++ b/tests/end-to-end/test-data/JavaScript_Sample/src/index.js @@ -0,0 +1 @@ +console.log("Hello, world!"); diff --git a/tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt b/tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt new file mode 100644 index 00000000..d113eced --- /dev/null +++ b/tests/end-to-end/test-data/Kotlin_Sample/src/Main.kt @@ -0,0 +1 @@ +fun main() { println("Hello, world!") } diff --git a/tests/end-to-end/test-data/Python_Sample/main.py b/tests/end-to-end/test-data/Python_Sample/main.py new file mode 100644 index 00000000..f7cf60e1 --- /dev/null +++ b/tests/end-to-end/test-data/Python_Sample/main.py @@ -0,0 +1 @@ +print("Hello, world!") diff --git a/tests/end-to-end/test-data/Swift_Sample/Sources/main.swift b/tests/end-to-end/test-data/Swift_Sample/Sources/main.swift new file mode 100644 index 00000000..f7cf60e1 --- /dev/null +++ b/tests/end-to-end/test-data/Swift_Sample/Sources/main.swift @@ -0,0 +1 @@ +print("Hello, world!") diff --git a/tests/end-to-end/test-data/Terraform_Sample/main.tf b/tests/end-to-end/test-data/Terraform_Sample/main.tf new file mode 100644 index 00000000..69b152ca --- /dev/null +++ b/tests/end-to-end/test-data/Terraform_Sample/main.tf @@ -0,0 +1 @@ +output "hello_world" { value = "Hello, world!" } diff --git a/tests/end-to-end/test-data/TypeScript_Sample/src/index.ts b/tests/end-to-end/test-data/TypeScript_Sample/src/index.ts new file mode 100644 index 00000000..a8141d3b --- /dev/null +++ b/tests/end-to-end/test-data/TypeScript_Sample/src/index.ts @@ -0,0 +1 @@ +console.log("Hello, world!"); diff --git a/tests/end-to-end/test-language-detect.bats b/tests/end-to-end/test-language-detect.bats new file mode 100644 index 00000000..47173708 --- /dev/null +++ b/tests/end-to-end/test-language-detect.bats @@ -0,0 +1,65 @@ +setup() { + load "${BATS_LIBS_ROOT}/bats-support/load" + load "${BATS_LIBS_ROOT}/bats-assert/load" +} + +@test "can detect C# language" { + #cd tests/end-to-end/test-data/Csharp_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] The following language(s) support secrets detection: C#' + assert_output --partial '[seCureLI] - C#: 100%' +} + +@test "can detect Go language" { + #cd tests/end-to-end/test-data/Go_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Go: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Go.' +} + +@test "can detect Javascript language" { + #cd tests/end-to-end/test-data/JavaScript_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - JavaScript: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): JavaScript.' +} + +@test "can detect Kotlin language" { + #cd tests/end-to-end/test-data/Kotlin_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Kotlin: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Kotlin.' +} + +@test "can detect Python language" { + #cd tests/end-to-end/test-data/Python_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Python: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Python.' +} + +@test "can detect Swift language" { + #cd tests/end-to-end/test-data/Swift_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Swift.' + assert_output --partial '[seCureLI] - Swift: 100%' +} + +@test "can detect Terraform language" { + #cd tests/end-to-end/test-data/Terraform_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - Terraform: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): Terraform.' +} + +@test "can detect Typescript language" { + #cd tests/end-to-end/test-data/Typescript_Sample/ + run python secureli/main.py init -ry + assert_output --partial '[seCureLI] - TypeScript: 100%' + assert_output --partial '[seCureLI] seCureLI has been installed successfully for the following language(s): TypeScript.cd ..' +} + +@test "can detect Cloudformation language" { + #cd tests/end-to-end/test-data/CloudFormation_Sample/ + run python secureli/main.py init -ry +} \ No newline at end of file