Skip to content
This repository was archived by the owner on Jul 26, 2022. It is now read-only.

Commit 129a518

Browse files
authored
fix(core): verify data items with path attribute when using naming conventions. (#800)
* Fixes naming convention permission check for data items with path attribute.
1 parent 599c3cf commit 129a518

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/poller.js

+9
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ class Poller {
281281
// Testing data property
282282
if (namingConvention && externalData) {
283283
externalData.forEach((secretProperty, index) => {
284+
if (secretProperty.path) {
285+
if (!reNaming.test(secretProperty.path)) {
286+
allowed = false
287+
reason = `path ${secretProperty.path} does not match naming convention ${namingConvention}`
288+
return {
289+
allowed, reason
290+
}
291+
}
292+
}
284293
if (!reNaming.test(secretProperty.key)) {
285294
allowed = false
286295
reason = `key name ${secretProperty.key} does not match naming convention ${namingConvention}`

lib/poller.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,26 @@ describe('Poller', () => {
982982
},
983983
permitted: false
984984
},
985+
{
986+
// test regex on path
987+
ns: { metadata: { annotations: { [namingPermittedAnnotation]: 'dev/team-a/.*' } } },
988+
descriptor: {
989+
data: [
990+
{ path: 'dev/team-b/secret' }
991+
]
992+
},
993+
permitted: false
994+
},
995+
{
996+
// test regex on path when key is also specified
997+
ns: { metadata: { annotations: { [namingPermittedAnnotation]: 'dev/team-a/.*' } } },
998+
descriptor: {
999+
data: [
1000+
{ path: 'dev/team-b/secret', key: 'dev/team-a/secret' }
1001+
]
1002+
},
1003+
permitted: false
1004+
},
9851005
{
9861006
// test regex
9871007
ns: { metadata: { annotations: { [namingPermittedAnnotation]: 'dev/team-a/.*' } } },

0 commit comments

Comments
 (0)