kubernetes-sigs / bom

A utility to generate SPDX-compliant Bill of Materials manifests
https://kubernetes-sigs.github.io/bom/
Apache License 2.0
329 stars 48 forks source link

Path separator issue when pulling embedded license zip #460

Open ohxeighty opened 1 month ago

ohxeighty commented 1 month ago

What happened:

When trying to read embedded license data (embedded in the pkg\license\download.go file), the calls to fs.ReadFile fail on (presumably) Windows machines because filepath.join will join the path using backslashes which ReadFile doesn't seem to like ("The path separator is a forward slash even on Windows systems"). https://github.com/kubernetes-sigs/bom/blob/0952c9f51b97474062cec39d5399feb9d9778dd8/pkg/license/download.go#L196C1-L205C121

What you expected to happen:

The embedded license file being pulled and read. Changing the path separator to a forward slash when pulling the licenses.json and walking the details directory resolves this issue (works on my machine..)

How to reproduce it (as minimally and precisely as possible):

Running a bare minimal generate example on a Windows machine (e.g. go run main.go generate . or bom generate .)

Anything else we need to know?:

See https://github.com/golang/go/issues/45230? I have minimal go knowledge.

Environment:

puerco commented 1 month ago

Thanks for the report @ohxeighty I'll take a look!