Skip to content

Commit 100d652

Browse files
Merge branch 'dev' into bump_httpx_version
2 parents 776cb4f + d76187f commit 100d652

File tree

6 files changed

+1174
-97
lines changed

6 files changed

+1174
-97
lines changed

cmd/integration-test/exporters.go

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
"time"
8+
9+
"github.com/projectdiscovery/nuclei/v3/pkg/output"
10+
"github.com/projectdiscovery/nuclei/v3/pkg/reporting/exporters/mongo"
11+
"github.com/testcontainers/testcontainers-go"
12+
mongocontainer "github.com/testcontainers/testcontainers-go/modules/mongodb"
13+
14+
osutil "github.com/projectdiscovery/utils/os"
15+
mongoclient "go.mongodb.org/mongo-driver/mongo"
16+
mongooptions "go.mongodb.org/mongo-driver/mongo/options"
17+
)
18+
19+
const (
20+
dbName = "test"
21+
dbImage = "mongo:8"
22+
)
23+
24+
var exportersTestCases = []TestCaseInfo{
25+
{Path: "exporters/mongo", TestCase: &mongoExporter{}, DisableOn: func() bool {
26+
return osutil.IsWindows() || osutil.IsOSX()
27+
}},
28+
}
29+
30+
type mongoExporter struct{}
31+
32+
func (m *mongoExporter) Execute(filepath string) error {
33+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
34+
defer cancel()
35+
36+
// Start a MongoDB container
37+
mongodbContainer, err := mongocontainer.Run(ctx, dbImage)
38+
defer func() {
39+
if err := testcontainers.TerminateContainer(mongodbContainer); err != nil {
40+
log.Printf("failed to terminate container: %s", err)
41+
}
42+
}()
43+
if err != nil {
44+
return fmt.Errorf("failed to start container: %w", err)
45+
}
46+
47+
connString, err := mongodbContainer.ConnectionString(ctx)
48+
if err != nil {
49+
return fmt.Errorf("failed to get connection string for MongoDB container: %s", err)
50+
}
51+
connString = connString + dbName
52+
53+
// Create a MongoDB exporter and write a test result to the database
54+
opts := mongo.Options{
55+
ConnectionString: connString,
56+
CollectionName: "test",
57+
BatchSize: 1, // Ensure we write the result immediately
58+
}
59+
60+
exporter, err := mongo.New(&opts)
61+
if err != nil {
62+
return fmt.Errorf("failed to create MongoDB exporter: %s", err)
63+
}
64+
defer func() {
65+
if err := exporter.Close(); err != nil {
66+
fmt.Printf("failed to close exporter: %s\n", err)
67+
}
68+
}()
69+
70+
res := &output.ResultEvent{
71+
Request: "test request",
72+
Response: "test response",
73+
}
74+
75+
err = exporter.Export(res)
76+
if err != nil {
77+
return fmt.Errorf("failed to export result event to MongoDB: %s", err)
78+
}
79+
80+
// Verify that the result was written to the database
81+
clientOptions := mongooptions.Client().ApplyURI(connString)
82+
client, err := mongoclient.Connect(ctx, clientOptions)
83+
if err != nil {
84+
return fmt.Errorf("error creating MongoDB client: %s", err)
85+
}
86+
defer func() {
87+
if err := client.Disconnect(ctx); err != nil {
88+
fmt.Printf("failed to disconnect from MongoDB: %s\n", err)
89+
}
90+
}()
91+
92+
collection := client.Database(dbName).Collection(opts.CollectionName)
93+
var actualRes output.ResultEvent
94+
err = collection.FindOne(ctx, map[string]interface{}{"request": res.Request}).Decode(&actualRes)
95+
if err != nil {
96+
return fmt.Errorf("failed to find document in MongoDB: %s", err)
97+
}
98+
99+
if actualRes.Request != res.Request || actualRes.Response != res.Response {
100+
return fmt.Errorf("exported result does not match expected result: got %v, want %v", actualRes, res)
101+
}
102+
103+
return nil
104+
}

