xray

package
v0.0.0-...-f12bd69 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name  = "xray"
	Usage = "Shows what's inside of your container image and reverse engineers its Dockerfile"
	Alias = "x"
)
View Source
const (
	FlagChanges                = "changes"
	FlagChangesOutput          = "changes-output"
	FlagLayer                  = "layer"
	FlagAddImageManifest       = "add-image-manifest"
	FlagAddImageConfig         = "add-image-config"
	FlagLayerChangesMax        = "layer-changes-max"
	FlagAllChangesMax          = "all-changes-max"
	FlagAddChangesMax          = "add-changes-max"
	FlagModifyChangesMax       = "modify-changes-max"
	FlagDeleteChangesMax       = "delete-changes-max"
	FlagChangePath             = "change-path"
	FlagChangeData             = "change-data"
	FlagChangeDataHash         = "change-data-hash"
	FlagReuseSavedImage        = "reuse-saved-image"
	FlagTopChangesMax          = "top-changes-max"
	FlagHashData               = "hash-data"
	FlagDetectUTF8             = "detect-utf8"
	FlagDetectDuplicates       = "detect-duplicates"
	FlagShowDuplicates         = "show-duplicates"
	FlagShowSpecialPerms       = "show-special-perms"
	FlagChangeMatchLayersOnly  = "change-match-layers-only"
	FlagExportAllDataArtifacts = "export-all-data-artifacts"
	FlagDetectAllCertFiles     = "detect-all-certs"
	FlagDetectAllCertPKFiles   = "detect-all-cert-pks"

	FlagDetectIdentities        = "detect-identities"
	FlagDetectIdentitiesParam   = "detect-identities-param"
	FlagDetectIdentitiesDumpRaw = "detect-identities-dump-raw"

	FlagDetectScheduledTasks        = "detect-scheduled-tasks"
	FlagDetectScheduledTasksParam   = "detect-scheduled-tasks-param"
	FlagDetectScheduledTasksDumpRaw = "detect-scheduled-tasks-dump-raw"

	FlagDetectServices        = "detect-services"
	FlagDetectServicesParam   = "detect-services-param"
	FlagDetectServicesDumpRaw = "detect-services-dump-raw"

	FlagDetectSystemHooks        = "detect-system-hooks"
	FlagDetectSystemHooksParam   = "detect-system-hooks-param"
	FlagDetectSystemHooksDumpRaw = "detect-system-hooks-dump-raw"
)

Xray command flag names

