Skip to content

Conversation

@fit2bot
Copy link
Contributor

@fit2bot fit2bot commented Dec 22, 2025

perf: ssh command acl accept

@fit2bot fit2bot requested a review from a team December 22, 2025 04:52
}
}

host, _, _ := net.SplitHostPort(sess.RemoteAddr().String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems to be free from any major issues. However, there is an opportunity for further optimization in function name "proxyAssetCommand". This command appears unrelated with other commands like assetCommandForTokenInfo that follow this method's signature.

Additionally:

  • The current version uses a loop and comparison to decide whether an ACL matches based on the Action field of a TokenInfo object. As such, it could be more efficient/performant if the matching logic was moved into a function where input data can be passed as a reference instead. For example:

var match = func(ti *model.TokenInfos) bool {
return ti.FilterACLs[ac] // Use slice indexing here
}

This will also improve readability due to clear implementation details when calling it inside another function.

Here are some brief points:

1. Naming convention should be followed (lowercase).
2. Consider move the conditional statement out of loop so efficiency improves.
3. Add appropriate comments around functions and sections, especially those parts needing extra explanation which might be difficult to understand otherwise.

Please let me know if you need help with anything else!

@LeeEirc LeeEirc force-pushed the pr@dev@perf_cmd_acl branch from 1984bcc to 674669a Compare December 22, 2025 04:53
}
}

host, _, _ := net.SplitHostPort(sess.RemoteAddr().String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no immediate issues with this code snippet; it currently appears free of syntax, spelling, or formatting errors. However, one could consider improving the readability:

func proxyAssetCommand(sess ssh.Session, sshClient *srvconn.SSHClient, rawStr string) error {

    // todo: support ACL command filter
	// parse raw string to action (execute/rollback)
	var action, err = ParseAction(rawStr)
	if err != nil {
		return err
	}

	// validate input data
	if !IsValidAction(action) {
        return fmt.Errorf("action must be 'execute' or 'rollback'")
	}

	// handle different actions based on action type
	switch action {
	case "execute":
      // implement execution logic here

	default:
       break
	}

	return nil
}

This modification enhances the readability of the function by using variables named action and err, which helps in identifying parts of the code that can potentially lead to runtime exceptions when parsing the raw string.

For future enhancement, consider adding docstrings around more complex sections of the functions like handling different types of acls.

 +  "model.CommandACLs(acls)",

And document variable names appropriately.
Note that these modifications assume basic understanding of Go programming principles such as best practices for naming variables and avoiding unnecessary complexity within conditional blocks.
The code is mostly correct until line 415 where there would need additional documentation explaining parse raw string to action. After reading through the rest of your code I didn't find other major discrepancies, so the current implementation does not appear flawed per se but if you have specific areas of concern please clarify them further.

@sonarqubecloud
Copy link

@LeeEirc LeeEirc merged commit e58ad05 into dev Dec 22, 2025
10 of 11 checks passed
@LeeEirc LeeEirc deleted the pr@dev@perf_cmd_acl branch December 22, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants