Skip to content

Commit

Permalink
gosec: avoid security warning
Browse files Browse the repository at this point in the history
CWE-118: Implicit memory aliasing in for loop
  • Loading branch information
brainexe committed Aug 25, 2023
1 parent f509038 commit 1506a2f
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions command/pool/pool_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ func (c *poolCommands) lockResource(match matcher.Result, message msg.Message) {
c.slackClient.ReplyError(message, err)
return
}
c.slackClient.SendMessage(message, fmt.Sprintf("`%s` is locked for you until %s!\n%s%s", resource.Resource.Name, resource.LockUntil.Format(time.RFC1123), getFormattedReason(resource.Reason), getAddressesAndFeatures(&resource.Resource)))
c.slackClient.SendMessage(
message,
fmt.Sprintf("`%s` is locked for you until %s!\n%s%s",
resource.Resource.Name,
resource.LockUntil.Format(time.RFC1123),
getFormattedReason(resource.Reason),
getAddressesAndFeatures(resource.Resource),
),
)
}

func (c *poolCommands) unlockResource(match matcher.Result, message msg.Message) {
Expand Down Expand Up @@ -208,15 +216,25 @@ func (c *poolCommands) listPoolInfo(match matcher.Result, message msg.Message) {
messages = append(messages, "*Available:*")
free := c.pool.GetFree()
for _, f := range free {
messages = append(messages, fmt.Sprintf("`%s`:\n%s\n", f.Name, getAddressesAndFeatures(f)))
messages = append(messages, fmt.Sprintf("`%s`:\n%s\n", f.Name, getAddressesAndFeatures(*f)))
}
}
messages = append(messages, "")
if len(status) == 0 || status == "used" || status == "locked" {
locked := c.pool.GetLocks("")
messages = append(messages, "*Used/Locked:*")
for _, l := range locked {
messages = append(messages, fmt.Sprintf("`%s`:\n locked by %s until %s\n%s%s", l.Resource.Name, l.User, l.LockUntil.Format(time.RFC1123), getFormattedReason(l.Reason), getAddressesAndFeatures(&l.Resource)))
messages = append(
messages,
fmt.Sprintf(
"`%s`:\n locked by %s until %s\n%s%s",
l.Resource.Name,
l.User,
l.LockUntil.Format(time.RFC1123),
getFormattedReason(l.Reason),
getAddressesAndFeatures(l.Resource),
),
)
}
}

Expand All @@ -230,7 +248,7 @@ func getFormattedReason(reason string) string {
return fmt.Sprintf("_%s_\n", reason)
}

func getAddressesAndFeatures(resource *config.Resource) string {
func getAddressesAndFeatures(resource config.Resource) string {
var lines []string
lines = append(lines, ">_Addresses:_")
for _, address := range resource.Addresses {
Expand Down

0 comments on commit 1506a2f

Please sign in to comment.