Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new flag --skip-audit and skip profile cmd from audit by default #15872

Merged
merged 3 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/minikube/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func init() {
RootCmd.PersistentFlags().StringP(config.ProfileName, "p", constants.DefaultClusterName, `The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently.`)
RootCmd.PersistentFlags().StringP(configCmd.Bootstrapper, "b", "kubeadm", "The name of the cluster bootstrapper that will set up the Kubernetes cluster.")
RootCmd.PersistentFlags().String(config.UserFlag, "", "Specifies the user executing the operation. Useful for auditing operations executed by 3rd party tools. Defaults to the operating system username.")
RootCmd.PersistentFlags().Bool(config.SkipAuditFlag, false, "Skip recording the current command in the audit logs.")
RootCmd.PersistentFlags().Bool(config.Rootless, false, "Force to use rootless driver (docker and podman driver only)")

groups := templates.CommandGroups{
Expand Down Expand Up @@ -327,6 +328,7 @@ func setupViper() {
viper.SetDefault(config.WantNoneDriverWarning, true)
viper.SetDefault(config.WantVirtualBoxDriverWarning, true)
viper.SetDefault(config.MaxAuditEntries, 1000)
viper.SetDefault(config.SkipAuditFlag, false)
}

func addToPath(dir string) {
Expand Down
6 changes: 5 additions & 1 deletion pkg/minikube/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ func getStartIndex(entryCount int) int {

// shouldLog returns if the command should be logged.
func shouldLog() bool {
if viper.GetBool(config.SkipAuditFlag) {
return false
}

// in rare chance we get here without a command, don't log
if pflag.NArg() == 0 {
return false
Expand All @@ -141,7 +145,7 @@ func shouldLog() bool {
}

// commands that should not be logged.
no := []string{"status", "version", "logs", "generate-docs"}
no := []string{"status", "version", "logs", "generate-docs", "profile"}
a := pflag.Arg(0)
for _, c := range no {
if a == c {
Expand Down
2 changes: 2 additions & 0 deletions pkg/minikube/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const (
ProfileName = "profile"
// UserFlag is the key for the global user flag (ex. --user=user1)
UserFlag = "user"
// SkipAuditFlag is the key for skipping command from aduit
SkipAuditFlag = "skip-audit"
// Rootless is the key for the global rootless parameter (boolean)
Rootless = "rootless"
// AddonImages stores custom addon images config
Expand Down
8 changes: 8 additions & 0 deletions site/content/en/docs/commands/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ minikube addons SUBCOMMAND [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -67,6 +68,7 @@ minikube addons configure ADDON_NAME [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -102,6 +104,7 @@ minikube addons disable ADDON_NAME [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -152,6 +155,7 @@ minikube addons enable dashboard
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -188,6 +192,7 @@ minikube addons help [command] [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -229,6 +234,7 @@ minikube addons images ingress
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -271,6 +277,7 @@ minikube addons list [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -316,6 +323,7 @@ minikube addons open ADDON_NAME [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down
6 changes: 6 additions & 0 deletions site/content/en/docs/commands/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Add an image into minikube as a local cache, or delete, reload the cached images
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -69,6 +70,7 @@ minikube cache add [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -104,6 +106,7 @@ minikube cache delete [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -140,6 +143,7 @@ minikube cache help [command] [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -182,6 +186,7 @@ minikube cache list [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down Expand Up @@ -217,6 +222,7 @@ minikube cache reload [flags]
--one_output If true, only write logs to their native severity level (vs also writing to each lower severity level; no effect when -logtostderr=true)
-p, --profile string The name of the minikube VM being used. This can be set to allow having multiple instances of minikube independently. (default "minikube")
--rootless Force to use rootless driver (docker and podman driver only)
--skip-audit Skip recording the current command in the audit logs.
--skip_headers If true, avoid header prefixes in the log messages
--skip_log_headers If true, avoid headers when opening log files (no effect when -logtostderr=true)
--stderrthreshold severity logs at or above this threshold go to stderr when writing to files and stderr (no effect when -logtostderr=true or -alsologtostderr=false) (default 2)
Expand Down
Loading