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

Manual argument parsing and undefined behavior in cmd entry points #128

Open
ross-spencer opened this issue Oct 31, 2024 · 1 comment
Open
Assignees

Comments

@ross-spencer
Copy link
Collaborator

Code is triggered by excess data on the command line when running a command.

E.g. command:

./gocfl add /tmp/gocfl-test /tmp/tmpfile/ -u "ross" -a "ross@gocfl" -m "one file" --object-id 'rs:id001' --log-level DEBUG IGNOREMEEXCESSTEXT

The value IGNOREMEEXCESSTEXT is evaluated by the below and because it can't match a value it is largely ignored but I feel perhaps it's handling can maybe be more explicit in the command line args where we can provide some further documentation about its use in GOCFL. There might also (or instead of) be a way to route the value better through the command entry point as well, but I'm not clear on that and don't have too much time to spend on it at present.

gocfl/gocfl/cmd/add.go

Lines 222 to 238 in 12be4b8

area := conf.DefaultArea
if area == "" {
area = "content"
}
var areaPaths = map[string]fs.FS{}
for i := 2; i < len(args); i++ {
matches := areaPathRegexp.FindStringSubmatch(args[i])
if matches == nil {
logger.Error().Msgf("no area given in areapath '%s'", args[i])
continue
}
areaPaths[matches[1]], err = fsFactory.Get(matches[2])
if err != nil {
doNotClose = true
logger.Panic().Stack().Msgf("cannot get filesystem for '%s'", args[i])
}
}

@je4 je4 self-assigned this Dec 6, 2024
@je4
Copy link
Collaborator

je4 commented Dec 6, 2024

Eventually it would be enought to replace MinimumArgs with ExactArgs

https://github.com/ocfl-archive/gocfl/blob/12be4b8e73c6ed228668fb021a51fe065f83568c/gocfl/cmd/add.go#L35C2-L35C33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants