github.com/google/osv-scalibr@v0.4.1/extractor/filesystem/language/erlang/mixlock/mixlock.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 mixlock extracts erlang mix.lock files. 16 package mixlock 17 18 import ( 19 "context" 20 "path/filepath" 21 22 "github.com/google/osv-scalibr/extractor/filesystem" 23 "github.com/google/osv-scalibr/extractor/filesystem/language/erlang/mixlock/mixlockutils" 24 "github.com/google/osv-scalibr/inventory" 25 "github.com/google/osv-scalibr/plugin" 26 ) 27 28 const ( 29 // Name is the unique name of this extractor. 30 Name = "erlang/mixlock" 31 ) 32 33 // Extractor extracts erlang mix.lock files. 34 type Extractor struct{} 35 36 // New returns a new instance of this Extractor. 37 func New() filesystem.Extractor { return &Extractor{} } 38 39 // Name of the extractor 40 func (e Extractor) Name() string { return Name } 41 42 // Version of the extractor 43 func (e Extractor) Version() int { return 0 } 44 45 // Requirements of the extractor 46 func (e Extractor) Requirements() *plugin.Capabilities { 47 return &plugin.Capabilities{} 48 } 49 50 // FileRequired returns true if the specified file is a mix.lock file. 51 func (e Extractor) FileRequired(api filesystem.FileAPI) bool { 52 return filepath.Base(api.Path()) == "mix.lock" 53 } 54 55 // Extract extracts packages from Erlang mix.lock files passed through the scan input. 56 func (e Extractor) Extract(ctx context.Context, input *filesystem.ScanInput) (inventory.Inventory, error) { 57 // Parse the Mix.lock file using mixlockutils 58 return mixlockutils.ParseMixLockFile(input) 59 } 60 61 var _ filesystem.Extractor = Extractor{}