github.com/platform-engineering-labs/formae/pkg/auth v0.2.2-0.20260720143758-7c563cebd76d
Legitimate Go auth plugin client code
Contains an unbounded block loopimports net/rpc
SHA-25693fdf618fc65f7a9f2c37f9933d9114e2bac36738f858c60d05a3a9bad4520d5
MaleculeH₂(CmPo₂)
Evidence
⋯6 lines
9 "fmt"
10 "io"
11 "net/rpc"
12 "os/exec"
13 "time"
⋯7 lines
28:22… Path string, config json.RawMessage) (*Client, error) {
29 cmd := exec.Command(binaryPath)
30 cmd.Stderr = nil // let plugin stderr go to parent stderr
31 setSysProcAttr(cmd)
32
33 stdin, err := cmd.StdinPipe()
34 if err != nil {
35 return nil, fmt.Errorf("auth client: stdin pipe: %w", err)
36 }
37
38 stdout, err := cmd.StdoutPipe()
39 if err != nil {
40 return nil, fmt.Errorf("auth client: stdout pipe: %w", err)
⋯4 lines
50:16… yte
51 if _, err := io.ReadFull(stdout, ready[:]); err != nil {
52 cmd.Process.Kill()
53 cmd.Wait()
54 return nil, fmt.Errorf("auth client: waiting for ready signal: %w", err)
⋯4 lines
14:52… ods without a real binary.
15func newTestClient(t *testing.T, plugin AuthPlugin) *Client {
16 t.Helper()
17
⋯7 lines
⋯5 lines
6
7import (
8 "io"
9 "net/rpc"
10 "os"
11 "time"
12)
13
14// Serve runs the auth plugin RPC server over the given connection.
15// Plugin authors call this from main() with os.Stdin/os.Stdout.
16// The function blocks until the connection is closed.
17func Serve(plugin AuthPlugin, conn io.ReadWriteCloser) {
⋯4 lines
22
23// ReadySignal is the single byte written to stdout by Run before starting
24// the RPC server. The host process uses this to detect that the plugin is
25// alive and ready to accept RPC calls.
26const ReadySignal byte = 0x01
27
28// Run is a convenience function for plugin authors. It creates a stdioConn
29// from os.Stdin/os.Stdout and calls Serve. Before entering the RPC loop it
30// writes a single ready-signal byte so the host can detect readiness without
⋯6 lines
37 // Signal readiness before creating the stdioConn so the marker byte
38 // is separate from the RPC stream.
39 os.Stdout.Write([]byte{ReadySignal})
40 os.Stdout.Sync()
41
42 // Monitor parent process — exit if reparented (parent died).
43 go monitorParent()
44
45 conn := &stdioConn{
46 Reader: stdinReader(),
47 WriteCloser: stdoutWriteCloser(),
48 }
No evidence locations were recorded for this file. Raw result