Skip to content

Commit 3c7ae8b

Browse files
committed
Added gosec
1 parent 199c7f0 commit 3c7ae8b

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

.github/workflows/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ jobs:
4545
tags: transformimgs-dev
4646
cache-from: type=local,src=/tmp/.buildx-cache
4747
cache-to: type=local,dest=/tmp/.buildx-cache
48+
-
49+
name: Gosec
50+
id: gosec
51+
uses: securego/gosec@master
52+
with:
53+
args: ./...
4854
-
4955
name: Run tests
5056
run: |

cmd/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net/http"
1010
"os"
1111
"runtime"
12+
"time"
1213
)
1314

1415
func main() {
@@ -46,7 +47,13 @@ func main() {
4647
router.HandleFunc("/health", health.Health)
4748

4849
img.Log.Printf("Running the application on port 8080...\n")
49-
err = http.ListenAndServe(":8080", router)
50+
server := http.Server{
51+
Addr: ":8080",
52+
Handler: router,
53+
ReadTimeout: 5 * time.Second,
54+
WriteTimeout: 10 * time.Second,
55+
}
56+
err = server.ListenAndServe()
5057

5158
if err != nil {
5259
img.Log.Errorf("Error while stopping application: %+v", err)

img/processor/imagemagick.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func (p *ImageMagick) Optimise(config *img.TransformationConfig) (*img.Image, er
252252

253253
func (p *ImageMagick) execImagemagick(in *bytes.Reader, args []string, imgId string) ([]byte, error) {
254254
var out, cmderr bytes.Buffer
255-
cmd := exec.Command(p.convertCmd)
255+
cmd := exec.Command(p.convertCmd) // #nosec G204 - sanitizing before assigning
256256

257257
cmd.Args = append(cmd.Args, args...)
258258

@@ -295,7 +295,7 @@ func (p *ImageMagick) LoadImageInfo(src *img.Image) (*img.Info, error) {
295295
var out, cmderr bytes.Buffer
296296
imgId := src.Id
297297
in := bytes.NewReader(src.Data)
298-
cmd := exec.Command(p.identifyCmd)
298+
cmd := exec.Command(p.identifyCmd) // #nosec G204 - sanitizing before assigning
299299
cmd.Args = append(cmd.Args, "-format", "%m %Q %[opaque] %w %h", "-")
300300

301301
cmd.Stdin = in

0 commit comments

Comments
 (0)