Skip to content

Conversation

@timthelion
Copy link
Contributor

Don't use strings when you can use dictionaries/objects. JSON objects are trivial to parse and manipulate, unlike strings. String parsing is the #1 cause of security bugs, so if it can be trivially avoided, then why not ;)

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

understandable, but not the format for mount. This options string value is the arg provided to mount.
Granted, this arg is not order dependent, so concatenating them for a single string joined by commas is not awful, but leaving it as the string to be provided removes a moving-part of processing where other issues could be introduced.
I'm on the fence about this.

@timthelion
Copy link
Contributor Author

@vbatts You write "but leaving it as the string to be provided removes a moving-part of processing where other issues could be introduced." That "moving part" is a simple string concatination. That string computation is a one liner in most programming languages. If you use a string and for some reason that string had to be modified (to add, remove, or change on option) then the moving part would become something complex.

Furthermore, I argue that this object WILL need to be modified at run time. In the examples, we see gid being specified as well as the size of the tmpfs. The idea of parsing is not merely theoretical. So the choice is whether we want to parse that string or whether we want to concatinate a JSON object. Concatination is the obvious choice, especially since the once parsed string must be reconcatinated anyways.

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

Fair. I just prefer fewer moving parts.

Then the formating should likely be standardized. https://github.com/opencontainers/specs/pull/120/files#diff-695bac0ce528e5c6765a6666fcccc425R30 has mixed type values. These integers might should stay as strings, so there is not a type handling assumption for any given json library, and then string concat and join.

@mrunalp
Copy link
Contributor

mrunalp commented Aug 27, 2015

IIRC, we did have a similar discussion on runc/libcontainer and had voted to keep it as it is.

@timthelion
Copy link
Contributor Author

@mrunalp but you were wrong ;) .

Joking aside, I think that your comment shouldn't have much weight in this current discussion. What arguments were raised against using an object? Lets try to make decisions based on the techincal merit of arguments and not past concensus.

@vbatts I have changed gid to use a string.

Along the same lines as only using strings as values, I was thinking that it might make sense to use nil rather than true for options that are not set to anything. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

same here. this is a bool, but if rw expects a string value of true, then this might as well be "true"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't expect to be true, it expects to be rw. The pattern is, if there is a string on the right hand side(RHS) then the syntax is item=string and if it is true then the syntax is item without an equals sign. That's why I suggested using nil rather than true.

Copy link
Member

Choose a reason for hiding this comment

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

oh hurr. you're right. i wasn't even reading that as just rw. Would these be better as an array of strings then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well I thought about that too, that would make:

["nosuid","noexec","newinstance","ptmxmode=0666","mode=0620","gid=5"]

And the code to change the gid searches through that list for a string that starts with "gid=" and replaces that string. Not too bad, but still a form of parsing.

Copy link
Member

Choose a reason for hiding this comment

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

fair, but I think this is more acceptable though as the mount -o ... is required as a comma delimited list. So this would put the formating as the greatest common denominator.

@timthelion timthelion force-pushed the patch-1 branch 3 times, most recently from 81d03fd to 9b94c55 Compare August 27, 2015 19:27
@timthelion
Copy link
Contributor Author

@vbatts I've updated the PR.

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

nice nice.
I wonder if verbiage would be good to show the alignment, at least for linux/*nix is matching to mount and fstab option formating.

Also, I presume there could be similar for windows, but i'm unfamiliar there.

@dqminh
Copy link
Contributor

dqminh commented Aug 27, 2015

i think this looks good. the array version is much better than object version.

Also documentation for options needs to be changed, not a string anymore.

Don't use strings when you can use dictionaries/objects. JSON objects are trivial to parse and manipulate, unlike strings. String parsing is the opencontainers#1 cause of security bugs, so if it can be trivially avoided, then why not ;)
@timthelion
Copy link
Contributor Author

@dqminh oops, thanks.

@philips
Copy link
Contributor

philips commented Aug 27, 2015

This is fine with me. The primary two folks wanting a flat options string were @crosbymichael and @LK4D4 IIRC.

@mrunalp
Copy link
Contributor

mrunalp commented Aug 27, 2015

If we are going to change this, then might as well make it so there is no parsing required if possible.
I can't find any mount option that requires the value to be set to true.

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

@mrunalp that was the point in making it not a dictionary. mount options are not key=value, they are just a comma delimited list.

@mrunalp
Copy link
Contributor

mrunalp commented Aug 27, 2015

@vbatts Yes, but creating this new array still allows for items in the list to be key=value and that requires parsing the item to make sure it is correct which is only slightly better than what it is today.

A dictionary could be converted into mount options in a single loop and there is no parsing necessary.
To handle keys like newinstance we can require their value to be true like discussed earlier in the thread. Also, a validation tool could then check for invalid mount options without having to parse each item in the list.

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

the discussed true was in regards to: what =value to provide in a dictionary, for a key that requires no value, like rw

@mrunalp
Copy link
Contributor

mrunalp commented Aug 27, 2015

@vbatts Yep, that's what I was referring to as well.

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

That seems like sloppy semantics though. How is {"newinstance":false} expected to be handled?

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

And a technical side note, a few mount option parsers handle overrides where the right-most wins. So order matters. This is assured in lists, and not in dictionary maps.

@mrunalp
Copy link
Contributor

mrunalp commented Aug 27, 2015

@vbatts I am convinced but don't see what this PR buys then. However, I will stay out and go with whatever is decided :)

@vbatts
Copy link
Member

vbatts commented Aug 27, 2015

Haha. That circles back to my first concern. I could still be on the fence,
but figure we mimic the least common denominator for requirements.
On Aug 27, 2015 5:42 PM, "Mrunal Patel" [email protected] wrote:

@vbatts https://github.com/vbatts I am convinced but don't see what
this PR buys then. However, I will stay out and go with whatever is decided
:)


Reply to this email directly or view it on GitHub
#120 (comment).

@crosbymichael
Copy link
Member

change fine for me, looks exactly the same now just more " ;)

@wking
Copy link
Contributor

wking commented Aug 28, 2015 via email

@crosbymichael
Copy link
Member

using the list LGTM

@LK4D4
Copy link
Contributor

LK4D4 commented Aug 28, 2015

LGTM too

@vbatts
Copy link
Member

vbatts commented Aug 28, 2015

LGTM

vbatts added a commit that referenced this pull request Aug 28, 2015
JSON objects are easier to parse/manipulate
@vbatts vbatts merged commit b4af780 into opencontainers:master Aug 28, 2015
@timthelion timthelion deleted the patch-1 branch August 28, 2015 18:12
wking added a commit to wking/opencontainer-runtime-spec that referenced this pull request Aug 29, 2015
These snuck in with 7232e4b (specs: introduce the concept of a
runtime.json, 2015-07-30, opencontainers#88) and 73bf1ba (JSON objects are easier
to parse/manipulate, 2015-08-27, opencontainers#120).

Signed-off-by: W. Trevor King <[email protected]>
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

Successfully merging this pull request may close these issues.

8 participants