github.com/google/osv-scalibr@v0.4.1/extractor/containerimage.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 extractor
    16  
    17  import "github.com/opencontainers/go-digest"
    18  
    19  // ContainerImageMetadata stores metadata about a container image.
    20  type ContainerImageMetadata struct {
    21  	// Index of the container image in the full inventory.
    22  	Index int
    23  	// OSInfo is the key value map from /etc/os-release.
    24  	OSInfo map[string]string
    25  	// LayerMetadata stores metadata about the layers in the container image.
    26  	// Currently this does not store any empty layers.
    27  	LayerMetadata []*LayerMetadata
    28  	// BaseImages stores metadata about the base images that the container image is based on.
    29  	// The first element is always empty.
    30  	BaseImages [][]*BaseImageDetails
    31  }
    32  
    33  // LayerMetadata stores metadata about a layer in a container image.
    34  type LayerMetadata struct {
    35  	ParentContainer *ContainerImageMetadata
    36  
    37  	// Index of the layer in the ParentContainer image.
    38  	Index   int
    39  	DiffID  digest.Digest
    40  	ChainID digest.Digest
    41  	Command string
    42  	IsEmpty bool
    43  	// Index of the base image match in the ParentContainer image. 0 means no match.
    44  	BaseImageIndex int
    45  }
    46  
    47  // BaseImageDetails stores details about a base image.
    48  type BaseImageDetails struct {
    49  	// Repository is the name of the image. (e.g. `debian`, `circleci/node`)
    50  	Repository string
    51  	// Registry is the name of the registry. (e.g. `docker.io`, `ghcr.io`)
    52  	Registry string
    53  	// Plugin name of the plugin used to extract the base image.
    54  	Plugin string
    55  	// ChainID used to query this layer. This is calculated including empty layers, so will not correspond
    56  	// to the ChainID of any layer in the inventory.
    57  	ChainID digest.Digest
    58  }