diff --git a/README.md b/README.md index b5ae355c..caeef4c1 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Auditors can also be run individually. | :---- | :----------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | | | --format | The output format to use (one of "pretty", "logrus", "json") (default is "pretty") | | -c | --kubeconfig | Path to local Kubernetes config file. Only used in local mode (default is `$HOME/.kube/config`) | -| -f | --manifest | Path to the yaml configuration to audit. Only used in manifest mode. | +| -f | --manifest | Path to the yaml configuration to audit. Only used in manifest mode. You may use `-` to read from stdin. | | -n | --namespace | Only audit resources in the specified namespace. Not currently supported in manifest mode. | | -g | --includegenerated | Include generated resources in scan (such as Pods generated by deployments). If you would like kubeaudit to produce results for generated resources (for example if you have custom resources or want to catch orphaned resources where the owner resource no longer exists) you can use this flag. | | -m | --minseverity | Set the lowest severity level to report (one of "error", "warning", "info") (default "info") | diff --git a/cmd/commands/root.go b/cmd/commands/root.go index 6054809d..99e3e107 100644 --- a/cmd/commands/root.go +++ b/cmd/commands/root.go @@ -17,12 +17,12 @@ import ( var rootConfig rootFlags type rootFlags struct { - format string - kubeConfig string - manifest string - namespace string - minSeverity string - exitCode int + format string + kubeConfig string + manifest string + namespace string + minSeverity string + exitCode int includeGenerated bool } @@ -91,11 +91,19 @@ func getReport(auditors ...kubeaudit.Auditable) *kubeaudit.Report { auditor := initKubeaudit(auditors...) if rootConfig.manifest != "" { - manifest, err := os.Open(rootConfig.manifest) - if err != nil { - log.WithError(err).Fatal("Error opening manifest file") + var f *os.File + if rootConfig.manifest == "-" { + f = os.Stdin + } else { + manifest, err := os.Open(rootConfig.manifest) + if err != nil { + log.WithError(err).Fatal("Error opening manifest file") + } + + f = manifest } - report, err := auditor.AuditManifest(manifest) + + report, err := auditor.AuditManifest(f) if err != nil { log.WithError(err).Fatal("Error auditing manifest") }