Skip to content

Commit 2b7d64b

Browse files
committed
fix gosec G114, enable index server scan
Signed-off-by: Kim Tsao <[email protected]>
1 parent 5ad7146 commit 2b7d64b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

index/server/pkg/server/index.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,18 @@ var getIndexLatency = prometheus.NewHistogramVec(
6767
func ServeRegistry() {
6868
// Enable metrics
6969
// Run on a separate port and router from the index server so that it's not exposed publicly
70-
http.Handle("/metrics", promhttp.Handler())
70+
71+
handler := http.NewServeMux()
72+
handler.Handle("/metrics", promhttp.Handler())
7173
prometheus.MustRegister(getIndexLatency)
72-
go http.ListenAndServe(":7071", nil)
74+
indexServer := &http.Server{
75+
Addr: ":7071",
76+
Handler: handler,
77+
ReadTimeout: 10 * time.Second,
78+
WriteTimeout: 10 * time.Second,
79+
}
80+
81+
go indexServer.ListenAndServe()
7382

7483
// Wait until registry is up and running
7584
err := wait.PollImmediate(time.Millisecond, time.Second*30, func() (bool, error) {

run_gosec.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ then
77
fi
88

99
echo "running gosec scan"
10-
gosec -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir index/server -exclude-dir index/generator/tests -exclude-dir tests ./...
10+
gosec -no-fail -fmt=sarif -out=gosec.sarif -exclude-dir index/generator/tests -exclude-dir tests ./...
1111

0 commit comments

Comments
 (0)