Bump gosec version

This commit is contained in:
Mike Farah
2025-12-20 19:15:36 +11:00
parent 4a06cce376
commit 029ba68014
3 changed files with 28 additions and 1 deletions
+4
View File
@@ -122,6 +122,10 @@ func (te *tomlEncoder) encodeRootMapping(w io.Writer, node *CandidateNode) error
// encodeTopLevelEntry encodes a key/value at the root, dispatching to attribute, table, or array-of-tables
func (te *tomlEncoder) encodeTopLevelEntry(w io.Writer, path []string, node *CandidateNode) error {
if len(path) == 0 {
return fmt.Errorf("cannot encode TOML entry with empty path")
}
switch node.Kind {
case ScalarNode:
// key = value
+23
View File
@@ -2,6 +2,7 @@ package yqlib
import (
"bufio"
"bytes"
"fmt"
"strings"
"testing"
@@ -797,6 +798,28 @@ func TestTomlColorisationNumberBug(t *testing.T) {
}
}
// Tests that the encoder handles empty path slices gracefully
func TestTomlEmptyPathPanic(t *testing.T) {
encoder := NewTomlEncoder()
tomlEncoder := encoder.(*tomlEncoder)
var buf bytes.Buffer
// Create a simple scalar node
scalarNode := &CandidateNode{
Kind: ScalarNode,
Tag: "!!str",
Value: "test",
}
// Test with empty path - this should not panic
err := tomlEncoder.encodeTopLevelEntry(&buf, []string{}, scalarNode)
if err == nil {
t.Error("Expected error when encoding with empty path, got nil")
}
}
// TestTomlStringEscapeColourization tests that string colourization correctly
// handles escape sequences, particularly escaped quotes at the end of strings
func TestTomlStringEscapeColourization(t *testing.T) {