( invocation workflow.InvocationContext, _ []workflow.Data, )
| 69 | } |
| 70 | |
| 71 | func legacycliWorkflow( |
| 72 | invocation workflow.InvocationContext, |
| 73 | _ []workflow.Data, |
| 74 | ) (output []workflow.Data, err error) { |
| 75 | output = []workflow.Data{} |
| 76 | var outBuffer bytes.Buffer |
| 77 | var outWriter *bufio.Writer |
| 78 | |
| 79 | config := invocation.GetConfiguration() |
| 80 | debugLogger := invocation.GetEnhancedLogger() // uses zerolog |
| 81 | debugLoggerDefault := invocation.GetLogger() // uses log |
| 82 | ri := invocation.GetRuntimeInfo() |
| 83 | |
| 84 | staticNodeJsBinaryBool, parseErr := strconv.ParseBool(constants.StaticNodeJsBinary) |
| 85 | if parseErr != nil { |
| 86 | debugLogger.Print("Failed to parse staticNodeJsBinary:", parseErr) |
| 87 | } |
| 88 | |
| 89 | err = ValidateGlibcVersion(debugLogger, utils.DefaultGlibcVersion(), runtime.GOOS, runtime.GOARCH, staticNodeJsBinaryBool) |
| 90 | if err != nil { |
| 91 | return output, err |
| 92 | } |
| 93 | |
| 94 | args := config.GetStringSlice(configuration.RAW_CMD_ARGS) |
| 95 | useStdIo := config.GetBool(configuration.WORKFLOW_USE_STDIO) |
| 96 | workingDirectory := config.GetString(configuration.WORKING_DIRECTORY) |
| 97 | analyticsDisabled := config.GetBool(configuration.ANALYTICS_DISABLED) |
| 98 | |
| 99 | debugLogger.Print("Use StdIO:", useStdIo) |
| 100 | debugLogger.Print("Working directory:", workingDirectory) |
| 101 | |
| 102 | // init cli object |
| 103 | var cli *cliv2.CLI |
| 104 | cli, err = cliv2.NewCLIv2(config, debugLoggerDefault, ri) |
| 105 | if err != nil { |
| 106 | return output, err |
| 107 | } |
| 108 | |
| 109 | cli.WorkingDirectory = workingDirectory |
| 110 | |
| 111 | // ensure to disable analytics based on configuration |
| 112 | if _, exists := os.LookupEnv(constants.SNYK_ANALYTICS_DISABLED_ENV); !exists && analyticsDisabled { |
| 113 | env := []string{constants.SNYK_ANALYTICS_DISABLED_ENV + "=1"} |
| 114 | cli.AppendEnvironmentVariables(env) |
| 115 | } |
| 116 | |
| 117 | // In general all authentication if handled through the Extensible CLI now. But there is some legacy logic |
| 118 | // that checks for an API token to be available. Until this logic is safely removed, we will be injecting a |
| 119 | // fake/random API token to bypass this logic. |
| 120 | apiToken := config.GetString(configuration.AUTHENTICATION_TOKEN) |
| 121 | if len(apiToken) == 0 { |
| 122 | apiToken = "random" |
| 123 | } |
| 124 | cli.AppendEnvironmentVariables([]string{constants.SNYK_API_TOKEN_ENV + "=" + apiToken, "DEBUG_HIDE_DATE=true"}) |
| 125 | |
| 126 | err = cli.Init() |
| 127 | if err != nil { |
| 128 | return output, err |
nothing calls this directly
no test coverage detected