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

Allow configurable interactive modes #1785

Closed
wlynch opened this issue Apr 21, 2022 · 0 comments · Fixed by #1827
Closed

Allow configurable interactive modes #1785

wlynch opened this issue Apr 21, 2022 · 0 comments · Fixed by #1827
Labels
enhancement New feature or request

Comments

@wlynch
Copy link
Member

wlynch commented Apr 21, 2022

Description

When toying around with calling cosign from other tools, I noticed that cosign can hang when it's invoked with keyless enabled.

e.g. if you do something like

func main() {
        os.Setenv("COSIGN_EXPERIMENTAL", "1")
        out, err := exec.Command("cosign", "sign-blob", "a.txt").CombinedOutput()
        fmt.Println(string(out), err)
}

IIUC, this happens because of how cosign detects interactive-ness for commands -

var flow string
switch {
case idToken != "":
flow = FlowToken
case !term.IsTerminal(0):
fmt.Fprintln(os.Stderr, "Non-interactive mode detected, using device flow.")
flow = FlowDevice
default:
flow = FlowNormal
}

i.e. there is no ID token present and there's no terminal, so prompt for device flow, but stderr/stdout won't print until the command has completed so the command hangs waiting for the input that will never come. If the flow is forcibly set to FlowNormal, the regular browser based flow would still work and the command can complete.

For this particular case, the answer would be to use Stdout/StderrPipe to plumb through the message during execution or just call the cosign funcs directly, but I originally encountered this when trying to invoke cosign through Git plugins (#865 (comment)) where this won't be possible without an upstream change to git itself.

As a workaround, I'd like to make interactive flow mode configurable to allow callers to select the flow they want. This way for tools that can't pipe stdout/stderr can still have an option to send users through a normal interactive flow if they choose (else fall back to the existing behavior).

Also open to other ideas if you have them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant