Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
kube-bench
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
aquasecurity
kube-bench
Commits
11136317
Unverified
Commit
11136317
authored
3 years ago
by
tonyqui
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix experimental-encryption-provider-config test on OCP 3.11 - Issue #926 (#1024)
Co-authored-by:
Yoav Rotem
<
yoavrotems97@gmail.com
>
parent
0de52d98
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cfg/rh-0.7/master.yaml
+7
-2
7 additions, 2 deletions
cfg/rh-0.7/master.yaml
check/test_test.go
+127
-1
127 additions, 1 deletion
check/test_test.go
with
134 additions
and
3 deletions
cfg/rh-0.7/master.yaml
+
7
−
2
View file @
11136317
...
...
@@ -591,11 +591,16 @@ groups:
audit_config
:
"
grep
-A1
experimental-encryption-provider-config
/etc/origin/master/master-config.yaml
|
sed
-n
'2p'
|
awk
'{
print
$2
}'
|
xargs
cat"
tests
:
bin_op
:
and
test_items
:
-
path
:
"
{.providers.aescbc.experimental-encryption-provider-config}"
-
path
:
"
{.resources[*].providers[*].aescbc.keys[*]}}"
compare
:
op
:
has
value
:
"
secret"
-
path
:
"
{.resources[*].providers[*].aescbc.keys[*]}}"
compare
:
op
:
has
value
:
"
aescbc
"
value
:
"
name
"
remediation
:
|
Edit the Openshift master config file /etc/origin/master/master-config.yaml and set aescbc as the first provider in encryption provider config.
See https://docs.openshift.com/container-platform/3.10/admin_guide/encrypting_data.html.
...
...
This diff is collapsed.
Click to expand it.
check/test_test.go
+
127
−
1
View file @
11136317
...
...
@@ -427,7 +427,7 @@ func TestExecuteJSONPath(t *testing.T) {
}{
{
"JSONPath parse works, results don't match"
,
"{.
Kind
}"
,
"{.
resourcesproviders.aescbc
}"
,
kubeletConfig
{
Kind
:
"KubeletConfiguration"
,
ApiVersion
:
"kubelet.config.k8s.io/v1beta1"
,
...
...
@@ -1134,3 +1134,129 @@ func TestToNumeric(t *testing.T) {
})
}
}
func
TestExecuteJSONPathOnEncryptionConfig
(
t
*
testing
.
T
)
{
type
Resources
struct
{
Resources
[]
string
`json:"resources"`
Providers
[]
map
[
string
]
interface
{}
`json:"providers"`
}
type
EncryptionConfig
struct
{
Kind
string
`json:"kind"`
ApiVersion
string
`json:"apiVersion"`
Resources
[]
Resources
`json:"resources"`
}
type
Key
struct
{
Secret
string
`json:"secret"`
Name
string
`json:"name"`
}
type
Aescbc
struct
{
Keys
[]
Key
`json:"keys"`
}
type
SecretBox
struct
{
Keys
[]
Key
`json:"keys"`
}
type
Aesgcm
struct
{
Keys
[]
Key
`json:"keys"`
}
// identity disable encryption when set as the first parameter
type
Identity
struct
{}
cases
:=
[]
struct
{
name
string
jsonPath
string
jsonInterface
EncryptionConfig
expectedResult
string
expectedToFail
bool
}{
{
"JSONPath parse works, results match"
,
"{.resources[*].providers[*].aescbc.keys[*].secret}"
,
EncryptionConfig
{
Kind
:
"EncryptionConfig"
,
ApiVersion
:
"v1"
,
Resources
:
[]
Resources
{{
Resources
:
[]
string
{
"secrets"
},
Providers
:
[]
map
[
string
]
interface
{}{
{
"aescbc"
:
Aescbc
{
Keys
:
[]
Key
{
Key
{
Secret
:
"secret1"
,
Name
:
"name1"
}}}},
}}}},
"secret1"
,
false
,
},
{
"JSONPath parse works, results match"
,
"{.resources[*].providers[*].aescbc.keys[*].name}"
,
EncryptionConfig
{
Kind
:
"EncryptionConfig"
,
ApiVersion
:
"v1"
,
Resources
:
[]
Resources
{{
Resources
:
[]
string
{
"secrets"
},
Providers
:
[]
map
[
string
]
interface
{}{
{
"aescbc"
:
Aescbc
{
Keys
:
[]
Key
{
Key
{
Secret
:
"secret1"
,
Name
:
"name1"
}}}},
}}}},
"name1"
,
false
,
},
{
"JSONPath parse works, results don't match"
,
"{.resources[*].providers[*].aescbc.keys[*].secret}"
,
EncryptionConfig
{
Kind
:
"EncryptionConfig"
,
ApiVersion
:
"v1"
,
Resources
:
[]
Resources
{{
Resources
:
[]
string
{
"secrets"
},
Providers
:
[]
map
[
string
]
interface
{}{
{
"aesgcm"
:
Aesgcm
{
Keys
:
[]
Key
{
Key
{
Secret
:
"secret1"
,
Name
:
"name1"
}}}},
}}}},
"secret1"
,
true
,
},
{
"JSONPath parse works, results match"
,
"{.resources[*].providers[*].aesgcm.keys[*].secret}"
,
EncryptionConfig
{
Kind
:
"EncryptionConfig"
,
ApiVersion
:
"v1"
,
Resources
:
[]
Resources
{{
Resources
:
[]
string
{
"secrets"
},
Providers
:
[]
map
[
string
]
interface
{}{
{
"aesgcm"
:
Aesgcm
{
Keys
:
[]
Key
{
Key
{
Secret
:
"secret1"
,
Name
:
"name1"
}}}},
}}}},
"secret1"
,
false
,
},
{
"JSONPath parse works, results match"
,
"{.resources[*].providers[*].secretbox.keys[*].secret}"
,
EncryptionConfig
{
Kind
:
"EncryptionConfig"
,
ApiVersion
:
"v1"
,
Resources
:
[]
Resources
{{
Resources
:
[]
string
{
"secrets"
},
Providers
:
[]
map
[
string
]
interface
{}{
{
"secretbox"
:
SecretBox
{
Keys
:
[]
Key
{
Key
{
Secret
:
"secret1"
,
Name
:
"name1"
}}}},
}}}},
"secret1"
,
false
,
},
{
"JSONPath parse works, results match"
,
"{.resources[*].providers[*].aescbc.keys[*].secret}"
,
EncryptionConfig
{
Kind
:
"EncryptionConfig"
,
ApiVersion
:
"v1"
,
Resources
:
[]
Resources
{{
Resources
:
[]
string
{
"secrets"
},
Providers
:
[]
map
[
string
]
interface
{}{
{
"aescbc"
:
Aescbc
{
Keys
:
[]
Key
{
Key
{
Secret
:
"secret1"
,
Name
:
"name1"
},
Key
{
Secret
:
"secret2"
,
Name
:
"name2"
}}}},
}}}},
"secret1 secret2"
,
false
,
},
}
for
_
,
c
:=
range
cases
{
t
.
Run
(
c
.
name
,
func
(
t
*
testing
.
T
)
{
result
,
err
:=
executeJSONPath
(
c
.
jsonPath
,
c
.
jsonInterface
)
if
err
!=
nil
&&
!
c
.
expectedToFail
{
t
.
Fatalf
(
"jsonPath:%q, expectedResult:%q got:%v"
,
c
.
jsonPath
,
c
.
expectedResult
,
err
)
}
if
c
.
expectedResult
!=
result
&&
!
c
.
expectedToFail
{
t
.
Errorf
(
"jsonPath:%q, expectedResult:%q got:%q"
,
c
.
jsonPath
,
c
.
expectedResult
,
result
)
}
})
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment