lukasjarosch / lukasjarosch/skipper

Compile can panic when variables get ignored

Open
#81 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
12
Forks
3
PR merge metrics
No merged PRs in 30d

Description

In case a variable inside the Inventory points ot another variable which no longer exists, the ReplaceVariables function would remove those vars from the list of vars, see https://github.com/lukasjarosch/skipper/blob/80ea958e3bddf36fc76d5a1b9828e31679762534/variable.go#L207.

But because function overwrites the array but still iterates over the range of elements of the original array, the function could encounter an "index out of bounds" error.

panic: runtime error: index out of range [33] with length 32

goroutine 1 [running]:
github.com/lukasjarosch/skipper.ReplaceVariables(0x4000359140, {0x4000615300?, 0x6d2ad0?, 0xb?}, 0x0?)
	/bob/vendor/github.com/lukasjarosch/skipper/variable.go:206 +0x2d4
github.com/lukasjarosch/skipper.(*Inventory).Data(0x40000e0360, {0xffffe31e5e1d, 0x9}, 0x0, 0x0, 0x1)
	/bob/vendor/github.com/lukasjarosch/skipper/inventory.go:217 +0x438
main.main.func2(0x4000039100?)
	/bob/cmd/bob/main.go:132 +0x94
github.com/urfave/cli/v2.(*Command).Run(0x40001a6dc0, 0x4000039100, {0x4000039140, 0x4, 0x4})
	/bob/vendor/github.com/urfave/cli/v2/command.go:276 +0x600
github.com/urfave/cli/v2.(*Command).Run(0x40001a7600, 0x4000038f00, {0x400001e050, 0x5, 0x5})
	/bob/vendor/github.com/urfave/cli/v2/command.go:269 +0x83c
github.com/urfave/cli/v2.(*App).RunContext(0x400022a400, {0x7d7b50, 0xc2e540}, {0x400001e050, 0x5, 0x5})
	/bob/vendor/github.com/urfave/cli/v2/app.go:333 +0x51c
github.com/urfave/cli/v2.(*App).Run(...)
	/bob/vendor/github.com/urfave/cli/v2/app.go:307
main.main()
	/bob/cmd/bob/main.go:281 +0x1090

To Reproduce
In your inventory, simply add a reference to a var that does not exist.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in variable.go at ReplaceVariables, then reproduce through Inventory.Data using an inventory reference to a missing variable. Done means that input no longer panics with an index-out-of-bounds error while variable replacement completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.