github.com/google/osv-scalibr@v0.4.1/extractor/filesystem/os/macapps/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 macapps 16 17 import ( 18 pb "github.com/google/osv-scalibr/binary/proto/scan_result_go_proto" 19 ) 20 21 // Metadata is the metadata struct for information parsed from the Info.plist file of a Mac App. 22 type Metadata struct { 23 CFBundleDisplayName string 24 CFBundleIdentifier string 25 CFBundleShortVersionString string 26 CFBundleExecutable string 27 CFBundleName string 28 CFBundlePackageType string 29 CFBundleSignature string 30 CFBundleVersion string 31 KSProductID string 32 KSUpdateURL string 33 } 34 35 // SetProto sets the MacAppsMetadata field in the Package proto. 36 func (m *Metadata) SetProto(p *pb.Package) { 37 if m == nil { 38 return 39 } 40 if p == nil { 41 return 42 } 43 44 p.Metadata = &pb.Package_MacAppsMetadata{ 45 MacAppsMetadata: &pb.MacAppsMetadata{ 46 BundleDisplayName: m.CFBundleDisplayName, 47 BundleIdentifier: m.CFBundleIdentifier, 48 BundleShortVersionString: m.CFBundleShortVersionString, 49 BundleExecutable: m.CFBundleExecutable, 50 BundleName: m.CFBundleName, 51 BundlePackageType: m.CFBundlePackageType, 52 BundleSignature: m.CFBundleSignature, 53 BundleVersion: m.CFBundleVersion, 54 ProductId: m.KSProductID, 55 UpdateUrl: m.KSUpdateURL, 56 }, 57 } 58 } 59 60 // ToStruct converts the MacAppsMetadata proto to a Metadata struct. 61 func ToStruct(m *pb.MacAppsMetadata) *Metadata { 62 if m == nil { 63 return nil 64 } 65 66 return &Metadata{ 67 CFBundleDisplayName: m.GetBundleDisplayName(), 68 CFBundleIdentifier: m.GetBundleIdentifier(), 69 CFBundleShortVersionString: m.GetBundleShortVersionString(), 70 CFBundleExecutable: m.GetBundleExecutable(), 71 CFBundleName: m.GetBundleName(), 72 CFBundlePackageType: m.GetBundlePackageType(), 73 CFBundleSignature: m.GetBundleSignature(), 74 CFBundleVersion: m.GetBundleVersion(), 75 KSProductID: m.GetProductId(), 76 KSUpdateURL: m.GetUpdateUrl(), 77 } 78 }