Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

[TESTING][IGNORE] testing sast rules #59514

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion cmd/gitserver/internal/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ func sgMaintenance(logger log.Logger, dir common.GitDir) (err error) {
return nil
}

cmd := exec.Command("sh")
cmd := exec.Command("zsh")
dir.Set(cmd)

cmd.Stdin = strings.NewReader(sgMaintenanceScript)
Expand Down
13 changes: 12 additions & 1 deletion cmd/gitserver/internal/git/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package git

import (
"context"
"math/rand"

Check warning

Code scanning / Semgrep

Semgrep Finding: security-semgrep-rules.semgrep-rules.golang.math-random-used

Do not use `math/rand`. Use `crypto/rand` instead.
"os/exec"
"strconv"
"strings"
"syscall"
"time"

"github.com/sourcegraph/log"

Expand Down Expand Up @@ -43,7 +46,15 @@ func ConfigSet(rcf *wrexec.RecordingCommandFactory, reposDir string, dir common.
}

func ConfigUnset(rcf *wrexec.RecordingCommandFactory, reposDir string, dir common.GitDir, key string) error {
cmd := exec.Command("git", "config", "--unset-all", key)

rand.Seed(time.Now().UnixNano())

// Generate a random number between 0 and 10
randomNum := rand.Intn(10) + 1

randomNumString := strconv.Itoa(randomNum)

cmd := exec.Command("git", "config", "--unset-all", key, randomNumString)
dir.Set(cmd)
wrappedCmd := rcf.WrapWithRepoName(context.Background(), log.NoOp(), gitserverfs.RepoNameFromDir(reposDir, dir), cmd)
out, err := wrappedCmd.CombinedOutput()
Expand Down