Skip to content

Commit

Permalink
Merge pull request #255 from homeport/address/gosec-finding
Browse files Browse the repository at this point in the history
Address `gosec` findings
  • Loading branch information
HeavyWombat authored Jan 1, 2025
2 parents bccf6b3 + ec63791 commit 13f7d42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ window including all terminal colors and text decorations.
version = "(development)"
}

// #nosec G104
bunt.Printf("Lime{*%s*} version DimGray{%s}\n",
executableName(),
version,
Expand Down Expand Up @@ -111,6 +112,7 @@ window including all terminal colors and text decorations.
// Optional: Prepend command line arguments to output content
//
if includeCommand, err := cmd.Flags().GetBool("show-cmd"); err == nil && includeCommand {
// #nosec G104
bunt.Fprintf(&buf, "Lime{%s} DimGray{%s}\n",
commandIndicator,
strings.Join(args, " "),
Expand Down Expand Up @@ -182,7 +184,7 @@ window including all terminal colors and text decorations.
return fmt.Errorf("file extension %q of filename %q is not supported, only png is supported", extension, filename)
}

file, err := os.Create(filename)
file, err := os.Create(filepath.Clean(filename))
if err != nil {
return fmt.Errorf("failed to create file: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/root_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func init() {
return err
}

cmd := exec.Command(osascript, "-e", buf.String())
cmd := exec.Command(osascript, "-e", buf.String()) // #nosec G204
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprint(os.Stderr, string(out))
Expand Down
12 changes: 6 additions & 6 deletions internal/img/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ func (s *Scaffold) image() (image.Image, error) {
switch cr.Settings & 0x02 {
case 2:
dc.SetRGB255(
int((cr.Settings>>32)&0xFF),
int((cr.Settings>>40)&0xFF),
int((cr.Settings>>48)&0xFF),
int((cr.Settings>>32)&0xFF), // #nosec G115
int((cr.Settings>>40)&0xFF), // #nosec G115
int((cr.Settings>>48)&0xFF), // #nosec G115
)

dc.DrawRectangle(x, y-h+12, w, h)
Expand All @@ -322,9 +322,9 @@ func (s *Scaffold) image() (image.Image, error) {
switch cr.Settings & 0x01 {
case 1:
dc.SetRGB255(
int((cr.Settings>>8)&0xFF),
int((cr.Settings>>16)&0xFF),
int((cr.Settings>>24)&0xFF),
int((cr.Settings>>8)&0xFF), // #nosec G115
int((cr.Settings>>16)&0xFF), // #nosec G115
int((cr.Settings>>24)&0xFF), // #nosec G115
)

default:
Expand Down

0 comments on commit 13f7d42

Please sign in to comment.