View Source
const (
	FlagChangesUsage                = "Show layer change details for the selected change type (values: none, all, delete, modify, add)"
	FlagChangesOutputUsage          = "Where to show the changes (values: all, report, console)"
	FlagLayerUsage                  = "Show details for the selected layer (using layer index or ID)"
	FlagAddImageManifestUsage       = "Add raw image manifest to the command execution report file"
	FlagAddImageConfigUsage         = "Add raw image config object to the command execution report file"
	FlagLayerChangesMaxUsage        = "Maximum number of changes to show for each layer"
	FlagAllChangesMaxUsage          = "Maximum number of changes to show for all layers"
	FlagAddChangesMaxUsage          = "Maximum number of 'add' changes to show for all layers"
	FlagModifyChangesMaxUsage       = "Maximum number of 'modify' changes to show for all layers"
	FlagDeleteChangesMaxUsage       = "Maximum number of 'delete' changes to show for all layers"
	FlagChangePathUsage             = "Include changes for the files that match the path pattern (Glob/Match in Go and **)"
	FlagChangeDataUsage             = "Include changes for the files that match the data pattern (regex)"
	FlagReuseSavedImageUsage        = "Reuse saved container image"
	FlagTopChangesMaxUsage          = "Maximum number of top changes to track"
	FlagChangeDataHashUsage         = "Include changes for the files that match the provided data hashes (sha1)"
	FlagHashDataUsage               = "Generate file data hashes"
	FlagDetectUTF8Usage             = "Detect utf8 files and optionally extract the discovered utf8 file content"
	FlagDetectDuplicatesUsage       = "Detect duplicate files based on their hashes"
	FlagShowDuplicatesUsage         = "Show discovered duplicate file paths"
	FlagShowSpecialPermsUsage       = "Show files with special permissions (setuid,setgid,sticky)"
	FlagChangeMatchLayersOnlyUsage  = "Show only layers with change matches"
	FlagExportAllDataArtifactsUsage = "" /* 142-byte string literal not displayed */
	FlagDetectAllCertFilesUsage     = "Detect all certifcate files"
	FlagDetectAllCertPKFilesUsage   = "Detect all certifcate private key files"

	FlagDetectIdentitiesUsage        = "Detect system identities (users, groups) and their properties"
	FlagDetectIdentitiesParamUsage   = "Input parameters for system identities detection"
	FlagDetectIdentitiesDumpRawUsage = "" /* 188-byte string literal not displayed */

	FlagDetectScheduledTasksUsage        = "Detect scheduled tasks and their properties"
	FlagDetectScheduledTasksParamUsage   = "Input parameters for scheduled tasks detection"
	FlagDetectScheduledTasksDumpRawUsage = "" /* 195-byte string literal not displayed */

	FlagDetectServicesUsage        = "Detect services and their properties"
	FlagDetectServicesParamUsage   = "Input parameters for services detection"
	FlagDetectServicesDumpRawUsage = "" /* 177-byte string literal not displayed */

	FlagDetectSystemHooksUsage        = "Detect system hooks and their properties"
	FlagDetectSystemHooksParamUsage   = "Input parameters for system hooks detection"
	FlagDetectSystemHooksDumpRawUsage = "" /* 185-byte string literal not displayed */
)

Xray command flag usage info

Variables

