Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
Signed-off-by: Eliott Bouhana <eliott.bouhana@datadoghq.com>
  • Loading branch information
eliottness committed Aug 13, 2024
1 parent 4e7459c commit 7a9527d
Showing 1 changed file with 3 additions and 18 deletions.
21 changes: 3 additions & 18 deletions internal/appsec/waf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,21 +666,18 @@ func TestRASPLFI(t *testing.T) {
Operation: dyngo.NewOperation(parent),
}

dyngo.StartOperation(op, &ossec.OpenOperationArgs{
dyngo.StartOperation(op, ossec.OpenOperationArgs{
Path: path,
Flags: flags,
Perms: fs.FileMode(0),
})

var x any = file
defer dyngo.FinishOperation(op, &ossec.OpenOperationRes{
defer dyngo.FinishOperation(op, ossec.OpenOperationRes{
File: &x,
Err: &err,
})

// Open the file
file = &os.File{}

return
}

Expand All @@ -690,20 +687,8 @@ func TestRASPLFI(t *testing.T) {
path := r.URL.Query().Get("path")
block := r.URL.Query().Get("block")
if block == "true" {
// Make sure we don't scan writing operations
file, err := WrappedOpen(r.Context(), path, os.O_WRONLY)
require.NoError(t, err)
require.NotNil(t, file)

file, err = WrappedOpen(r.Context(), path, os.O_CREATE|os.O_RDWR)
require.NoError(t, err)
require.NotNil(t, file)

// Make sure we scan reading operations
file, err = WrappedOpen(r.Context(), path, os.O_RDONLY)
_, err := WrappedOpen(r.Context(), path, os.O_RDONLY)
require.ErrorIs(t, err, &events.BlockingSecurityEvent{})
require.Nil(t, file)

return
}

Expand Down

0 comments on commit 7a9527d

Please sign in to comment.