Skip to content

Commit

Permalink
feat: add magefile
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
  • Loading branch information
fzipi committed Jul 26, 2023
1 parent 750f77d commit 29c6c1c
Show file tree
Hide file tree
Showing 66 changed files with 360 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions check/base.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package check

import (
Expand Down
6 changes: 4 additions & 2 deletions check/base_test.go
Original file line number Diff line number Diff line change
@@ -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{
Expand Down
3 changes: 3 additions & 0 deletions check/error.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 4 additions & 2 deletions check/error_test.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions check/logs.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions check/logs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package check

import (
Expand Down
3 changes: 3 additions & 0 deletions check/response.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package check

import (
Expand Down
6 changes: 4 additions & 2 deletions check/response_test.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions check/status.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions check/status_test.go
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion cmd/check.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmd/check_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
Expand Down
3 changes: 3 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
Expand Down
3 changes: 3 additions & 0 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
Expand Down
8 changes: 5 additions & 3 deletions cmd/run.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions cmd/run_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package cmd

import (
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package config

import (
Expand Down
3 changes: 3 additions & 0 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package config

import (
Expand Down
3 changes: 3 additions & 0 deletions config/types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package config

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/client.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/client_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/connection.go
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/connection_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/header.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/request.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/request_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/response.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/response_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/rtt.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import "time"
Expand Down
3 changes: 3 additions & 0 deletions ftwhttp/types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright 2023 OWASP ModSecurity Core Rule Set Project
// SPDX-License-Identifier: Apache-2.0

package ftwhttp

import (
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
19 changes: 19 additions & 0 deletions mage.go
Original file line number Diff line number Diff line change
@@ -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())
}
Loading

0 comments on commit 29c6c1c

Please sign in to comment.