-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support: URR related IEs * ignore session report msg in PeekNextResponse() * print log msg when received session report related msg * upgrade to golang 1.18 & go-pfcp v0.0.19 * update urr related handlers * support to handle sessionReport * add fuzz package * support ie fuzzing * update Fuzzing Test * ignore HeartbeatRequest * fix ci linter error * package rename * add license/copyright header * update makefile * Fix lint issue * fix gosec G404 & update behavior of test target in Makefile * update go.mod * fix ci-lint error in fuzz test * update README * fix ci linter error * fix: support loopback interface * Update .gitignore * fix: update typo and add args for fuzz test * doc: update README * Apply suggestions from code review --------- Co-authored-by: gab-arrobo <[email protected]> Co-authored-by: CTFang@WireLab <[email protected]>
- Loading branch information
1 parent
528d74b
commit 2f3579b
Showing
18 changed files
with
1,363 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright 2022-present Open Networking Foundation | ||
|
||
.fuzz/test_data | ||
.idea/ | ||
.coverage/ | ||
output | ||
*.pyc | ||
*.swp | ||
*.log | ||
client | ||
server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// Copyright 2024-present Ian Chen <[email protected]> | ||
|
||
package fuzz | ||
|
||
import ( | ||
"crypto/rand" | ||
"flag" | ||
"math/big" | ||
"testing" | ||
"time" | ||
|
||
"github.com/omec-project/pfcpsim/internal/pfcpsim/export" | ||
"github.com/omec-project/pfcpsim/pkg/pfcpsim/session" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
MaxUint = ^uint(0) | ||
MaxInt = int(MaxUint >> 1) | ||
) | ||
|
||
func getRand(n int) int { | ||
res, err := rand.Int(rand.Reader, big.NewInt(int64(n))) | ||
if err != nil { | ||
return n | ||
} | ||
|
||
return int(res.Int64()) | ||
} | ||
|
||
var ( | ||
iface = flag.String("iface", "eth0", "the interface name you used to establish the connection with UPF.") | ||
upfN3 = flag.String("upfN3", "192.168.0.5", "the N3 interface address of the UPF") | ||
upfN4 = flag.String("upfN4", "127.0.0.8", "the N4 interface address of the UPF") | ||
) | ||
|
||
func Fuzz(f *testing.F) { | ||
var testcases []uint | ||
for i := 0; i < 100; i++ { | ||
testcases = append(testcases, uint(getRand(MaxInt))) | ||
} | ||
|
||
for _, tc := range testcases { | ||
f.Add(tc) | ||
} | ||
|
||
session.SetCheck(false) | ||
|
||
f.Fuzz(func(t *testing.T, input uint) { | ||
time.Sleep(5 * time.Second) | ||
|
||
sim := export.NewPfcpSimCfg(*iface, *upfN3, *upfN4) | ||
|
||
err := sim.InitPFCPSim() | ||
if err != nil { | ||
require.NoError(t, err, "InitPFCPSim failed") | ||
} | ||
|
||
err = sim.Associate() | ||
if err != nil { | ||
require.NoError(t, err, "Associate failed") | ||
} | ||
|
||
defer func() { | ||
err = sim.TerminatePFCPSim() | ||
require.NoError(t, err) | ||
}() | ||
|
||
err = sim.CreateSession(2, getRand(session.PdrMax), | ||
int(input)%session.QerMax, | ||
int(input)%session.FarMax, | ||
int(input)%session.UrrMax, | ||
input) | ||
if err != nil { | ||
require.NoError(t, err, "CreateSession failed") | ||
} | ||
|
||
err = sim.ModifySession(2, | ||
getRand(session.FarMax), | ||
getRand(session.UrrMax), | ||
input) | ||
if err != nil { | ||
require.NoError(t, err, "ModifySession failed") | ||
} | ||
|
||
time.Sleep(3 * time.Second) | ||
|
||
err = sim.DeleteSession(2) | ||
if err != nil { | ||
require.NoError(t, err, "DeleteSession failed") | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.