github.com/google/osv-scalibr@v0.4.1/detector/detector.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 detector provides the interface for security-related detection plugins. 16 package detector 17 18 import ( 19 "context" 20 21 scalibrfs "github.com/google/osv-scalibr/fs" 22 "github.com/google/osv-scalibr/inventory" 23 "github.com/google/osv-scalibr/packageindex" 24 "github.com/google/osv-scalibr/plugin" 25 ) 26 27 // Detector is the interface for a security detector plugin, used to scan for security findings 28 // such as vulnerabilities. 29 type Detector interface { 30 plugin.Plugin 31 // RequiredExtractors returns a list of Extractors that need to be enabled for this 32 // Detector to run. 33 RequiredExtractors() []string 34 // DetectedFinding returns generic information about the finding identified by the detector. 35 // Generic means the finding do not contain any information specific to the target or extras. 36 // E.g. no paths (locations), no IP addresses or any other information that could identify the 37 // target. 38 DetectedFinding() inventory.Finding 39 // Scan performs the security scan, considering scanRoot to be the root directory. 40 // Implementations may use PackageIndex to check if a relevant software package is installed and 41 // terminate early if it's not. 42 Scan(c context.Context, scanRoot *scalibrfs.ScanRoot, px *packageindex.PackageIndex) (inventory.Finding, error) 43 }