Skip to content

Conversation

@sujankota
Copy link
Contributor

No description provided.

@sujankota sujankota requested a review from a team as a code owner September 9, 2024 17:08
Copy link

@Doom4535 Doom4535 left a comment

Choose a reason for hiding this comment

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

I like the code cleanup; I believe the direct inclusion of the OpenTDF sdk can be avoided here by using the one that is already wrapped inside of the handler (although I have not tested these changes myself).

Comment on lines 21 to 26
// TODO: validate values are FQNs or return an error [https://github.com/opentdf/platform/issues/515]
_, err = h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), *nanoTDFConfig)
_, err := h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), options...)
if err != nil {
return nil, err
}
return enc, nil

Choose a reason for hiding this comment

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

Slight code shortening:

if _, err := h.sdk.CreateNanoTDF(enc, bytes.NewReader(b), options...); err != nil {
	return nil, err
}
return enc, nil

Comment on lines 31 to 35
_, err := h.sdk.ReadNanoTDF(io.Writer(&outBuf), bytes.NewReader(toDecrypt))
if err != nil {
return nil, err
}
return &outBuf, nil

Choose a reason for hiding this comment

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

While we're here, we could shorten this spot a bit as well:

if _, err := h.sdk.ReadNanoTDF(io.Writer(&outBuf), bytes.NewReader(toDecrypt)); err != nil {
	return nil, err
}
return &outBuf, nil

Comment on lines +14 to 20
options := []sdk.NanoTDFOption{
sdk.WithKasURL(h.platformEndpoint + kasUrlPath),
sdk.WithNanoDataAttributes(values),
}
if ecdsaBinding {
nanoTDFConfig.EnableECDSAPolicyBinding()
options = append(options, sdk.WithECDSAPolicyBinding())
}

Choose a reason for hiding this comment

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

Is it possible to remove the need for the extra module inclusion of github.com/opentdf/platform/sdk by using the handler wrapped sdk? Something like:

options := []h.sdk.NanoTDFOption{
	h.sdk.WithKasURL(h.platformEndpoint + kasUrlPath),
	h.sdk.WithNanoDataAttributes(values),
}

if ecdsaBinding {
	options = append(options, h.sdk.WithECDSAPolicyBinding())
}

@Doom4535
Copy link

@sujankota I believe the commit name also needs to be updated, as this fix is not for the CI/CD environment; also don't forget to signoff on the commit to satisfy the DCO (part of the new committing process: https://github.com/opentdf/otdfctl/blob/main/CONTRIBUTING.md).

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.

3 participants