Skip to content

Conversation

oncilla
Copy link
Contributor

@oncilla oncilla commented Oct 7, 2019

Adds TRC configuration parsing and encoding.


This change is Reviewable

@oncilla oncilla added c/tooling SCION network tools c/CPPKI SCION Control-plane PKI labels Oct 7, 2019
@oncilla oncilla added this to the Q4S1 milestone Oct 7, 2019
@oncilla oncilla requested a review from scrye October 7, 2019 11:47
@oncilla oncilla force-pushed the pub-spki-trcconfig branch from f25cb46 to 4d5ef1f Compare October 7, 2019 15:16
@scrye scrye removed this from the Q4S1 milestone Oct 28, 2019
Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 7 of 7 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @oncilla)


go/tools/scion-pki/internal/v2/conf/trc.go, line 111 at r1 (raw file):

type Primary struct {
	Attributes              []trc.Attribute     `toml:"attributes"`
	IssuingKeyVersion       *scrypto.KeyVersion `toml:"issuing_key_version"`

Why is this a pointer instead of a value? Every read risks causing a panic this way.

If it's just to support default values because 0 is a special cased value, then it's ok provided this never gets seen out of internal.

I assume the same reasoning applies to the fields below.


go/tools/scion-pki/internal/v2/conf/trc.go, line 117 at r1 (raw file):

// Validate checks the right keys are set.
func (p Primary) Validate() error {

This will return nil for something like:

func TestXxx(t *testing.T) {
	p := conf.Primary{
		Attributes: []trc.Attribute{"foo"},
	}
	assert.Error(t, p.Validate())
}

So it looks like "deep validation" (validation of all fields) isn't provided by the API. If this is intended, is should be explicitly mentioned in the godoc.

@oncilla oncilla force-pushed the pub-spki-trcconfig branch from 4d5ef1f to 35ee3a3 Compare November 4, 2019 09:02
Copy link
Contributor Author

@oncilla oncilla left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 of 7 files reviewed, 2 unresolved discussions (waiting on @scrye)


go/tools/scion-pki/internal/v2/conf/trc.go, line 111 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

Why is this a pointer instead of a value? Every read risks causing a panic this way.

If it's just to support default values because 0 is a special cased value, then it's ok provided this never gets seen out of internal.

I assume the same reasoning applies to the fields below.

Well somewhat.

0 is not special cased, but a valid value.
It has to be a pointer, because that is the only way of distinguishing whether the value was actually set in the toml file.

I could implement the toml.Unmarshaler interface, but that is overkill IMO.


go/tools/scion-pki/internal/v2/conf/trc.go, line 117 at r1 (raw file):

Previously, scrye (Sergiu Costea) wrote…

This will return nil for something like:

func TestXxx(t *testing.T) {
	p := conf.Primary{
		Attributes: []trc.Attribute{"foo"},
	}
	assert.Error(t, p.Validate())
}

So it looks like "deep validation" (validation of all fields) isn't provided by the API. If this is intended, is should be explicitly mentioned in the godoc.

That should never be the case in normal operation because trc.Attribute implements UnmarshalText that has the validity check, and attributes always stem from parsing, or constant value.

Added for completeness.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r2.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


go/tools/scion-pki/internal/v2/conf/trc.go, line 117 at r1 (raw file):

Previously, Oncilla wrote…

That should never be the case in normal operation because trc.Attribute implements UnmarshalText that has the validity check, and attributes always stem from parsing, or constant value.

Added for completeness.

That assumes only UnmarshalText is used to construct objects of type trc.Attribute. But given the exported type and fields that may not always be the case.

It's better to be paranoid, and assume the users of your API will use it in unintended ways (often due to a lack of familiarity). And once it's used the wrong way and it works, it might be the case that it can no longer be changed.

Copy link
Contributor

@scrye scrye left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Adds TRC configuration parsing and encoding.
@oncilla oncilla force-pushed the pub-spki-trcconfig branch from 35ee3a3 to e427a24 Compare November 4, 2019 09:32
@oncilla oncilla merged commit 7af09e3 into scionproto:master Nov 4, 2019
@oncilla oncilla deleted the pub-spki-trcconfig branch November 4, 2019 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/CPPKI SCION Control-plane PKI c/tooling SCION network tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants