Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
737607ba
Commit
737607ba
authored
Jun 14, 2017
by
Justin Santa Barbara
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
AWS: Fix suspicious loop comparing permissions
Because we only ever call it with a single UserId/GroupId, this would not have been a problem in practice, but this fixes the code. Fix #36902
parent
ad43147e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
aws.go
pkg/cloudprovider/providers/aws/aws.go
+8
-3
aws_test.go
pkg/cloudprovider/providers/aws/aws_test.go
+12
-0
No files found.
pkg/cloudprovider/providers/aws/aws.go
View file @
737607ba
...
...
@@ -2030,17 +2030,22 @@ func ipPermissionExists(newPermission, existing *ec2.IpPermission, compareGroupU
break
}
}
if
found
==
false
{
if
!
found
{
return
false
}
}
for
_
,
leftPair
:=
range
newPermission
.
UserIdGroupPairs
{
found
:=
false
for
_
,
rightPair
:=
range
existing
.
UserIdGroupPairs
{
if
isEqualUserGroupPair
(
leftPair
,
rightPair
,
compareGroupUserIDs
)
{
return
true
found
=
true
break
}
}
return
false
if
!
found
{
return
false
}
}
return
true
...
...
pkg/cloudprovider/providers/aws/aws_test.go
View file @
737607ba
...
...
@@ -877,6 +877,18 @@ func TestIpPermissionExistsHandlesMultipleGroupIds(t *testing.T) {
if
equals
{
t
.
Errorf
(
"Should have not been considered equal since first is not in the second array of groups"
)
}
// The first pair matches, but the second does not
newIpPermission2
:=
ec2
.
IpPermission
{
UserIdGroupPairs
:
[]
*
ec2
.
UserIdGroupPair
{
{
GroupId
:
aws
.
String
(
"firstGroupId"
)},
{
GroupId
:
aws
.
String
(
"fourthGroupId"
)},
},
}
equals
=
ipPermissionExists
(
&
newIpPermission2
,
&
oldIpPermission
,
false
)
if
equals
{
t
.
Errorf
(
"Should have not been considered equal since first is not in the second array of groups"
)
}
}
func
TestIpPermissionExistsHandlesRangeSubsets
(
t
*
testing
.
T
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment