Fix linting issues (#595)
* fix lint * Bump golangci-lint action to v8 and update linting args * fix lint errors * fix: correct loop condition in main function to process remaining arguments
This commit is contained in:
parent
22ad31b127
commit
2c2d378f86
10 changed files with 17 additions and 17 deletions
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
|
|
@ -33,9 +33,9 @@ jobs:
|
||||||
run: go test -v -race -cover -tags full ./...
|
run: go test -v -race -cover -tags full ./...
|
||||||
|
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v6
|
uses: golangci/golangci-lint-action@v8
|
||||||
with:
|
with:
|
||||||
args: --timeout=60m -E gofmt --verbose --print-resources-usage --build-tags full
|
args: --timeout=60m --verbose --print-resources-usage --build-tags full -D errcheck
|
||||||
env:
|
env:
|
||||||
GOGC: "10"
|
GOGC: "10"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,8 @@ func newAsciicastLogger(recorddir string, prefix string) *asciicastLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *asciicastLogger) uphook(msg []byte) error {
|
func (l *asciicastLogger) uphook(msg []byte) error {
|
||||||
if msg[0] == msgChannelData {
|
switch msg[0] {
|
||||||
|
case msgChannelData:
|
||||||
clientChannelID := binary.BigEndian.Uint32(msg[1:5])
|
clientChannelID := binary.BigEndian.Uint32(msg[1:5])
|
||||||
|
|
||||||
f, ok := l.channels[clientChannelID]
|
f, ok := l.channels[clientChannelID]
|
||||||
|
|
@ -74,7 +75,7 @@ func (l *asciicastLogger) uphook(msg []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if msg[0] == msgChannelOpenConfirm {
|
case msgChannelOpenConfirm:
|
||||||
clientChannelID := binary.BigEndian.Uint32(msg[1:5])
|
clientChannelID := binary.BigEndian.Uint32(msg[1:5])
|
||||||
serverChannelID := binary.BigEndian.Uint32(msg[5:9])
|
serverChannelID := binary.BigEndian.Uint32(msg[5:9])
|
||||||
l.channelIDMap[serverChannelID] = clientChannelID
|
l.channelIDMap[serverChannelID] = clientChannelID
|
||||||
|
|
|
||||||
|
|
@ -244,7 +244,9 @@ func (d *daemon) run() error {
|
||||||
log.Errorf("cannot create screen recording dir %v: %v", recorddir, err)
|
log.Errorf("cannot create screen recording dir %v: %v", recorddir, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if d.recordfmt == "asciicast" {
|
|
||||||
|
switch d.recordfmt {
|
||||||
|
case "asciicast":
|
||||||
prefix := ""
|
prefix := ""
|
||||||
if d.usernameAsRecorddir {
|
if d.usernameAsRecorddir {
|
||||||
// add prefix to avoid conflict
|
// add prefix to avoid conflict
|
||||||
|
|
@ -255,7 +257,7 @@ func (d *daemon) run() error {
|
||||||
|
|
||||||
uphookchain.append(ssh.InspectPacketHook(recorder.uphook))
|
uphookchain.append(ssh.InspectPacketHook(recorder.uphook))
|
||||||
downhookchain.append(ssh.InspectPacketHook(recorder.downhook))
|
downhookchain.append(ssh.InspectPacketHook(recorder.downhook))
|
||||||
} else if d.recordfmt == "typescript" {
|
case "typescript":
|
||||||
recorder, err := newFilePtyLogger(recorddir)
|
recorder, err := newFilePtyLogger(recorddir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("cannot create screen recording logger: %v", err)
|
log.Errorf("cannot create screen recording logger: %v", err)
|
||||||
|
|
|
||||||
|
|
@ -346,7 +346,7 @@ func (g *GrpcPlugin) createUpstream(conn ssh.ConnMetadata, challengeCtx ssh.Chal
|
||||||
|
|
||||||
caCertificate, ok := caPublicKey.(*ssh.Certificate)
|
caCertificate, ok := caPublicKey.(*ssh.Certificate)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("Failed to convert the caPublicKey to an ssh.Certificate")
|
return nil, fmt.Errorf("failed to convert the caPublicKey to an ssh.Certificate")
|
||||||
}
|
}
|
||||||
|
|
||||||
private, err = ssh.NewCertSigner(caCertificate, private)
|
private, err = ssh.NewCertSigner(caCertificate, private)
|
||||||
|
|
|
||||||
|
|
@ -260,10 +260,7 @@ func main() {
|
||||||
args := ctx.Args().Slice()
|
args := ctx.Args().Slice()
|
||||||
remain := args
|
remain := args
|
||||||
|
|
||||||
for {
|
for len(remain) > 0 {
|
||||||
if len(remain) <= 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
args, remain = splitByDash(remain)
|
args, remain = splitByDash(remain)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ func newFilePtyLogger(outputdir string) (*filePtyLogger, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = typescript.Write([]byte(fmt.Sprintf("Script started on %v\n", now.Format(time.ANSIC))))
|
_, err = fmt.Fprintf(typescript, "Script started on %v\n", now.Format(time.ANSIC))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
@ -79,7 +79,7 @@ func (l *filePtyLogger) Close() (err error) {
|
||||||
// if _, err = ; err != nil {
|
// if _, err = ; err != nil {
|
||||||
// return err
|
// return err
|
||||||
// }
|
// }
|
||||||
_, _ = l.typescript.Write([]byte(fmt.Sprintf("Script done on %v\n", time.Now().Format(time.ANSIC))))
|
_, _ = fmt.Fprintf(l.typescript, "Script done on %v\n", time.Now().Format(time.ANSIC))
|
||||||
|
|
||||||
l.typescript.Close()
|
l.typescript.Close()
|
||||||
l.timing.Close()
|
l.timing.Close()
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ func TestOldSshd(t *testing.T) {
|
||||||
enterPassword(stdin, stdout, "pass")
|
enterPassword(stdin, stdout, "pass")
|
||||||
|
|
||||||
waitForStdoutContains(stdout, "SSHREADY", func(_ string) {
|
waitForStdoutContains(stdout, "SSHREADY", func(_ string) {
|
||||||
_, _ = stdin.Write([]byte(fmt.Sprintf("%v\n", "triggerping")))
|
_, _ = fmt.Fprintf(stdin, "%v\n", "triggerping")
|
||||||
})
|
})
|
||||||
|
|
||||||
time.Sleep(time.Second * 3) // wait for file flush
|
time.Sleep(time.Second * 3) // wait for file flush
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ func waitForStdoutContains(stdout io.Reader, text string, cb func(string)) {
|
||||||
|
|
||||||
func enterPassword(stdin io.Writer, stdout io.Reader, password string) {
|
func enterPassword(stdin io.Writer, stdout io.Reader, password string) {
|
||||||
waitForStdoutContains(stdout, "'s password", func(_ string) {
|
waitForStdoutContains(stdout, "'s password", func(_ string) {
|
||||||
_, _ = stdin.Write([]byte(fmt.Sprintf("%v\n", password)))
|
_, _ = fmt.Fprintf(stdin, "%v\n", password)
|
||||||
log.Printf("got password prompt, sending password")
|
log.Printf("got password prompt, sending password")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ func (l *singleConnListener) Accept() (net.Conn, error) {
|
||||||
|
|
||||||
// Addr implements net.Listener
|
// Addr implements net.Listener
|
||||||
func (l *singleConnListener) Addr() net.Addr {
|
func (l *singleConnListener) Addr() net.Addr {
|
||||||
return l.conn.LocalAddr()
|
return l.LocalAddr()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close implements net.Listener
|
// Close implements net.Listener
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ func (l *listOrString) UnmarshalYAML(value *yaml.Node) error {
|
||||||
l.Str = str
|
l.Str = str
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("Failed to unmarshal OneOfType")
|
return fmt.Errorf("failed to unmarshal OneOfType")
|
||||||
}
|
}
|
||||||
|
|
||||||
type yamlPipe struct {
|
type yamlPipe struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue