github.com/google/osv-scalibr@v0.4.1/extractor/filesystem/language/python/wheelegg/metadata.go (about) 1 // Copyright 2025 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package wheelegg 16 17 import ( 18 pb "github.com/google/osv-scalibr/binary/proto/scan_result_go_proto" 19 ) 20 21 // PythonPackageMetadata holds parsing information from a python egg or wheel package. 22 type PythonPackageMetadata struct { 23 Author string `json:"author"` 24 AuthorEmail string `json:"authorEmail"` 25 } 26 27 // SetProto sets the PythonMetadata field in the Package proto. 28 func (m *PythonPackageMetadata) SetProto(p *pb.Package) { 29 if m == nil { 30 return 31 } 32 if p == nil { 33 return 34 } 35 36 p.Metadata = &pb.Package_PythonMetadata{ 37 PythonMetadata: &pb.PythonPackageMetadata{ 38 Author: m.Author, 39 AuthorEmail: m.AuthorEmail, 40 }, 41 } 42 } 43 44 // ToStruct converts the PythonPackageMetadata proto to a Metadata struct. 45 func ToStruct(m *pb.PythonPackageMetadata) *PythonPackageMetadata { 46 if m == nil { 47 return nil 48 } 49 50 return &PythonPackageMetadata{ 51 Author: m.GetAuthor(), 52 AuthorEmail: m.GetAuthorEmail(), 53 } 54 }