Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/piprate/json-gold v0.7.0
github.com/pmezard/go-difflib v1.0.0
github.com/spdx/gordf v0.0.0-20201111095634-7098f93598fb
github.com/stretchr/testify v1.11.1
mvdan.cc/gofumpt v0.7.0
Expand All @@ -26,6 +25,7 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deiu/gon3 v0.0.0-20241212124032-93153c038193 // indirect
github.com/linkeddata/gojsonld v0.0.0-20170418210642-4f5db6791326 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
github.com/rychipman/easylex v0.0.0-20160129204217-49ee7767142f // indirect
golang.org/x/mod v0.14.0 // indirect
Expand Down
22 changes: 22 additions & 0 deletions spdx/v3/internal/ld/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ld
import (
"fmt"
"reflect"
"strings"
)

var StopTraversing = fmt.Errorf("stop-traversing-graph")
Expand Down Expand Up @@ -33,6 +34,22 @@ func visitObjectGraph(visited map[reflect.Value]struct{}, path []any, v reflect.
} else if err != nil {
return err
}
} else {
t := v.Type()
if t.Size() == 0 || isPrimitive(t) {
// expected for fields like ld.Type, we should not reference zero-sized fields
return nil
}
if t.Kind() == reflect.Pointer || t.Kind() == reflect.Interface {
t = t.Elem()
}
p := t.PkgPath()
if p != "" && !strings.Contains(p, ".") {
return nil // stdlib packages
}

// for debugging: panic(fmt.Errorf("can't interface: %v %#v", typeName(t), v))
return nil
}

t := v.Type()
Expand Down Expand Up @@ -78,7 +95,12 @@ func visitObjectGraph(visited map[reflect.Value]struct{}, path []any, v reflect.
return err
}
}
case reflect.String, reflect.Bool,
reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
reflect.Float32, reflect.Float64:
default:
// for debugging: panic(fmt.Errorf("unexpected type: %v %#v", typeName(t), v))
}
return nil
}
Loading