Skip to content

Commit 5a0e8cb

Browse files
authored
fix: reduce vulnerable test dependencies (#13554)
1 parent 6749048 commit 5a0e8cb

18 files changed

Lines changed: 240 additions & 5054 deletions

File tree

ci/pod/openfunction/function-example/test-body/cmd/main.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818
package main
1919

2020
import (
21-
"context"
2221
"log"
22+
"net/http"
2323

24-
_ "example.com/hello"
25-
"github.com/OpenFunction/functions-framework-go/framework"
24+
hello "example.com/hello"
2625
)
2726

2827
func main() {
29-
fwk, err := framework.NewFramework()
30-
if err != nil {
31-
log.Fatalf("failed to create framework: %v", err)
32-
}
33-
if err = fwk.Start(context.Background()); err != nil {
34-
log.Fatalf("failed to start framework: %v", err)
35-
}
28+
http.HandleFunc("/", hello.HelloWorld)
29+
log.Fatal(http.ListenAndServe(":8080", nil))
3630
}
Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
11
module example.com/hello
22

3-
go 1.17
4-
5-
require github.com/OpenFunction/functions-framework-go v0.3.0
6-
7-
require (
8-
github.com/SkyAPM/go2sky v1.4.1 // indirect
9-
github.com/cloudevents/sdk-go/v2 v2.4.1 // indirect
10-
github.com/dapr/dapr v1.6.0 // indirect
11-
github.com/dapr/go-sdk v1.3.1 // indirect
12-
github.com/go-logr/logr v1.2.0 // indirect
13-
github.com/golang/protobuf v1.5.2 // indirect
14-
github.com/google/uuid v1.3.0 // indirect
15-
github.com/json-iterator/go v1.1.11 // indirect
16-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
17-
github.com/modern-go/reflect2 v1.0.1 // indirect
18-
github.com/pkg/errors v0.9.1 // indirect
19-
go.uber.org/atomic v1.9.0 // indirect
20-
go.uber.org/multierr v1.7.0 // indirect
21-
go.uber.org/zap v1.19.1 // indirect
22-
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f // indirect
23-
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
24-
golang.org/x/text v0.3.7 // indirect
25-
google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2 // indirect
26-
google.golang.org/grpc v1.40.0 // indirect
27-
google.golang.org/protobuf v1.33.0 // indirect
28-
gopkg.in/yaml.v3 v3.0.0 // indirect
29-
k8s.io/klog/v2 v2.30.0 // indirect
30-
skywalking.apache.org/repo/goapi v0.0.0-20220401015832-2c9eee9481eb // indirect
31-
)
3+
go 1.24

ci/pod/openfunction/function-example/test-body/go.sum

Lines changed: 0 additions & 1760 deletions
This file was deleted.

ci/pod/openfunction/function-example/test-body/hello.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,8 @@ import (
2323
"fmt"
2424
"io"
2525
"net/http"
26-
27-
"github.com/OpenFunction/functions-framework-go/functions"
2826
)
2927

30-
func init() {
31-
functions.HTTP("HelloWorld", HelloWorld)
32-
}
33-
3428
func HelloWorld(w http.ResponseWriter, r *http.Request) {
3529
body, _ := io.ReadAll(r.Body)
3630
fmt.Fprintf(w, "Hello, %s!\n", string(body))
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2022 The OpenFunction Authors.
3+
*
4+
* Licensed to the Apache Software Foundation (ASF) under one or more
5+
* contributor license agreements. See the NOTICE file distributed with
6+
* this work for additional information regarding copyright ownership.
7+
* The ASF licenses this file to You under the Apache License, Version 2.0
8+
* (the "License"); you may not use this file except in compliance with
9+
* the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
package hello
21+
22+
import (
23+
"net/http/httptest"
24+
"strings"
25+
"testing"
26+
)
27+
28+
func TestHelloWorldReadsRequestBody(t *testing.T) {
29+
req := httptest.NewRequest("POST", "/", strings.NewReader("APISIX"))
30+
rec := httptest.NewRecorder()
31+
32+
HelloWorld(rec, req)
33+
34+
if got, want := rec.Body.String(), "Hello, APISIX!\n"; got != want {
35+
t.Fatalf("unexpected response body: got %q, want %q", got, want)
36+
}
37+
}

ci/pod/openfunction/function-example/test-uri/cmd/main.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@
1818
package main
1919

2020
import (
21-
"context"
2221
"log"
22+
"net/http"
2323

24-
_ "example.com/hello"
25-
"github.com/OpenFunction/functions-framework-go/framework"
24+
hello "example.com/hello"
2625
)
2726

2827
func main() {
29-
fwk, err := framework.NewFramework()
30-
if err != nil {
31-
log.Fatalf("failed to create framework: %v", err)
32-
}
33-
if err = fwk.Start(context.Background()); err != nil {
34-
log.Fatalf("failed to start framework: %v", err)
35-
}
28+
http.HandleFunc("/", hello.HelloWorld)
29+
log.Fatal(http.ListenAndServe(":8080", nil))
3630
}
Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
11
module example.com/hello
22

3-
go 1.17
4-
5-
require github.com/OpenFunction/functions-framework-go v0.4.0
6-
7-
require (
8-
github.com/SkyAPM/go2sky v1.4.1 // indirect
9-
github.com/cloudevents/sdk-go/v2 v2.4.1 // indirect
10-
github.com/dapr/dapr v1.8.3 // indirect
11-
github.com/dapr/go-sdk v1.5.0 // indirect
12-
github.com/go-logr/logr v1.2.3 // indirect
13-
github.com/golang/protobuf v1.5.2 // indirect
14-
github.com/google/uuid v1.3.0 // indirect
15-
github.com/gorilla/mux v1.8.0 // indirect
16-
github.com/json-iterator/go v1.1.12 // indirect
17-
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
18-
github.com/modern-go/reflect2 v1.0.2 // indirect
19-
github.com/pkg/errors v0.9.1 // indirect
20-
go.uber.org/atomic v1.9.0 // indirect
21-
go.uber.org/multierr v1.7.0 // indirect
22-
go.uber.org/zap v1.21.0 // indirect
23-
golang.org/x/net v0.0.0-20220621193019-9d032be2e588 // indirect
24-
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
25-
golang.org/x/text v0.3.7 // indirect
26-
google.golang.org/genproto v0.0.0-20220622171453-ea41d75dfa0f // indirect
27-
google.golang.org/grpc v1.47.0 // indirect
28-
google.golang.org/protobuf v1.33.0 // indirect
29-
gopkg.in/yaml.v3 v3.0.1 // indirect
30-
k8s.io/klog/v2 v2.30.0 // indirect
31-
skywalking.apache.org/repo/goapi v0.0.0-20220401015832-2c9eee9481eb // indirect
32-
)
3+
go 1.24

0 commit comments

Comments
 (0)