<commit_before>package main

import (
	"fmt"
	"log"
	"os"

	cli "github.com/jawher/mow.cli"
	"github.com/mbndr/logo"
)

var (
	whitelist = vulnerabilitiesWhitelist{}
	logger    *logo.Logger
)

func main() {
	app := cli.App("clair-scanner", "Scan local Docker images for vulnerabilities with Clair")

	var (
		whitelistFile = app.StringOpt("w whitelist", "", "Path to the whitelist file")
		clair         = app.StringOpt("c clair", "http://127.0.0.1:6060", "Clair URL")
		ip            = app.StringOpt("ip", "localhost", "IP address where clair-scanner is running on")
		logFile       = app.StringOpt("l log", "", "Log to a file")
		reportFile    = app.StringOpt("r report", "", "Report output file, as JSON")
		imageName     = app.StringArg("IMAGE", "", "Name of the Docker image to scan")
	)

	app.Before = func() {
		initializeLogger(*logFile)
		if *whitelistFile != "" {
			whitelist = parseWhitelistFile(*whitelistFile)
		}
	}

	app.Action = func() {
		logger.Info("Start clair-scanner")

		go listenForSignal(func(s os.Signal) {
			log.Fatalf("Application interrupted [%v]", s)
		})

		scan(scannerConfig{*imageName, whitelist, *clair, *ip, *reportFile})
	}
	app.Run(os.Args)
}

func initializeLogger(logFile string) {
	cliRec := logo.NewReceiver(os.Stderr, "")
	cliRec.Color = true

	if logFile != "" {
		file, err := logo.Open(logFile)
		if err != nil {
			fmt.Printf("Could not initialize logging file %v", err)
			os.Exit(1)
		}

		fileRec := logo.NewReceiver(file, "")
		logger = logo.NewLogger(cliRec, fileRec)
	} else {
		logger = logo.NewLogger(cliRec)
	}
}<commit_msg>Exit code is 1 when there is a vulnerability<commit_after>package main

import (
	"fmt"
	"log"
	"os"

	cli "github.com/jawher/mow.cli"
	"github.com/mbndr/logo"
)

var (
	whitelist = vulnerabilitiesWhitelist{}
	logger    *logo.Logger
)

func main() {
	app := cli.App("clair-scanner", "Scan local Docker images for vulnerabilities with Clair")

	var (
		whitelistFile = app.StringOpt("w whitelist", "", "Path to the whitelist file")
		clair         = app.StringOpt("c clair", "http://127.0.0.1:6060", "Clair URL")
		ip            = app.StringOpt("ip", "localhost", "IP address where clair-scanner is running on")
		logFile       = app.StringOpt("l log", "", "Log to a file")
		reportFile    = app.StringOpt("r report", "", "Report output file, as JSON")
		imageName     = app.StringArg("IMAGE", "", "Name of the Docker image to scan")
	)

	app.Before = func() {
		initializeLogger(*logFile)
		if *whitelistFile != "" {
			whitelist = parseWhitelistFile(*whitelistFile)
		}
	}

	app.Action = func() {
		logger.Info("Start clair-scanner")

		go listenForSignal(func(s os.Signal) {
			log.Fatalf("Application interrupted [%v]", s)
		})

		result := scan(scannerConfig{*imageName, whitelist, *clair, *ip, *reportFile})
		if len(result) > 0 {
			os.Exit(1)
		}
	}
	app.Run(os.Args)
}

func initializeLogger(logFile string) {
	cliRec := logo.NewReceiver(os.Stderr, "")
	cliRec.Color = true

	if logFile != "" {
		file, err := logo.Open(logFile)
		if err != nil {
			fmt.Printf("Could not initialize logging file %v", err)
			os.Exit(1)
		}

		fileRec := logo.NewReceiver(file, "")
		logger = logo.NewLogger(cliRec, fileRec)
	} else {
		logger = logo.NewLogger(cliRec)
	}
}
{'fraction_non_alphanumeric': 0.15773259396179914, 'fraction_numerical': 0.007701786814540973, 'mean_word_length': 3.638571428571429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3963975', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1154, 'n_words': 273}