cmd/integration-test/integration-test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ var (
5757
"flow": flowTestcases,
5858
"javascript": jsTestcases,
5959
"matcher-status": matcherStatusTestcases,
60+
"exporters": exportersTestCases,
6061
}
6162
// flakyTests are run with a retry count of 3
6263
flakyTests = map[string]bool{

go.mod

Lines changed: 51 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ require (
3939
go.uber.org/multierr v1.11.0
4040
golang.org/x/net v0.42.0
4141
golang.org/x/oauth2 v0.30.0
42-
golang.org/x/text v0.27.0
42+
golang.org/x/text v0.28.0
4343
gopkg.in/yaml.v2 v2.4.0
4444
)
4545

@@ -110,26 +110,28 @@ require (
110110
github.com/redis/go-redis/v9 v9.11.0
111111
github.com/seh-msft/burpxml v1.0.1
112112
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466
113-
github.com/stretchr/testify v1.10.0
113+
github.com/stretchr/testify v1.11.0
114114
github.com/tarunKoyalwar/goleak v0.0.0-20240429141123-0efa90dbdcf9
115+
github.com/testcontainers/testcontainers-go v0.38.0
116+
github.com/testcontainers/testcontainers-go/modules/mongodb v0.37.0
115117
github.com/yassinebenaid/godump v0.11.1
116118
github.com/zmap/zgrab2 v0.1.8
117119
gitlab.com/gitlab-org/api/client-go v0.130.1
118120
go.mongodb.org/mongo-driver v1.17.4
119-
golang.org/x/term v0.33.0
121+
golang.org/x/term v0.34.0
120122
gopkg.in/yaml.v3 v3.0.1
121123
moul.io/http2curl v1.0.0
122124
)
123125

124126
require (
125127
aead.dev/minisign v0.2.0 // indirect
126-
dario.cat/mergo v1.0.0 // indirect
128+
dario.cat/mergo v1.0.2 // indirect
127129
filippo.io/edwards25519 v1.1.0 // indirect
128130
git.mills.io/prologic/smtpd v0.0.0-20210710122116-a525b76c287a // indirect
129131
github.com/42wim/httpsig v1.2.2 // indirect
130132
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect
131133
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect
132-
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
134+
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
133135
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
134136
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
135137
github.com/Microsoft/go-winio v0.6.2 // indirect
@@ -185,18 +187,26 @@ require (
185187
github.com/cloudwego/base64x v0.1.5 // indirect
186188
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
187189
github.com/containerd/continuity v0.4.5 // indirect
190+
github.com/containerd/errdefs v1.0.0 // indirect
191+
github.com/containerd/errdefs/pkg v0.3.0 // indirect
192+
github.com/containerd/log v0.1.0 // indirect
193+
github.com/containerd/platforms v0.2.1 // indirect
194+
github.com/cpuguy83/dockercfg v0.3.2 // indirect
188195
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
189196
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
190197
github.com/davidmz/go-pageant v1.0.2 // indirect
191198
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
199+
github.com/distribution/reference v0.6.0 // indirect
192200
github.com/dlclark/regexp2 v1.11.5 // indirect
193201
github.com/docker/cli v27.4.1+incompatible // indirect
194-
github.com/docker/docker v28.0.0+incompatible // indirect
195-
github.com/docker/go-connections v0.5.0 // indirect
202+
github.com/docker/docker v28.3.3+incompatible // indirect
203+
github.com/docker/go-connections v0.6.0 // indirect
196204
github.com/dsnet/compress v0.0.2-0.20230904184137-39efe44ab707 // indirect
205+
github.com/ebitengine/purego v0.8.4 // indirect
197206
github.com/emirpasic/gods v1.18.1 // indirect
198207
github.com/fatih/color v1.18.0 // indirect
199208
github.com/felixge/fgprof v0.9.5 // indirect
209+
github.com/felixge/httpsnoop v1.0.4 // indirect
200210
github.com/free5gc/util v1.0.5-0.20230511064842-2e120956883b // indirect
201211
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
202212
github.com/gaissmai/bart v0.23.1 // indirect
@@ -207,13 +217,15 @@ require (
207217
github.com/go-fed/httpsig v1.1.0 // indirect
208218
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
209219
github.com/go-git/go-billy/v5 v5.6.2 // indirect
210-
github.com/go-ole/go-ole v1.2.6 // indirect
220+
github.com/go-logr/logr v1.4.3 // indirect
221+
github.com/go-logr/stdr v1.2.2 // indirect
222+
github.com/go-ole/go-ole v1.3.0 // indirect
211223
github.com/go-openapi/jsonpointer v0.21.0 // indirect
212224
github.com/go-openapi/swag v0.23.0 // indirect
213225
github.com/go-playground/locales v0.14.1 // indirect
214226
github.com/go-playground/universal-translator v0.18.1 // indirect
215227
github.com/go-sourcemap/sourcemap v2.1.4+incompatible // indirect
216-
github.com/go-viper/mapstructure/v2 v2.3.0 // indirect
228+
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
217229
github.com/gogo/protobuf v1.3.2 // indirect
218230
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
219231
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
@@ -255,8 +267,9 @@ require (
255267
github.com/logrusorgru/aurora/v4 v4.0.0 // indirect
256268
github.com/lor00x/goldap v0.0.0-20180618054307-a546dffdd1a3 // indirect
257269
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
258-
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
270+
github.com/lufia/plan9stats v0.0.0-20250821153705-5981dea3221d // indirect
259271
github.com/mackerelio/go-osstat v0.2.4 // indirect
272+
github.com/magiconair/properties v1.8.10 // indirect
260273
github.com/mailru/easyjson v0.7.7 // indirect
261274
github.com/mattn/go-colorable v0.1.14 // indirect
262275
github.com/mattn/go-isatty v0.0.20 // indirect
@@ -268,12 +281,17 @@ require (
268281
github.com/minio/selfupdate v0.6.1-0.20230907112617-f11e74f84ca7 // indirect
269282
github.com/mitchellh/go-homedir v1.1.0 // indirect
270283
github.com/moby/docker-image-spec v1.3.1 // indirect
271-
github.com/moby/sys/user v0.3.0 // indirect
272-
github.com/moby/term v0.5.0 // indirect
284+
github.com/moby/go-archive v0.1.0 // indirect
285+
github.com/moby/patternmatcher v0.6.0 // indirect
286+
github.com/moby/sys/sequential v0.6.0 // indirect
287+
github.com/moby/sys/user v0.4.0 // indirect
288+
github.com/moby/sys/userns v0.1.0 // indirect
289+
github.com/moby/term v0.5.2 // indirect
273290
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
274291
github.com/modern-go/reflect2 v1.0.2 // indirect
275292
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
276293
github.com/montanaflynn/stats v0.7.1 // indirect
294+
github.com/morikuni/aec v1.0.0 // indirect
277295
github.com/muesli/reflow v0.3.0 // indirect
278296
github.com/muesli/termenv v0.16.0 // indirect
279297
github.com/nwaples/rardecode/v2 v2.1.0 // indirect
@@ -282,7 +300,7 @@ require (
282300
github.com/olekukonko/errors v1.1.0 // indirect
283301
github.com/olekukonko/ll v0.0.9 // indirect
284302
github.com/opencontainers/go-digest v1.0.0 // indirect
285-
github.com/opencontainers/image-spec v1.1.0 // indirect
303+
github.com/opencontainers/image-spec v1.1.1 // indirect
286304
github.com/opencontainers/runc v1.2.3 // indirect
287305
github.com/openrdap/rdap v0.9.1 // indirect
288306
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
@@ -291,7 +309,7 @@ require (
291309
github.com/pjbgf/sha1cd v0.3.2 // indirect
292310
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
293311
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
294-
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
312+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
295313
github.com/projectdiscovery/asnmap v1.1.1 // indirect
296314
github.com/projectdiscovery/blackrock v0.0.1 // indirect
297315
github.com/projectdiscovery/cdncheck v1.1.27 // indirect
@@ -302,6 +320,7 @@ require (
302320
github.com/sashabaranov/go-openai v1.37.0 // indirect
303321
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
304322
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
323+
github.com/shirou/gopsutil/v4 v4.25.7 // indirect
305324
github.com/shoenig/go-m1cpu v0.1.6 // indirect
306325
github.com/sirupsen/logrus v1.9.3 // indirect
307326
github.com/skeema/knownhosts v1.3.1 // indirect
@@ -315,8 +334,8 @@ require (
315334
github.com/tidwall/rtred v0.1.2 // indirect
316335
github.com/tidwall/tinyqueue v0.1.1 // indirect
317336
github.com/tim-ywliu/nested-logrus-formatter v1.3.2 // indirect
318-
github.com/tklauser/go-sysconf v0.3.12 // indirect
319-
github.com/tklauser/numcpus v0.6.1 // indirect
337+
github.com/tklauser/go-sysconf v0.3.15 // indirect
338+
github.com/tklauser/numcpus v0.10.0 // indirect
320339
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
321340
github.com/ugorji/go/codec v1.2.11 // indirect
322341
github.com/ulikunitz/xz v0.5.12 // indirect
@@ -337,6 +356,11 @@ require (
337356
github.com/yuin/goldmark-emoji v1.0.5 // indirect
338357
github.com/zcalusic/sysinfo v1.0.2 // indirect
339358
github.com/zeebo/blake3 v0.2.3 // indirect
359+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
360+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 // indirect
361+
go.opentelemetry.io/otel v1.37.0 // indirect
362+
go.opentelemetry.io/otel/metric v1.37.0 // indirect
363+
go.opentelemetry.io/otel/trace v1.37.0 // indirect
340364
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
341365
golang.org/x/arch v0.3.0 // indirect
342366
golang.org/x/sync v0.16.0 // indirect
@@ -363,12 +387,12 @@ require (
363387
go.etcd.io/bbolt v1.3.10 // indirect
364388
go.uber.org/zap v1.25.0 // indirect
365389
goftp.io/server/v2 v2.0.1 // indirect
366-
golang.org/x/crypto v0.40.0 // indirect
390+
golang.org/x/crypto v0.41.0 // indirect
367391
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b
368-
golang.org/x/mod v0.25.0 // indirect
369-
golang.org/x/sys v0.34.0 // indirect
392+
golang.org/x/mod v0.26.0 // indirect
393+
golang.org/x/sys v0.35.0 // indirect
370394
golang.org/x/time v0.11.0 // indirect
371-
golang.org/x/tools v0.34.0
395+
golang.org/x/tools v0.35.0
372396
google.golang.org/protobuf v1.35.1 // indirect
373397
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
374398
gopkg.in/corvus-ch/zbase32.v1 v1.0.0 // indirect
@@ -382,3 +406,10 @@ require (
382406

383407
// https://go.dev/ref/mod#go-mod-file-retract
384408
retract v3.2.0 // retract due to broken js protocol issue
409+
410+
// Fix genproto version conflicts
411+
replace (
412+
google.golang.org/genproto => google.golang.org/genproto v0.0.0-20240814211410-ddb44dafa142
413+
google.golang.org/genproto/googleapis/api => google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
414+
google.golang.org/genproto/googleapis/rpc => google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1
415+
)

0 commit comments

Comments
 (0)