github.com/google/osv-scalibr@v0.4.1/stats/types.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 stats 16 17 import ( 18 "time" 19 20 "github.com/google/osv-scalibr/inventory" 21 ) 22 23 // AfterExtractorStats is a struct containing stats about the results of a file extraction run. 24 type AfterExtractorStats struct { 25 Path string 26 Root string 27 Runtime time.Duration 28 29 Inventory *inventory.Inventory 30 Error error 31 } 32 33 // FileRequiredStats is a struct containing stats about a file that was 34 // required or skipped by a plugin. 35 type FileRequiredStats struct { 36 Path string 37 Result FileRequiredResult 38 FileSizeBytes int64 39 } 40 41 // FileRequiredResult is a string representation of the result of a call to 42 // `Extractor.FileRequired`. 43 type FileRequiredResult string 44 45 const ( 46 // FileRequiredResultOK indicates that the file was required by the plugin. 47 FileRequiredResultOK FileRequiredResult = "FILE_REQUIRED_RESULT_OK" 48 49 // FileRequiredResultSizeLimitExceeded indicates that the file was skipped 50 // because it was too large. 51 FileRequiredResultSizeLimitExceeded FileRequiredResult = "FILE_REQUIRED_RESULT_SIZE_LIMIT_EXCEEDED" 52 ) 53 54 // FileExtractedStats is a struct containing stats about a file that was extracted. If 55 // the file was skipped due to an error during extraction, `Error` will be 56 // populated. 57 type FileExtractedStats struct { 58 Path string 59 Result FileExtractedResult 60 FileSizeBytes int64 61 62 // Optional. For extractors that unarchive a compressed files, this reports 63 // the bytes that were opened during the unarchiving process. 64 UncompressedBytes int64 65 } 66 67 // FileExtractedResult is a string representation of the result of a call to 68 // `Extractor.Extract`. 69 type FileExtractedResult string 70 71 const ( 72 // FileExtractedResultSuccess indicates that the file was extracted 73 // successfully. 74 FileExtractedResultSuccess FileExtractedResult = "FILE_EXTRACTED_RESULT_SUCCESS" 75 76 // FileExtractedResultErrorUnknown indicates that an unknown error occurred 77 // during extraction. 78 FileExtractedResultErrorUnknown FileExtractedResult = "FILE_EXTRACTED_RESULT_ERROR_UNKNOWN" 79 80 // FileExtractedResultErrorMemoryLimitExceeded indicates that the extraction 81 // failed because the memory limit inside the plugin was exceeded. 82 FileExtractedResultErrorMemoryLimitExceeded = "FILE_EXTRACTED_RESULT_ERROR_MEMORY_LIMIT_EXCEEDED" 83 )