| // Copyright 2021 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| "github.com/go-git/go-git/v5/plumbing/object" |
| "golang.org/x/vuln/srv/internal/cveschema" |
| "golang.org/x/vuln/srv/internal/derrors" |
| // ReadCVEAtPath reads file at path in commit, and JSON-decodes it into a CVE. |
| func ReadCVEAtPath(commit *object.Commit, path string) (_ *cveschema.CVE, blobHash string, err error) { |
| defer derrors.Wrap(&err, "readCVEAtPath(%q)", path) |
| file, err := commit.File(path) |
| if err := json.NewDecoder(r).Decode(&cve); err != nil { |
| return &cve, file.Hash.String(), nil |