Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tagvalue parser incorrectly complains about DocumentComment #182

Closed
justinabrahms opened this issue Jan 17, 2023 · 7 comments
Closed

tagvalue parser incorrectly complains about DocumentComment #182

justinabrahms opened this issue Jan 17, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@justinabrahms
Copy link

Hello.

When parsing a tagvalue file, I incorrectly get the error received unknown tag DocumentComment in CreationInfo section. I've ensured the file passes validation at https://tools.spdx.org/app/validate/.

File listed here: eBay/sbom-scorecard#22 (comment)

Test case:

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"

	spdx_tv "github.com/spdx/tools-golang/tvloader"
)

func main() {
	f, err := ioutil.ReadFile("/Users/jabrahms/Downloads/photon.spdxtv.txt")
	if err != nil {
		print("error opening SPDX document: %w", err)
		return
	}

	doc22, err := spdx_tv.Load2_2(bytes.NewReader(f))
	if err == nil && doc22 != nil {
		print("Found 2.2 tv document")
	} else {
		fmt.Println("Error: ", err)
	}
}
@neilnaveen
Copy link
Contributor

@lumjjb I do not see tvloader package in main. It was their in the release v0.4.0, but now it is gone, how do you want to handle this?

@justinabrahms
Copy link
Author

@neilnaveen I'm happy if you just fix what's in main.

package main

import (
	"bytes"
	"fmt"
	"io/ioutil"

	spdx_tv "github.com/spdx/tools-golang/tagvalue"
)

func main() {
	f, err := ioutil.ReadFile("/Users/jabrahms/Downloads/photon.spdxtv.txt")
	if err != nil {
		print("error opening SPDX document: %w", err)
		return
	}

	doc22, err := spdx_tv.Read(bytes.NewReader(f))
	if err == nil && doc22 != nil {
		print("Found 2.2 tv document")
	} else {
		fmt.Println("Error: ", err)
	}
}

and

$ go run main.go
Error:  received unknown tag DocumentComment in CreationInfo section

@neilnaveen
Copy link
Contributor

Not in your code, but the main branch of spdx.

@justinabrahms
Copy link
Author

@neilnaveen Totally. I (I think...?) updated the code to reflect the test case with what's in main.

@lumjjb
Copy link
Collaborator

lumjjb commented Jan 26, 2023

@justinabrahms does the PR #185 from @neilnaveen fix this for you?

@justinabrahms
Copy link
Author

@lumjjb It does;

go run main.go                                                          
Found 2.2 tv document% 

@lumjjb
Copy link
Collaborator

lumjjb commented Feb 16, 2023

awesome closing this issue. Thanks @neilnaveen @justinabrahms

@lumjjb lumjjb closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants