Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/vfkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ func createCloudInitISO(files map[string]io.Reader) (string, error) {
if err != nil {
return "", fmt.Errorf("unable to create temporary cloud-init ISO file: %w", err)
}
isoFileName := isoFile.Name()

defer func() {
if err := isoFile.Close(); err != nil {
Expand All @@ -419,7 +420,7 @@ func createCloudInitISO(files map[string]io.Reader) (string, error) {

// register handler to remove isoFile when exiting
util.RegisterExitHandler(func() {
os.Remove(isoFile.Name())
os.Remove(isoFileName)
})

err = writer.WriteTo(isoFile, "cidata")
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/bootloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (bootloader *EFIBootloader) ToCmdLine() ([]string, error) {

builder := strings.Builder{}
builder.WriteString("efi")
builder.WriteString(fmt.Sprintf(",variable-store=%s", bootloader.EFIVariableStorePath))
fmt.Fprintf(&builder, ",variable-store=%s", bootloader.EFIVariableStorePath)
if bootloader.CreateVariableStore {
builder.WriteString(",create")
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/virtio.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ func (dev *VirtioNet) ToCmdLine() ([]string, error) {
builder.WriteString(",vfkitMagic=off")
}
default:
fmt.Fprintf(&builder, ",fd=%d", dev.Socket.Fd())
fmt.Fprintf(&builder, ",fd=%d", dev.Socket.Fd()) // #nosec G705 -- CLI arg, not HTML
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A cli arg is still user provided and could be abused?

}

if len(dev.MacAddress) != 0 {
Expand Down Expand Up @@ -515,6 +515,9 @@ func (dev *VirtioNet) FromOptions(options []option) error {
if err != nil {
return err
}
if fd < 0 || fd > math.MaxInt32 {
return fmt.Errorf("invalid file descriptor: %d", fd)
}
dev.Socket = os.NewFile(uintptr(fd), "vfkit virtio-net socket")
case "unixSocketPath":
dev.UnixSocketPath = option.value
Expand Down
2 changes: 1 addition & 1 deletion test/osprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func uncompressFedora(fileName string, targetDir string) (string, error) {

xzCutName, _ := strings.CutSuffix(filepath.Base(file.Name()), ".xz")
outPath := filepath.Join(targetDir, xzCutName)
out, err := os.Create(outPath)
out, err := os.Create(outPath) // #nosec G703 -- file is created in a temporary directory
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

G703 is "Path traversal via taint analysis" https://github.com/securego/gosec/blob/master/RULES.md

As I understand it, if gosec warns about this, this means it thinks the user could provide a specially crafted filename which would get the code to create the file outside of the temporary directory.
Maybe this is a false positive regardless, but I don’t think the fact that this is a temporary directory explains why.

if err != nil {
return "", err
}
Expand Down
47 changes: 23 additions & 24 deletions tools/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/crc-org/vfkit/tools

go 1.24.0
go 1.25.0

require github.com/golangci/golangci-lint/v2 v2.8.0
require github.com/golangci/golangci-lint/v2 v2.10.1

require (
4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
Expand All @@ -21,12 +21,12 @@ require (
github.com/BurntSushi/toml v1.6.0 // indirect
github.com/Djarvur/go-err113 v0.1.1 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
github.com/MirrexOne/unqueryvet v1.4.0 // indirect
github.com/MirrexOne/unqueryvet v1.5.3 // indirect
github.com/OpenPeeDeeP/depguard/v2 v2.2.1 // indirect
github.com/alecthomas/chroma/v2 v2.21.1 // indirect
github.com/alecthomas/chroma/v2 v2.23.1 // indirect
github.com/alecthomas/go-check-sumtype v0.3.1 // indirect
github.com/alexkohler/nakedret/v2 v2.0.6 // indirect
github.com/alexkohler/prealloc v1.0.1 // indirect
github.com/alexkohler/prealloc v1.0.2 // indirect
github.com/alfatraining/structtag v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/alingse/nilnesserr v0.2.0 // indirect
Expand All @@ -37,7 +37,7 @@ require (
github.com/bkielbasa/cyclop v1.2.3 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bombsimon/wsl/v4 v4.7.0 // indirect
github.com/bombsimon/wsl/v5 v5.3.0 // indirect
github.com/bombsimon/wsl/v5 v5.6.0 // indirect
github.com/breml/bidichk v0.3.3 // indirect
github.com/breml/errchkjson v0.4.1 // indirect
github.com/butuzov/ireturn v0.4.0 // indirect
Expand All @@ -48,7 +48,7 @@ require (
github.com/charithe/durationcheck v0.0.11 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.8.0 // indirect
github.com/charmbracelet/x/ansi v0.10.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/ckaznocha/intrange v0.3.1 // indirect
Expand All @@ -64,7 +64,7 @@ require (
github.com/firefart/nonamedreturns v1.0.6 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/ghostiam/protogetter v0.3.18 // indirect
github.com/ghostiam/protogetter v0.3.20 // indirect
github.com/go-critic/go-critic v0.14.3 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
Expand All @@ -73,18 +73,18 @@ require (
github.com/go-toolsmith/astp v1.1.0 // indirect
github.com/go-toolsmith/strparse v1.1.0 // indirect
github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/godoc-lint/godoc-lint v0.11.1 // indirect
github.com/godoc-lint/godoc-lint v0.11.2 // indirect
github.com/gofrs/flock v0.13.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golangci/asciicheck v0.5.0 // indirect
github.com/golangci/dupl v0.0.0-20250308024227-f665c8d69b32 // indirect
github.com/golangci/go-printf-func-name v0.1.1 // indirect
github.com/golangci/gofmt v0.0.0-20250106114630-d62b90e6713d // indirect
github.com/golangci/golines v0.14.0 // indirect
github.com/golangci/misspell v0.7.0 // indirect
github.com/golangci/golines v0.15.0 // indirect
github.com/golangci/misspell v0.8.0 // indirect
github.com/golangci/plugin-module-register v0.1.2 // indirect
github.com/golangci/revgrep v0.8.0 // indirect
github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect
Expand Down Expand Up @@ -130,15 +130,15 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mgechev/revive v1.13.0 // indirect
github.com/mgechev/revive v1.14.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moricho/tparallel v0.3.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nishanths/exhaustive v0.12.0 // indirect
github.com/nishanths/predeclared v0.2.2 // indirect
github.com/nunnatsa/ginkgolinter v0.21.2 // indirect
github.com/nunnatsa/ginkgolinter v0.23.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -160,8 +160,8 @@ require (
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.29.0 // indirect
github.com/securego/gosec/v2 v2.22.11 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/securego/gosec/v2 v2.23.0 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sonatard/noctx v0.4.0 // indirect
github.com/sourcegraph/go-diff v0.7.0 // indirect
Expand Down Expand Up @@ -193,23 +193,22 @@ require (
gitlab.com/bosi/decorder v0.4.2 // indirect
go-simpler.org/musttag v0.14.0 // indirect
go-simpler.org/sloglint v0.11.1 // indirect
go.augendre.info/arangolint v0.3.1 // indirect
go.augendre.info/arangolint v0.4.0 // indirect
go.augendre.info/fatcontext v0.9.0 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.27.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/exp/typeparams v0.0.0-20251023183803-a4bb9ffd2546 // indirect
golang.org/x/mod v0.31.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20260209203927-2842357ff358 // indirect
golang.org/x/mod v0.33.0 // indirect
golang.org/x/sync v0.19.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/tools v0.40.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/text v0.34.0 // indirect
golang.org/x/tools v0.42.0 // indirect
google.golang.org/protobuf v1.36.8 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.6.1 // indirect
honnef.co/go/tools v0.7.0 // indirect
mvdan.cc/gofumpt v0.9.2 // indirect
mvdan.cc/unparam v0.0.0-20251027182757-5beb8c8f8f15 // indirect
)
Loading
Loading