View Source
var CLI = &cli.Command{
	Name:    Name,
	Aliases: []string{Alias},
	Usage:   Usage,
	Flags:   XRayFlags,
	Action: func(ctx *cli.Context) error {
		gcvalues, ok := command.CLIContextGet(ctx.Context, command.GlobalParams).(*command.GenericParams)
		if !ok || gcvalues == nil {
			return command.ErrNoGlobalParams
		}

		xc := app.NewExecutionContext(
			Name,
			gcvalues.QuietCLIMode,
			gcvalues.OutputFormat)

		if ctx.String(command.FlagCommandParamsFile) != "" {
			command.ParseParamsFromFile(ctx, xc, ctx.String(command.FlagCommandParamsFile), XRayFlags)
		}

		targetRef := ctx.String(command.FlagTarget)
		if targetRef == "" {
			if ctx.Args().Len() < 1 {
				xc.Out.Error("param.target", "missing image ID/name")
				cli.ShowCommandHelp(ctx, Name)
				return nil
			} else {
				targetRef = ctx.Args().First()
			}
		}

		detectIdentities, err := getDetectOpParam(ctx,
			FlagDetectIdentities,
			FlagDetectIdentitiesParam,
			FlagDetectIdentitiesDumpRaw,
			detectIdentitiesDumpRawDefault,
			detectIdentitiesOpParamKeys)
		if err != nil {
			xc.Out.Error("param.detect_identities", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		detectScheduledTasks, err := getDetectOpParam(ctx,
			FlagDetectScheduledTasks,
			FlagDetectScheduledTasksParam,
			FlagDetectScheduledTasksDumpRaw,
			detectScheduledTasksDumpRawDefault,
			detectScheduledTasksOpParamKeys)
		if err != nil {
			xc.Out.Error("param.detect_scheduled_tasks", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		detectServices, err := getDetectOpParam(ctx,
			FlagDetectServices,
			FlagDetectServicesParam,
			FlagDetectServicesDumpRaw,
			detectServicesDumpRawDefault,
			detectServicesOpParamKeys)
		if err != nil {
			xc.Out.Error("param.detect_services", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		detectSystemHooks, err := getDetectOpParam(ctx,
			FlagDetectSystemHooks,
			FlagDetectSystemHooksParam,
			FlagDetectSystemHooksDumpRaw,
			detectSystemHooksDumpRawDefault,
			detectSystemHooksOpParamKeys)
		if err != nil {
			xc.Out.Error("param.detect_system_hooks", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		cparams := &CommandParams{
			Runtime:              ctx.String(command.FlagRuntime),
			DetectAllCertFiles:   ctx.Bool(FlagDetectAllCertFiles),
			DetectAllCertPKFiles: ctx.Bool(FlagDetectAllCertPKFiles),
			DetectIdentities:     detectIdentities,
			DetectScheduledTasks: detectScheduledTasks,
			DetectServices:       detectServices,
			DetectSystemHooks:    detectSystemHooks,
		}

		xdArtifactsPath := ctx.String(FlagExportAllDataArtifacts)

		doPull := ctx.Bool(command.FlagPull)
		dockerConfigPath := ctx.String(command.FlagDockerConfigPath)
		registryAccount := ctx.String(command.FlagRegistryAccount)
		registrySecret := ctx.String(command.FlagRegistrySecret)
		doShowPullLogs := ctx.Bool(command.FlagShowPullLogs)

		changes, err := parseChangeTypes(ctx.StringSlice(FlagChanges))
		if err != nil {
			xc.Out.Error("param.error.change.types", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		if xdArtifactsPath != "" {

			changes["delete"] = struct{}{}
			changes["modify"] = struct{}{}
			changes["add"] = struct{}{}
		}

		rawChangesOutputs := ctx.StringSlice(FlagChangesOutput)
		if xdArtifactsPath != "" && len(rawChangesOutputs) == 0 {
			rawChangesOutputs = append(rawChangesOutputs, "report")
		}

		changesOutputs, err := parseChangeOutputTypes(rawChangesOutputs)
		if err != nil {
			xc.Out.Error("param.error.change.output", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		if xdArtifactsPath != "" {
			changesOutputs["report"] = struct{}{}
		}

		layers, err := command.ParseTokenSet(ctx.StringSlice(FlagLayer))
		if err != nil {
			xc.Out.Error("param.error.layer", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		layerChangesMax := ctx.Int(FlagLayerChangesMax)
		allChangesMax := ctx.Int(FlagAllChangesMax)
		addChangesMax := ctx.Int(FlagAddChangesMax)
		modifyChangesMax := ctx.Int(FlagModifyChangesMax)
		deleteChangesMax := ctx.Int(FlagDeleteChangesMax)
		topChangesMax := ctx.Int(FlagTopChangesMax)

		changePathMatchers, err := parseChangePathMatchers(ctx.StringSlice(FlagChangePath))
		if err != nil {
			xc.Out.Error("param.error.change.path", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		changeDataMatchers, err := parseChangeDataMatchers(ctx.StringSlice(FlagChangeData))
		if err != nil {
			xc.Out.Error("param.error.change.data", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		doAddImageManifest := ctx.Bool(FlagAddImageManifest)
		if xdArtifactsPath != "" {
			doAddImageManifest = true
		}

		doAddImageConfig := ctx.Bool(FlagAddImageConfig)
		if xdArtifactsPath != "" {
			doAddImageConfig = true
		}

		doRmFileArtifacts := ctx.Bool(command.FlagRemoveFileArtifacts)
		doReuseSavedImage := ctx.Bool(FlagReuseSavedImage)

		doHashData := ctx.Bool(FlagHashData)
		if xdArtifactsPath != "" {
			doHashData = true
		}

		doDetectDuplicates := ctx.Bool(FlagDetectDuplicates)
		if doDetectDuplicates {
			doHashData = true
		}

		rawDetectUTF8 := ctx.String(FlagDetectUTF8)
		if xdArtifactsPath != "" && rawDetectUTF8 == "" {
			rawDetectUTF8 = "dump:utf8.tgz::10000000"
		}

		utf8Detector, err := parseDetectUTF8(rawDetectUTF8)
		if err != nil {
			xc.Out.Error("param.error.detect.utf8", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		if utf8Detector != nil && !doHashData {
			xc.Out.Error("param.error.detect.utf8", "--detect-utf8 requires option --hash-data")
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		doShowDuplicates := ctx.Bool(FlagShowDuplicates)
		doShowSpecialPerms := ctx.Bool(FlagShowSpecialPerms)

		changeDataHashMatchers, err := parseChangeDataHashMatchers(ctx.StringSlice(FlagChangeDataHash))
		if err != nil {
			xc.Out.Error("param.error.change.data.hash", err.Error())
			xc.Out.State("exited",
				ovars{
					"exit.code": -1,
				})
			xc.Exit(-1)
		}

		changeMatchLayersOnly := ctx.Bool(FlagChangeMatchLayersOnly)

		OnCommand(
			xc,
			gcvalues,
			cparams,
			targetRef,
			doPull,
			dockerConfigPath,
			registryAccount,
			registrySecret,
			doShowPullLogs,
			changes,
			changesOutputs,
			layers,
			layerChangesMax,
			allChangesMax,
			addChangesMax,
			modifyChangesMax,
			deleteChangesMax,
			topChangesMax,
			changePathMatchers,
			changeDataMatchers,
			changeDataHashMatchers,
			doHashData,
			doDetectDuplicates,
			doShowDuplicates,
			doShowSpecialPerms,
			changeMatchLayersOnly,
			doAddImageManifest,
			doAddImageConfig,
			doReuseSavedImage,
			doRmFileArtifacts,
			utf8Detector,
			xdArtifactsPath,
		)

		return nil
	},
}
View Source
var CommandFlagSuggestions = &command.FlagSuggestions{
	Names: []prompt.Suggest{
		{Text: command.FullFlagName(command.FlagRuntime), Description: command.FlagRuntimeUsage},
		{Text: command.FullFlagName(command.FlagCommandParamsFile), Description: command.FlagCommandParamsFileUsage},
		{Text: command.FullFlagName(command.FlagTarget), Description: command.FlagTargetUsage},
		{Text: command.FullFlagName(command.FlagPull), Description: command.FlagPullUsage},
		{Text: command.FullFlagName(command.FlagShowPullLogs), Description: command.FlagShowPullLogsUsage},
		{Text: command.FullFlagName(command.FlagRegistryAccount), Description: command.FlagRegistryAccountUsage},
		{Text: command.FullFlagName(command.FlagRegistrySecret), Description: command.FlagRegistrySecretUsage},
		{Text: command.FullFlagName(command.FlagDockerConfigPath), Description: command.FlagDockerConfigPathUsage},
		{Text: command.FullFlagName(FlagChanges), Description: FlagChangesUsage},
		{Text: command.FullFlagName(FlagChangesOutput), Description: FlagChangesOutputUsage},
		{Text: command.FullFlagName(FlagLayer), Description: FlagLayerUsage},
		{Text: command.FullFlagName(FlagAddImageManifest), Description: FlagAddImageManifestUsage},
		{Text: command.FullFlagName(FlagAddImageConfig), Description: FlagAddImageConfigUsage},
		{Text: command.FullFlagName(FlagLayerChangesMax), Description: FlagLayerChangesMaxUsage},
		{Text: command.FullFlagName(FlagAllChangesMax), Description: FlagAllChangesMaxUsage},
		{Text: command.FullFlagName(FlagAddChangesMax), Description: FlagAddChangesMaxUsage},
		{Text: command.FullFlagName(FlagModifyChangesMax), Description: FlagModifyChangesMaxUsage},
		{Text: command.FullFlagName(FlagDeleteChangesMax), Description: FlagDeleteChangesMaxUsage},
		{Text: command.FullFlagName(FlagChangePath), Description: FlagChangePathUsage},
		{Text: command.FullFlagName(FlagChangeData), Description: FlagChangeDataUsage},
		{Text: command.FullFlagName(FlagReuseSavedImage), Description: FlagReuseSavedImageUsage},
		{Text: command.FullFlagName(FlagHashData), Description: FlagHashDataUsage},
		{Text: command.FullFlagName(FlagDetectUTF8), Description: FlagDetectUTF8Usage},
		{Text: command.FullFlagName(FlagDetectDuplicates), Description: FlagDetectDuplicatesUsage},
		{Text: command.FullFlagName(FlagShowDuplicates), Description: FlagShowDuplicatesUsage},
		{Text: command.FullFlagName(FlagShowSpecialPerms), Description: FlagShowSpecialPermsUsage},
		{Text: command.FullFlagName(FlagChangeDataHash), Description: FlagChangeDataHashUsage},
		{Text: command.FullFlagName(FlagTopChangesMax), Description: FlagTopChangesMaxUsage},
		{Text: command.FullFlagName(FlagDetectAllCertFiles), Description: FlagDetectAllCertFilesUsage},
		{Text: command.FullFlagName(FlagDetectAllCertPKFiles), Description: FlagDetectAllCertPKFilesUsage},
		{Text: command.FullFlagName(FlagDetectIdentities), Description: FlagDetectIdentitiesUsage},
		{Text: command.FullFlagName(FlagDetectIdentitiesParam), Description: FlagDetectIdentitiesParamUsage},
		{Text: command.FullFlagName(FlagDetectIdentitiesDumpRaw), Description: FlagDetectIdentitiesDumpRawUsage},
		{Text: command.FullFlagName(FlagExportAllDataArtifacts), Description: FlagExportAllDataArtifactsUsage},
		{Text: command.FullFlagName(command.FlagRemoveFileArtifacts), Description: command.FlagRemoveFileArtifactsUsage},
	},
	Values: map[string]command.CompleteValue{
		command.FullFlagName(command.FlagRuntime):             command.CompleteRuntime,
		command.FullFlagName(command.FlagCommandParamsFile):   command.CompleteFile,
		command.FullFlagName(command.FlagPull):                command.CompleteTBool,
		command.FullFlagName(command.FlagShowPullLogs):        command.CompleteBool,
		command.FullFlagName(command.FlagDockerConfigPath):    command.CompleteFile,
		command.FullFlagName(command.FlagTarget):              completeTarget,
		command.FullFlagName(FlagChanges):                     completeLayerChanges,
		command.FullFlagName(FlagChangesOutput):               completeOutputs,
		command.FullFlagName(FlagAddImageManifest):            command.CompleteBool,
		command.FullFlagName(FlagAddImageConfig):              command.CompleteBool,
		command.FullFlagName(FlagHashData):                    command.CompleteBool,
		command.FullFlagName(FlagDetectDuplicates):            command.CompleteBool,
		command.FullFlagName(FlagShowDuplicates):              command.CompleteTBool,
		command.FullFlagName(FlagShowSpecialPerms):            command.CompleteTBool,
		command.FullFlagName(FlagReuseSavedImage):             command.CompleteTBool,
		command.FullFlagName(FlagDetectAllCertFiles):          command.CompleteBool,
		command.FullFlagName(FlagDetectAllCertPKFiles):        command.CompleteBool,
		command.FullFlagName(FlagDetectIdentities):            command.CompleteTBool,
		command.FullFlagName(command.FlagRemoveFileArtifacts): command.CompleteBool,
	},
}
View Source
var CommandSuggestion = prompt.Suggest{
	Text:        Name,
	Description: Usage,
}
View Source
var Flags = map[string]cli.Flag{
	FlagChanges: &cli.StringSliceFlag{
		Name:    FlagChanges,
		Value:   cli.NewStringSlice(""),
		Usage:   FlagChangesUsage,
		EnvVars: []string{"DSLIM_CHANGES"},
	},
	FlagChangesOutput: &cli.StringSliceFlag{
		Name:    FlagChangesOutput,
		Value:   cli.NewStringSlice("all"),
		Usage:   FlagChangesOutputUsage,
		EnvVars: []string{"DSLIM_CHANGES_OUTPUT"},
	},
	FlagLayer: &cli.StringSliceFlag{
		Name:    FlagLayer,
		Value:   cli.NewStringSlice(),
		Usage:   FlagLayerUsage,
		EnvVars: []string{"DSLIM_LAYER"},
	},
	FlagAddImageManifest: &cli.BoolFlag{
		Name:    FlagAddImageManifest,
		Usage:   FlagAddImageManifestUsage,
		EnvVars: []string{"DSLIM_XRAY_IMAGE_MANIFEST"},
	},
	FlagAddImageConfig: &cli.BoolFlag{
		Name:    FlagAddImageConfig,
		Usage:   FlagAddImageConfigUsage,
		EnvVars: []string{"DSLIM_XRAY_IMAGE_CONFIG"},
	},
	FlagLayerChangesMax: &cli.IntFlag{
		Name:    FlagLayerChangesMax,
		Value:   -1,
		Usage:   FlagLayerChangesMaxUsage,
		EnvVars: []string{"DSLIM_XRAY_LAYER_CHANGES_MAX"},
	},
	FlagAllChangesMax: &cli.IntFlag{
		Name:    FlagAllChangesMax,
		Value:   -1,
		Usage:   FlagAllChangesMaxUsage,
		EnvVars: []string{"DSLIM_XRAY_ALL_CHANGES_MAX"},
	},
	FlagAddChangesMax: &cli.IntFlag{
		Name:    FlagAddChangesMax,
		Value:   -1,
		Usage:   FlagAddChangesMaxUsage,
		EnvVars: []string{"DSLIM_XRAY_ADD_CHANGES_MAX"},
	},
	FlagModifyChangesMax: &cli.IntFlag{
		Name:    FlagModifyChangesMax,
		Value:   -1,
		Usage:   FlagModifyChangesMaxUsage,
		EnvVars: []string{"DSLIM_XRAY_MODIFY_CHANGES_MAX"},
	},
	FlagDeleteChangesMax: &cli.IntFlag{
		Name:    FlagDeleteChangesMax,
		Value:   -1,
		Usage:   FlagDeleteChangesMaxUsage,
		EnvVars: []string{"DSLIM_XRAY_DELETE_CHANGES_MAX"},
	},
	FlagChangePath: &cli.StringSliceFlag{
		Name:    FlagChangePath,
		Value:   cli.NewStringSlice(),
		Usage:   FlagChangePathUsage,
		EnvVars: []string{"DSLIM_XRAY_CHANGE_PATH"},
	},
	FlagChangeData: &cli.StringSliceFlag{
		Name:    FlagChangeData,
		Value:   cli.NewStringSlice(),
		Usage:   FlagChangeDataUsage,
		EnvVars: []string{"DSLIM_XRAY_CHANGE_DATA"},
	},
	FlagReuseSavedImage: &cli.BoolFlag{
		Name:    FlagReuseSavedImage,
		Value:   true,
		Usage:   FlagReuseSavedImageUsage,
		EnvVars: []string{"DSLIM_XRAY_REUSE_SAVED"},
	},
	FlagTopChangesMax: &cli.IntFlag{
		Name:    FlagTopChangesMax,
		Value:   20,
		Usage:   FlagTopChangesMaxUsage,
		EnvVars: []string{"DSLIM_XRAY_TOP_CHANGES_MAX"},
	},
	FlagHashData: &cli.BoolFlag{
		Name:    FlagHashData,
		Usage:   FlagHashDataUsage,
		EnvVars: []string{"DSLIM_XRAY_HASH_DATA"},
	},
	FlagDetectUTF8: &cli.StringFlag{
		Name:    FlagDetectUTF8,
		Usage:   FlagDetectUTF8Usage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_UTF8"},
	},
	FlagDetectDuplicates: &cli.BoolFlag{
		Name:    FlagDetectDuplicates,
		Value:   true,
		Usage:   FlagDetectDuplicatesUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_DUP"},
	},
	FlagShowDuplicates: &cli.BoolFlag{
		Name:    FlagShowDuplicates,
		Usage:   FlagShowDuplicatesUsage,
		EnvVars: []string{"DSLIM_XRAY_SHOW_DUP"},
	},
	FlagShowSpecialPerms: &cli.BoolFlag{
		Name:    FlagShowSpecialPerms,
		Value:   true,
		Usage:   FlagShowSpecialPermsUsage,
		EnvVars: []string{"DSLIM_XRAY_SHOW_SPECIAL"},
	},
	FlagChangeDataHash: &cli.StringSliceFlag{
		Name:    FlagChangeDataHash,
		Value:   cli.NewStringSlice(),
		Usage:   FlagChangeDataHashUsage,
		EnvVars: []string{"DSLIM_XRAY_CHANGE_DATA_HASH"},
	},
	FlagChangeMatchLayersOnly: &cli.BoolFlag{
		Name:    FlagChangeMatchLayersOnly,
		Usage:   FlagChangeMatchLayersOnlyUsage,
		EnvVars: []string{"DSLIM_XRAY_CHANGE_MATCH_LAYERS_ONLY"},
	},
	FlagExportAllDataArtifacts: &cli.StringFlag{
		Name:    FlagExportAllDataArtifacts,
		Usage:   FlagExportAllDataArtifactsUsage,
		EnvVars: []string{"DSLIM_XRAY_EXPORT_ALL_DARTIFACTS"},
	},
	FlagDetectAllCertFiles: &cli.BoolFlag{
		Name:    FlagDetectAllCertFiles,
		Usage:   FlagDetectAllCertFilesUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_ALL_CERTS"},
	},
	FlagDetectAllCertPKFiles: &cli.BoolFlag{
		Name:    FlagDetectAllCertPKFiles,
		Usage:   FlagDetectAllCertPKFilesUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_ALL_CERT_PKS"},
	},

	FlagDetectIdentities: &cli.BoolFlag{
		Name:    FlagDetectIdentities,
		Value:   true,
		Usage:   FlagDetectIdentitiesUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_IDENTITIES"},
	},
	FlagDetectIdentitiesParam: &cli.StringSliceFlag{
		Name:    FlagDetectIdentitiesParam,
		Value:   cli.NewStringSlice(),
		Usage:   FlagDetectIdentitiesParamUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_IDENTITIES_PARAM"},
	},
	FlagDetectIdentitiesDumpRaw: &cli.StringFlag{
		Name:    FlagDetectIdentitiesDumpRaw,
		Usage:   FlagDetectIdentitiesDumpRawUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_IDENTITIES_DUMP_RAW"},
	},

	FlagDetectScheduledTasks: &cli.BoolFlag{
		Name:    FlagDetectScheduledTasks,
		Value:   true,
		Usage:   FlagDetectScheduledTasksUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SCHEDULED_TASKS"},
	},
	FlagDetectScheduledTasksParam: &cli.StringSliceFlag{
		Name:    FlagDetectScheduledTasksParam,
		Value:   cli.NewStringSlice(),
		Usage:   FlagDetectScheduledTasksParamUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SCHEDULED_TASKS_PARAM"},
	},
	FlagDetectScheduledTasksDumpRaw: &cli.StringFlag{
		Name:    FlagDetectScheduledTasksDumpRaw,
		Usage:   FlagDetectScheduledTasksDumpRawUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SCHEDULED_TASKS_DUMP_RAW"},
	},

	FlagDetectServices: &cli.BoolFlag{
		Name:    FlagDetectServices,
		Value:   true,
		Usage:   FlagDetectServicesUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SERVICES"},
	},
	FlagDetectServicesParam: &cli.StringSliceFlag{
		Name:    FlagDetectServicesParam,
		Value:   cli.NewStringSlice(),
		Usage:   FlagDetectServicesParamUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SERVICES_PARAM"},
	},
	FlagDetectServicesDumpRaw: &cli.StringFlag{
		Name:    FlagDetectServicesDumpRaw,
		Usage:   FlagDetectServicesDumpRawUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SERVICES_DUMP_RAW"},
	},

	FlagDetectSystemHooks: &cli.BoolFlag{
		Name:    FlagDetectSystemHooks,
		Value:   true,
		Usage:   FlagDetectSystemHooksUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SYSTEM_HOOKS"},
	},
	FlagDetectSystemHooksParam: &cli.StringSliceFlag{
		Name:    FlagDetectSystemHooksParam,
		Value:   cli.NewStringSlice(),
		Usage:   FlagDetectSystemHooksParamUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SYSTEM_HOOKS_PARAM"},
	},
	FlagDetectSystemHooksDumpRaw: &cli.StringFlag{
		Name:    FlagDetectSystemHooksDumpRaw,
		Usage:   FlagDetectSystemHooksDumpRawUsage,
		EnvVars: []string{"DSLIM_XRAY_DETECT_SYSTEM_HOOKS_DUMP_RAW"},
	},
}

Functions

func OnCommand

func OnCommand(
	xc *app.ExecutionContext,
	gparams *command.GenericParams,
	cparams *CommandParams,
	targetRef string,
	doPull bool,
	dockerConfigPath string,
	registryAccount string,
	registrySecret string,
	doShowPullLogs bool,
	changes map[string]struct{},
	changesOutputs map[string]struct{},
	layers map[string]struct{},
	layerChangesMax int,
	allChangesMax int,
	addChangesMax int,
	modifyChangesMax int,
	deleteChangesMax int,
	topChangesMax int,
	changePathMatchers []*dockerimage.ChangePathMatcher,
	changeDataMatcherList []*dockerimage.ChangeDataMatcher,
	changeDataHashMatcherList []*dockerimage.ChangeDataHashMatcher,
	doHashData bool,
	doDetectDuplicates bool,
	doShowDuplicates bool,
	doShowSpecialPerms bool,
	changeMatchLayersOnly bool,
	doAddImageManifest bool,
	doAddImageConfig bool,
	doReuseSavedImage bool,
	doRmFileArtifacts bool,
	utf8Detector *dockerimage.UTF8Detector,
	xdArtifactsPath string,
)

OnCommand implements the 'xray' command

func RegisterCommand

func RegisterCommand()

Types

type CommandParams

type CommandParams struct {
	DetectIdentities     *DetectOpParam `json:"detect_identities,omitempty"`
	DetectScheduledTasks *DetectOpParam `json:"detect_scheduled_tasks,omitempty"`
	DetectServices       *DetectOpParam `json:"detect_services,omitempty"`
	DetectSystemHooks    *DetectOpParam `json:"detect_system_hooks,omitempty"`

	//todo: migrate simple bool param to DetectOpParam
	DetectAllCertFiles   bool   `json:"detect_all_cert_files,omitempty"`
	DetectAllCertPKFiles bool   `json:"detect_all_cert_pks,omitempty"`
	Runtime              string `json:"runtime,omitempty"`
}

type DetectOpParam

type DetectOpParam struct {
	/// Operation is enabled
	Enabled bool
	/// Dump/save raw data
	DumpRaw bool
	/// Dump raw data to console
	IsConsoleOut bool
	/// Dump raw data to directory (otherwise save to an archive file)
	IsDirOut bool
	/// Output path (directory or archive path)
	OutputPath string
	/// Input parameters for the operation
	InputParams map[string]string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL