Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WithScanPath doesn't set path as expected #64

Closed
ecshreve opened this issue Mar 4, 2022 · 2 comments · Fixed by #65
Closed

WithScanPath doesn't set path as expected #64

ecshreve opened this issue Mar 4, 2022 · 2 comments · Fixed by #65
Assignees
Labels
bug Something isn't working

Comments

@ecshreve
Copy link
Contributor

ecshreve commented Mar 4, 2022

Describe the bug

The hunter.WithScanPath function doesn't pass it's argument down to validate, rather it passes in the existing Config.ScanPath.

Here's the offending line

c.ScanPath = validate.Path(c.Filesystem, c.ScanPath)

To Reproduce
Add a log line like this log.Debug().Str("scanpath", h.ScanPath).Send() at the top of hunter.Hunt() and run a few pillager hunt commands observing the logs.

go run cmd/pillager/main.go hunt . -l debug
5:36AM DBG  scanpath=.

go run cmd/pillager/main.go hunt ./_examples/testdata -l debug
5:38AM DBG  scanpath=.

Expected behavior

Scanpath should be set to the value of the command line argument.

@ecshreve ecshreve added the bug Something isn't working label Mar 4, 2022
@brittonhayes
Copy link
Owner

Woops! Missed that one. I'll take a peek at this. I think I need to add some basic smoke tests to catch goofy errors like this to prevent any unexpected behaviors with the cli commands and flags.

@ecshreve
Copy link
Contributor Author

ecshreve commented Mar 4, 2022

Yeah, I played around with some unit tests but couldn't settle on a pattern that made sense. Testing cli behavior is hard, I went deep down a rabbit hole reading how other people test clis. Probably some basic "run with this set of commands and flags and snapshot the output" type of tests would work

brittonhayes added a commit that referenced this issue Mar 4, 2022
brittonhayes added a commit that referenced this issue Mar 4, 2022
* fix: issue #64

* fix: removed debug log

Co-authored-by: Britton Hayes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants