Skip to content

Commit 2f4e044

Browse files
committed
Fix a gosec lint
Gosec correctly-ish identified a place where we were taking a reference to an iteration variable, however, it was explicitly handled below, so note that it's fine.
1 parent f8684f4 commit 2f4e044

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/crd/schema_visitor.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ type SchemaVisitor interface {
2727
// this visitor will be called again with `nil` to indicate that
2828
// all children have been visited. If a nil visitor is returned,
2929
// children are not visited.
30+
//
31+
// It is *NOT* safe to save references to the given schema.
32+
// Make deepcopies if you need to keep things around beyond
33+
// the lifetime of the call.
3034
Visit(schema *apiext.JSONSchemaProps) SchemaVisitor
3135
}
3236

@@ -102,6 +106,8 @@ func (w schemaWalker) walkSchema(schema *apiext.JSONSchemaProps) {
102106
// walkMap walks over values of the given map, saving changes to them.
103107
func (w schemaWalker) walkMap(defs map[string]apiext.JSONSchemaProps) {
104108
for name, def := range defs {
109+
// this is iter var reference is because we immediately preseve it below
110+
//nolint:gosec
105111
w.walkSchema(&def)
106112
// make sure the edits actually go through since we can't
107113
// take a reference to the value in the map

0 commit comments

Comments
 (0)