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

[POA-1908][POA-1912] Add warning message for experimental flags #46

Merged
merged 1 commit into from
Nov 8, 2024
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
18 changes: 18 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ func preRun(cmd *cobra.Command, args []string) {
telemetry.CommandLine(cmd.Name(), os.Args)

startProfiling(cmd, args)

printFlagsWarning()
}

func startProfiling(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -141,6 +143,22 @@ func stopProfiling(cmd *cobra.Command, args []string) {
}
}

func printFlagsWarning() {
testingFlags := make(map[string]string)

if testOnlyUseHTTPSFlag {
testingFlags["test_only_disable_https"] = "This is only for debugging and testing in local environment."
}

if liveProfileAddress != "" {
testingFlags["live-profile"] = "The profiler server can run on an unsecured HTTP port without authentication, which could expose sensitive process information to unauthorized users."
}

if len(testingFlags) > 0 {
util.PrintFlagsWarning(testingFlags)
}
}

func Execute() {
defer telemetry.Shutdown()

Expand Down
38 changes: 38 additions & 0 deletions util/printWarningMsg.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package util

import (
"fmt"

"github.com/postmanlabs/postman-insights-agent/printer"
)

const warningMessage = `
██ ██ █████ ██████ ███ ██ ██ ███ ██ ██████
██ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██ ██
██ █ ██ ███████ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ███
██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███ ███ ██ ██ ██ ██ ██ ████ ██ ██ ████ ██████

______ ______ ______ ______ ______ ______
/_____/ /_____/ /_____/ /_____/ /_____/ /_____/

YOU ARE USING UNDOCUMENTED FLAGS ONLY FOR DEBUGGING AND
TESTING. THESE FLAGS ARE NOT MEANT TO BY USED BY END USERS
UNLESS THEY ARE DIRECTED TO DO SO BY POSTMAN SUPPORT!!!
______ ______ ______ ______ ______ ______
/_____/ /_____/ /_____/ /_____/ /_____/ /_____/

See below for flags and their warning:`

func PrintFlagsWarning(warningFlags map[string]string) {
// Print banner
printer.Warningf("%s\n", warningMessage)

// Print flags and their warnings
for flag, warning := range warningFlags {
fmt.Printf("Flag: %s\tWarning: %s\n", flag, warning)
}

// Print new line
fmt.Printf("\n")
}