This project provides tools for extracting and merging image data from Dockerfiles, Docker Compose files, and Helm charts. The extracted image data can be saved to a file for further analysis or use.
The Containers Images Extractor helps in extracting container images from various configuration files used in container orchestration. This includes Dockerfiles, Docker Compose files, and Helm charts.
- Extract images from Dockerfiles, Docker Compose files, and Helm charts.
- Merge extracted images with existing image lists.
- Save image data to JSON files for further use.
To install this package, you need to have Go installed on your machine.
-
Clone the repository:
git clone https://github.com/Checkmarx/containers-images-extractor.git
-
Navigate to the project directory:
cd containers-images-extractor
-
Install dependencies:
go mod tidy
Here is an example of how to use the ImagesExtractor
:
package main
import (
"github.com/Checkmarx/containers-images-extractor/imagesExtractor"
"github.com/Checkmarx/containers-types/types"
"log"
)
func main() {
extractor := imagesExtractor.ImagesExtractor{}
scanPath := "/path/to/scan"
// Extract files
files, envVars, extractedPath, err := extractor.ExtractFiles(scanPath)
if err != nil {
log.Fatalf("Error extracting files: %v", err)
}
// Merge images
images, err := extractor.ExtractAndMergeImagesFromFiles(files, []types.ImageModel{}, envVars)
if err != nil {
log.Fatalf("Error merging images: %v", err)
}
// Save to file
err = extractor.SaveObjectToFile(extractedPath, images)
if err != nil {
log.Fatalf("Error saving images to file: %v", err)
}
}