From 29c6c1cf4f1ec9b8c4c6f529caa641aa61898fd6 Mon Sep 17 00:00:00 2001 From: Felipe Zipitria Date: Tue, 25 Jul 2023 13:29:01 +0200 Subject: [PATCH] feat: add magefile Signed-off-by: Felipe Zipitria --- Dockerfile | 3 + check/base.go | 3 + check/base_test.go | 6 +- check/error.go | 3 + check/error_test.go | 6 +- check/logs.go | 3 + check/logs_test.go | 3 + check/response.go | 3 + check/response_test.go | 6 +- check/status.go | 3 + check/status_test.go | 6 +- cmd/check.go | 6 +- cmd/check_test.go | 3 + cmd/root.go | 3 + cmd/root_test.go | 3 + cmd/run.go | 8 +- cmd/run_test.go | 3 + config/config.go | 3 + config/config_test.go | 3 + config/types.go | 3 + ftwhttp/client.go | 3 + ftwhttp/client_test.go | 3 + ftwhttp/connection.go | 3 + ftwhttp/connection_test.go | 3 + ftwhttp/header.go | 3 + ftwhttp/request.go | 3 + ftwhttp/request_test.go | 3 + ftwhttp/response.go | 3 + ftwhttp/response_test.go | 3 + ftwhttp/rtt.go | 3 + ftwhttp/types.go | 3 + go.mod | 1 + go.sum | 2 + mage.go | 19 +++++ magefile.go | 132 ++++++++++++++++++++++++++++++ main.go | 6 +- output/output.go | 3 + output/output_test.go | 3 + runner/run.go | 6 +- runner/run_cloud_test.go | 8 +- runner/run_input_override_test.go | 6 +- runner/run_test.go | 3 + runner/stats.go | 6 +- runner/types.go | 6 +- test/data.go | 3 + test/data_test.go | 6 +- test/defaults.go | 3 + test/defaults_test.go | 3 + test/errors.go | 3 + test/errors_test.go | 3 + test/files.go | 3 + test/files_test.go | 3 + test/types.go | 3 + test/types_test.go | 3 + test/yaml.go | 3 + utils/empty.go | 3 + utils/empty_test.go | 3 + utils/tests.go | 3 + utils/tests_test.go | 3 + utils/time.go | 3 + utils/time_test.go | 3 + waflog/read.go | 3 + waflog/read_test.go | 3 + waflog/types.go | 3 + waflog/waflog.go | 3 + waflog/waflog_test.go | 3 + 66 files changed, 360 insertions(+), 23 deletions(-) create mode 100644 mage.go create mode 100644 magefile.go diff --git a/Dockerfile b/Dockerfile index 270236d9..b52cec20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +# Copyright 2023 OWASP ModSecurity Core Rule Set Project +# SPDX-License-Identifier: Apache-2.0 + FROM alpine:3 RUN apk add --no-cache ca-certificates diff --git a/check/base.go b/check/base.go index b6244c11..91f208c3 100644 --- a/check/base.go +++ b/check/base.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( diff --git a/check/base_test.go b/check/base_test.go index 451e7646..5d09fca2 100644 --- a/check/base_test.go +++ b/check/base_test.go @@ -1,15 +1,17 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( "sort" "testing" - "github.com/coreruleset/go-ftw/utils" - "github.com/stretchr/testify/suite" "github.com/coreruleset/go-ftw/config" "github.com/coreruleset/go-ftw/test" + "github.com/coreruleset/go-ftw/utils" ) var configMap = map[string]string{ diff --git a/check/error.go b/check/error.go index 118d3f46..a85dbb77 100644 --- a/check/error.go +++ b/check/error.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import "github.com/rs/zerolog/log" diff --git a/check/error_test.go b/check/error_test.go index 47b85a35..889455e9 100644 --- a/check/error_test.go +++ b/check/error_test.go @@ -1,14 +1,16 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( "errors" "testing" - "github.com/coreruleset/go-ftw/utils" - "github.com/stretchr/testify/suite" "github.com/coreruleset/go-ftw/config" + "github.com/coreruleset/go-ftw/utils" ) var expectedOKTests = []struct { diff --git a/check/logs.go b/check/logs.go index d510e7d8..ab1d4ea8 100644 --- a/check/logs.go +++ b/check/logs.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check // AssertNoLogContains returns true is the string is not found in the logs diff --git a/check/logs_test.go b/check/logs_test.go index 977f4320..38e87b26 100644 --- a/check/logs_test.go +++ b/check/logs_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( diff --git a/check/response.go b/check/response.go index 250fc838..6f38bbcb 100644 --- a/check/response.go +++ b/check/response.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( diff --git a/check/response_test.go b/check/response_test.go index 35930aff..cb26a8cf 100644 --- a/check/response_test.go +++ b/check/response_test.go @@ -1,13 +1,15 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( "testing" - "github.com/coreruleset/go-ftw/utils" - "github.com/stretchr/testify/suite" "github.com/coreruleset/go-ftw/config" + "github.com/coreruleset/go-ftw/utils" ) var expectedResponseOKTests = []struct { diff --git a/check/status.go b/check/status.go index 4138a097..8196f4b2 100644 --- a/check/status.go +++ b/check/status.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check // AssertStatus will match the expected status list with the one received in the response diff --git a/check/status_test.go b/check/status_test.go index 7b437860..e450a990 100644 --- a/check/status_test.go +++ b/check/status_test.go @@ -1,13 +1,15 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package check import ( "testing" - "github.com/coreruleset/go-ftw/utils" - "github.com/stretchr/testify/suite" "github.com/coreruleset/go-ftw/config" + "github.com/coreruleset/go-ftw/utils" ) var statusOKTests = []struct { diff --git a/cmd/check.go b/cmd/check.go index a9a848d0..05ce6806 100644 --- a/cmd/check.go +++ b/cmd/check.go @@ -1,11 +1,15 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( "fmt" - "github.com/coreruleset/go-ftw/test" "github.com/rs/zerolog/log" "github.com/spf13/cobra" + + "github.com/coreruleset/go-ftw/test" ) // NewCheckCmd represents the check command diff --git a/cmd/check_test.go b/cmd/check_test.go index 02803cde..d84ab3ce 100644 --- a/cmd/check_test.go +++ b/cmd/check_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cmd/root.go b/cmd/root.go index 29caed95..779b2bd9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cmd/root_test.go b/cmd/root_test.go index 453c1d40..b696c1be 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/cmd/run.go b/cmd/run.go index 8f71b118..a142ceb3 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( @@ -9,15 +12,14 @@ import ( "github.com/go-logr/zerologr" "github.com/rs/zerolog/log" - "wait4x.dev/v2/waiter" - + "github.com/spf13/cobra" "wait4x.dev/v2/checker" "wait4x.dev/v2/checker/http" + "wait4x.dev/v2/waiter" "github.com/coreruleset/go-ftw/output" "github.com/coreruleset/go-ftw/runner" "github.com/coreruleset/go-ftw/test" - "github.com/spf13/cobra" ) // NewRunCmd represents the run command diff --git a/cmd/run_test.go b/cmd/run_test.go index f1823f69..e188358b 100644 --- a/cmd/run_test.go +++ b/cmd/run_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package cmd import ( diff --git a/config/config.go b/config/config.go index dd1f454c..fb56a716 100644 --- a/config/config.go +++ b/config/config.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package config import ( diff --git a/config/config_test.go b/config/config_test.go index 81b71937..e9ee3d7b 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package config import ( diff --git a/config/types.go b/config/types.go index 435fcee9..8dc5191d 100644 --- a/config/types.go +++ b/config/types.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package config import ( diff --git a/ftwhttp/client.go b/ftwhttp/client.go index 9025c54e..767aa1ed 100644 --- a/ftwhttp/client.go +++ b/ftwhttp/client.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/client_test.go b/ftwhttp/client_test.go index ba6689c1..5f5eb871 100644 --- a/ftwhttp/client_test.go +++ b/ftwhttp/client_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/connection.go b/ftwhttp/connection.go index d2737803..ac9bd5e7 100644 --- a/ftwhttp/connection.go +++ b/ftwhttp/connection.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + // Package ftwhttp provides low level abstractions for sending/receiving raw http messages package ftwhttp diff --git a/ftwhttp/connection_test.go b/ftwhttp/connection_test.go index 7865f993..20b66e28 100644 --- a/ftwhttp/connection_test.go +++ b/ftwhttp/connection_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/header.go b/ftwhttp/header.go index 2f19e46b..54e7a43f 100644 --- a/ftwhttp/header.go +++ b/ftwhttp/header.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/request.go b/ftwhttp/request.go index 69ab888e..4d8b4979 100644 --- a/ftwhttp/request.go +++ b/ftwhttp/request.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/request_test.go b/ftwhttp/request_test.go index 7a427f3a..33565d86 100644 --- a/ftwhttp/request_test.go +++ b/ftwhttp/request_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/response.go b/ftwhttp/response.go index 645bc4f9..c39fec15 100644 --- a/ftwhttp/response.go +++ b/ftwhttp/response.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp // GetFullResponse gives the full response as string, or nil if there was some error diff --git a/ftwhttp/response_test.go b/ftwhttp/response_test.go index b9531a4d..e131addb 100644 --- a/ftwhttp/response_test.go +++ b/ftwhttp/response_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/ftwhttp/rtt.go b/ftwhttp/rtt.go index f5bcd593..2fd50914 100644 --- a/ftwhttp/rtt.go +++ b/ftwhttp/rtt.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import "time" diff --git a/ftwhttp/types.go b/ftwhttp/types.go index 31610bf3..ef3a363d 100644 --- a/ftwhttp/types.go +++ b/ftwhttp/types.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package ftwhttp import ( diff --git a/go.mod b/go.mod index 57f7abea..d7e84582 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( github.com/icza/backscanner v0.0.0-20220812133752-2e60bffed4a2 github.com/knadh/koanf v1.5.0 github.com/kyokomi/emoji v2.2.4+incompatible + github.com/magefile/mage v1.15.0 github.com/rs/zerolog v1.29.1 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 diff --git a/go.sum b/go.sum index 39c175f8..340b3c24 100644 --- a/go.sum +++ b/go.sum @@ -191,6 +191,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kyokomi/emoji v2.2.4+incompatible h1:np0woGKwx9LiHAQmwZx79Oc0rHpNw3o+3evou4BEPv4= github.com/kyokomi/emoji v2.2.4+incompatible/go.mod h1:mZ6aGCD7yk8j6QY6KICwnZ2pxoszVseX1DNoGtU2tBA= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= +github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= diff --git a/mage.go b/mage.go new file mode 100644 index 00000000..bbf0c4e7 --- /dev/null +++ b/mage.go @@ -0,0 +1,19 @@ +// Copyright 2023 OWASP Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + +//go:build ignore +// +build ignore + +// Entrypoint to mage for running without needing to install the command. +// https://magefile.org/zeroinstall/ +package main + +import ( + "os" + + "github.com/magefile/mage/mage" +) + +func main() { + os.Exit(mage.Main()) +} diff --git a/magefile.go b/magefile.go new file mode 100644 index 00000000..298a8ca5 --- /dev/null +++ b/magefile.go @@ -0,0 +1,132 @@ +// Copyright 2023 OWASP Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + +//go:build mage +// +build mage + +package main + +import ( + "errors" + "fmt" + "io" + "os" + "path/filepath" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" +) + +var addLicenseVersion = "v1.1.1" // https://github.com/google/addlicense +var golangCILintVer = "v1.53.1" // https://github.com/golangci/golangci-lint/releases +var gosImportsVer = "v0.3.8" // https://github.com/rinchsan/gosimports/releases/tag/v0.1.5 +var goGciVer = "v0.10.1" // https://github.com/daixiang0/gci/releases/tag/v0.8.2 +var goCycloVer = "v0.6.0" // https://github.com/fzipp/gocyclo/releases/tag/v0.6.0 + +var errCommitFormatting = errors.New("files not formatted, please commit formatting changes") +var errNoGitDir = errors.New("no .git directory found") + +// Format formats code in this repository. +func Format() error { + if err := sh.RunV("go", "mod", "tidy"); err != nil { + return err + } + // addlicense strangely logs skipped files to stderr despite not being erroneous, so use the long sh.Exec form to + // discard stderr too. + if _, err := sh.Exec(map[string]string{}, io.Discard, io.Discard, "go", "run", fmt.Sprintf("github.com/google/addlicense@%s", addLicenseVersion), + "-c", "OWASP ModSecurity Core Rule Set Project", + "-s=only", + "-ignore", "**/*.yml", + "-ignore", "**/*.yaml", + "-ignore", "examples/**", "."); err != nil { + return err + } + if err := sh.RunV("go", "run", fmt.Sprintf("github.com/rinchsan/gosimports/cmd/gosimports@%s", gosImportsVer), + "-w", + "-local", + "github.com/coreruleset/go-ftw", + "."); err != nil { + return err + } + + return sh.RunV("go", "run", fmt.Sprintf("github.com/daixiang0/gci@%s", goGciVer), + "write", + "--section", + "standard", + "--section", + "default", + "--section", + "blank", + "--section", + "prefix(github.com/coreruleset/go-ftw)", + "--custom-order", + "--skip-generated", + ".") +} + +// Lint verifies code quality. +func Lint() error { + if err := sh.RunV("go", "run", fmt.Sprintf("github.com/golangci/golangci-lint/cmd/golangci-lint@%s", golangCILintVer), "run"); err != nil { + return err + } + + if err := sh.RunV("go", "run", fmt.Sprintf("github.com/fzipp/gocyclo/cmd/gocyclo@%s", goCycloVer), "-over", "15", "."); err != nil { + return err + } + + sh.Run("git", "stash", "-k", "-u") // stash unstagged changes so they don't interfere with git diff below + defer sh.Run("git", "stash", "pop") + + mg.SerialDeps(Format) + + if sh.Run("git", "diff", "--exit-code") != nil { + return errCommitFormatting + } + + return nil +} + +// Test runs all tests. +func Test() error { + if err := sh.RunV("go", "test", "-v", "./..."); err != nil { + return err + } + + return nil +} + +// Coverage runs tests with coverage and race detector enabled. +func Coverage() error { + if err := os.MkdirAll("build", 0755); err != nil { + return err + } + if err := sh.RunV("go", "test", "-v", "-race", "-coverprofile=build/coverage.txt", "-covermode=atomic", "-coverpkg=./...", "./..."); err != nil { + return err + } + + return sh.RunV("go", "tool", "cover", "-html=build/coverage.txt", "-o", "build/coverage.html") +} + +// Doc runs godoc, access at http://localhost:6060 +func Doc() error { + return sh.RunV("go", "run", "golang.org/x/tools/cmd/godoc@latest", "-http=:6060") +} + +// Precommit installs a git hook to run check when committing +func Precommit() error { + if _, err := os.Stat(filepath.Join(".git", "hooks")); os.IsNotExist(err) { + return errNoGitDir + } + + f, err := os.ReadFile(".pre-commit.hook") + if err != nil { + return err + } + + return os.WriteFile(filepath.Join(".git", "hooks", "pre-commit"), f, 0755) +} + +// Check runs lint and tests. +func Check() { + mg.SerialDeps(Lint, Test) +} diff --git a/main.go b/main.go index 1a302813..c004a600 100644 --- a/main.go +++ b/main.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + // Package go-ftw is a Framework for Testing Web Application Firewalls // It is derived from the work made with the pytest plugin `ftw` package main @@ -7,11 +10,12 @@ import ( "errors" "fmt" "os" - _ "time/tzdata" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + _ "time/tzdata" + "github.com/coreruleset/go-ftw/cmd" ) diff --git a/output/output.go b/output/output.go index 790de5db..bf9cec62 100644 --- a/output/output.go +++ b/output/output.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + // Package output provides an interface for showing test results in different formats. package output diff --git a/output/output_test.go b/output/output_test.go index c0a48a10..bac39286 100644 --- a/output/output_test.go +++ b/output/output_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package output import ( diff --git a/runner/run.go b/runner/run.go index 68914f0b..ae468b9c 100644 --- a/runner/run.go +++ b/runner/run.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package runner import ( @@ -6,12 +9,11 @@ import ( "regexp" "time" - "github.com/coreruleset/go-ftw/config" - "github.com/google/uuid" "github.com/rs/zerolog/log" "github.com/coreruleset/go-ftw/check" + "github.com/coreruleset/go-ftw/config" "github.com/coreruleset/go-ftw/ftwhttp" "github.com/coreruleset/go-ftw/output" "github.com/coreruleset/go-ftw/test" diff --git a/runner/run_cloud_test.go b/runner/run_cloud_test.go index 982428e6..77040972 100644 --- a/runner/run_cloud_test.go +++ b/runner/run_cloud_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package runner import ( @@ -9,12 +12,13 @@ import ( "testing" "text/template" + "github.com/rs/zerolog/log" + "github.com/stretchr/testify/suite" + "github.com/coreruleset/go-ftw/config" "github.com/coreruleset/go-ftw/ftwhttp" "github.com/coreruleset/go-ftw/output" "github.com/coreruleset/go-ftw/test" - "github.com/rs/zerolog/log" - "github.com/stretchr/testify/suite" ) type runCloudTestSuite struct { diff --git a/runner/run_input_override_test.go b/runner/run_input_override_test.go index 9a41dea3..49524ce1 100644 --- a/runner/run_input_override_test.go +++ b/runner/run_input_override_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package runner import ( @@ -11,10 +14,11 @@ import ( "text/template" "github.com/Masterminds/sprig" + "github.com/stretchr/testify/suite" + "github.com/coreruleset/go-ftw/config" "github.com/coreruleset/go-ftw/ftwhttp" "github.com/coreruleset/go-ftw/test" - "github.com/stretchr/testify/suite" ) type inputOverrideTestSuite struct { diff --git a/runner/run_test.go b/runner/run_test.go index da6db398..9b801f9e 100644 --- a/runner/run_test.go +++ b/runner/run_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package runner import ( diff --git a/runner/stats.go b/runner/stats.go index 03f64ac0..b37aab75 100644 --- a/runner/stats.go +++ b/runner/stats.go @@ -1,11 +1,15 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package runner import ( "encoding/json" "time" - "github.com/coreruleset/go-ftw/output" "github.com/rs/zerolog/log" + + "github.com/coreruleset/go-ftw/output" ) // TestResult type are the values that the result of a test can have diff --git a/runner/types.go b/runner/types.go index 095460f9..4781f8e5 100644 --- a/runner/types.go +++ b/runner/types.go @@ -1,13 +1,15 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package runner import ( "regexp" "time" - "github.com/coreruleset/go-ftw/output" - "github.com/coreruleset/go-ftw/config" "github.com/coreruleset/go-ftw/ftwhttp" + "github.com/coreruleset/go-ftw/output" "github.com/coreruleset/go-ftw/waflog" ) diff --git a/test/data.go b/test/data.go index 232be48c..10291dd2 100644 --- a/test/data.go +++ b/test/data.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/data_test.go b/test/data_test.go index 50369c63..5849ce46 100644 --- a/test/data_test.go +++ b/test/data_test.go @@ -1,11 +1,13 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( "testing" - "github.com/stretchr/testify/suite" - "github.com/goccy/go-yaml" + "github.com/stretchr/testify/suite" ) var repeatTestSprig = `foo=%3d++++++++++++++++++++++++++++++++++` diff --git a/test/defaults.go b/test/defaults.go index 54bdd161..c593250d 100644 --- a/test/defaults.go +++ b/test/defaults.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/defaults_test.go b/test/defaults_test.go index 71c3c401..578667fb 100644 --- a/test/defaults_test.go +++ b/test/defaults_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/errors.go b/test/errors.go index 94bc143f..6d4eccdd 100644 --- a/test/errors.go +++ b/test/errors.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/errors_test.go b/test/errors_test.go index 472930bb..6b485bed 100644 --- a/test/errors_test.go +++ b/test/errors_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/files.go b/test/files.go index 40321a41..7ffd6a0d 100644 --- a/test/files.go +++ b/test/files.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/files_test.go b/test/files_test.go index 3219dd1c..83d95c99 100644 --- a/test/files_test.go +++ b/test/files_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/types.go b/test/types.go index e37036a6..1d3f9861 100644 --- a/test/types.go +++ b/test/types.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/types_test.go b/test/types_test.go index ef1d6ae1..97e309cc 100644 --- a/test/types_test.go +++ b/test/types_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/test/yaml.go b/test/yaml.go index 693596b4..8bf09d12 100644 --- a/test/yaml.go +++ b/test/yaml.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package test import ( diff --git a/utils/empty.go b/utils/empty.go index 7f6e6584..c864bc55 100644 --- a/utils/empty.go +++ b/utils/empty.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package utils import ( diff --git a/utils/empty_test.go b/utils/empty_test.go index fc578be2..df44234f 100644 --- a/utils/empty_test.go +++ b/utils/empty_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package utils import ( diff --git a/utils/tests.go b/utils/tests.go index abdfc892..e2970d50 100644 --- a/utils/tests.go +++ b/utils/tests.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package utils import ( diff --git a/utils/tests_test.go b/utils/tests_test.go index 0e52341d..f7eeaa17 100644 --- a/utils/tests_test.go +++ b/utils/tests_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package utils import ( diff --git a/utils/time.go b/utils/time.go index 6b1a4b35..d2668a0b 100644 --- a/utils/time.go +++ b/utils/time.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package utils import "time" diff --git a/utils/time_test.go b/utils/time_test.go index b197a05a..b08a1963 100644 --- a/utils/time_test.go +++ b/utils/time_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package utils import ( diff --git a/waflog/read.go b/waflog/read.go index 65111623..fe2f3496 100644 --- a/waflog/read.go +++ b/waflog/read.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package waflog import ( diff --git a/waflog/read_test.go b/waflog/read_test.go index f9ac7e03..89ec6139 100644 --- a/waflog/read_test.go +++ b/waflog/read_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package waflog import ( diff --git a/waflog/types.go b/waflog/types.go index 7c845c35..ca5f041c 100644 --- a/waflog/types.go +++ b/waflog/types.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + // Package waflog encapsulates getting logs from a WAF to compare with expected results package waflog diff --git a/waflog/waflog.go b/waflog/waflog.go index f3aca277..50c70580 100644 --- a/waflog/waflog.go +++ b/waflog/waflog.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package waflog import ( diff --git a/waflog/waflog_test.go b/waflog/waflog_test.go index 67a3760f..254ba3e8 100644 --- a/waflog/waflog_test.go +++ b/waflog/waflog_test.go @@ -1,3 +1,6 @@ +// Copyright 2023 OWASP ModSecurity Core Rule Set Project +// SPDX-License-Identifier: Apache-2.0 + package waflog import (