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

ensure non-nil Attachment in getENIAttachmentID #915

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

jaypipes
Copy link
Contributor

@jaypipes jaypipes commented Apr 17, 2020

Practice good code safety in the EC2MetadataCache.getENIAttachmentID() method
by not assuming that either the DescribeNetworkInterfacesOutput
struct's NetworkInterfaces field is not empty and that the first
NetworkInterface struct in that collection has a non-nil Attachment
field.

Fixes Issue #914

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Practice good code safety in the `EC2MetadataCache.getENIAttachmentID()`
method by not assuming that either the `DescribeNetworkInterfacesOutput`
struct's `NetworkInterfaces` field is not empty and that the first
`NetworkInterface` struct that collection has a non-nil `Attachment`
field.

Fixes Issue aws#914 however note that with aws#909, the source code changed
dramatically and this patch will need to be written differently for
v1.5.x branches.
@jaypipes jaypipes changed the title ensure non-nil Attachement in DescribeENI ensure non-nil Attachment in getENIAttachmentID Apr 17, 2020
Copy link
Contributor

@mogren mogren left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@@ -305,6 +305,68 @@ func TestAWSGetFreeDeviceNumberNoDevice(t *testing.T) {
assert.Error(t, err)
}

func TestGetENIAttachmentID(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@mogren mogren added the bug label Apr 17, 2020
@mogren mogren merged commit 9c86334 into aws:master Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants