-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix crash on empty array.flat with missing type info
This can unfortunately still happen, where the type info is missing and we essentially get the array indication in the type field, but nothing else. The subsequent for loop then crashes it. Add testing for this use-case and fix the crash by forcing the any-type into it. Signed-off-by: Dominik Richter <[email protected]>
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 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
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,23 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
package llx | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.mondoo.com/cnquery/v10/types" | ||
) | ||
|
||
func TestArrayFlat(t *testing.T) { | ||
t.Run("empty array with missing type info", func(t *testing.T) { | ||
res, ref, err := arrayFlat(nil, &RawData{ | ||
Type: types.ArrayLike, | ||
Value: []any{}, | ||
}, nil, 0) | ||
require.NoError(t, err) | ||
require.Equal(t, uint64(0), ref) | ||
require.Equal(t, ArrayData(nil, types.Any), res) | ||
}) | ||
} |