Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
evankanderson committed Jan 10, 2025
1 parent 9fc98be commit 47c356c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
5 changes: 2 additions & 3 deletions internal/engine/eval/rego/http.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2023 The Minder Authors
// SPDX-FileCopyrightText: Copyright 2025 The Minder Authors
// SPDX-License-Identifier: Apache-2.0

// Package rego provides the rego rule evaluator
Expand All @@ -16,7 +16,6 @@ import (
"go.opentelemetry.io/otel/metric"
)


var blockedRequests metric.Int64Counter
var metricsInit sync.Once

Expand Down Expand Up @@ -74,4 +73,4 @@ func publicOnlyDialer(baseDialer dialContextFunc) dialContextFunc {
}
return conn, err
}
}
}
22 changes: 11 additions & 11 deletions internal/engine/eval/rego/http_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2023 The Minder Authors
// SPDX-FileCopyrightText: Copyright 2025 The Minder Authors
// SPDX-License-Identifier: Apache-2.0

// Package rego provides the rego rule evaluator
Expand All @@ -11,19 +11,19 @@ import (
"net/http/httptest"
"testing"

"github.com/stretchr/testify/require"

engerrors "github.com/mindersec/minder/internal/engine/errors"
"github.com/mindersec/minder/internal/engine/eval/rego"
minderv1 "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1"
"github.com/mindersec/minder/pkg/engine/v1/interfaces"
"github.com/stretchr/testify/require"
)

func TestLimitedDialer(t *testing.T) {
t.Parallel()

ts := httptest.NewServer(http.HandlerFunc(func (w http.ResponseWriter, r *http.Request) {
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
t.Log("FETCHED!")
_, _ = w.Write([]byte(`{"ok": 1}`))
}))
t.Cleanup(ts.Close)
Expand All @@ -41,16 +41,16 @@ func TestLimitedDialer(t *testing.T) {
`

tests := []struct {
name string
url string
name string
url string
wantErr string
}{{
name: "test blocked fetch by name",
url: ts.URL,
name: "test blocked fetch by name",
url: ts.URL,
wantErr: "remote address is not public",
},{
}, {
name: "google.com not blocked",
url: "http://www.google.com",
url: "http://www.google.com",
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -59,7 +59,7 @@ func TestLimitedDialer(t *testing.T) {
eval, err := rego.NewRegoEvaluator(
&minderv1.RuleType_Definition_Eval_Rego{
Type: rego.DenyByDefaultEvaluationType.String(),
Def: fmt.Sprintf(ruleDef, tt.url),
Def: fmt.Sprintf(ruleDef, tt.url),
},
nil,
)
Expand Down

0 comments on commit 47c356c

Please sign in to comment.