File tree Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Expand file tree Collapse file tree 2 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { JsonObject } from './common' ;
2
2
import { ParsedValue } from './parsed-value' ;
3
3
import { generateSymmetricKey , encryptValue } from './encryption' ;
4
- import { encryptedDirective , extendsDirective } from './extensions' ;
4
+ import { encryptedDirective , extendsDirective , envDirective } from './extensions' ;
5
5
import { loadSchema } from './schema' ;
6
6
import { withTempFiles } from './test-util' ;
7
7
@@ -556,5 +556,34 @@ describe('Validation', () => {
556
556
} ,
557
557
) ;
558
558
} ) ;
559
+
560
+ it ( 'allows a "secret" array with all secret values, but not secret itself' , async ( ) => {
561
+ await withTempFiles (
562
+ {
563
+ '.app-config.schema.yml' : `
564
+ type: object
565
+ properties:
566
+ foo:
567
+ type: array
568
+ secret: true
569
+ items:
570
+ type: string
571
+ ` ,
572
+ } ,
573
+ async ( inDir ) => {
574
+ const { validate } = await loadSchema ( { directory : inDir ( '.' ) } ) ;
575
+ const symmetricKey = await generateSymmetricKey ( 1 ) ;
576
+
577
+ const parsed = await ParsedValue . parseLiteral (
578
+ {
579
+ foo : [ await encryptValue ( 'secret-1' , symmetricKey ) ] ,
580
+ } ,
581
+ [ encryptedDirective ( symmetricKey ) , envDirective ( ) ] ,
582
+ ) ;
583
+
584
+ validate ( parsed . toJSON ( ) as JsonObject , parsed ) ;
585
+ } ,
586
+ ) ;
587
+ } ) ;
559
588
} ) ;
560
589
} ) ;
Original file line number Diff line number Diff line change @@ -123,12 +123,11 @@ export async function loadSchema({
123
123
const arr = found . asArray ( ) ;
124
124
125
125
if ( arr ) {
126
- if ( ! arr . every ( ( v ) => v . meta . fromSecrets ) ) {
127
- return false ;
128
- }
126
+ return arr . every ( ( v ) => v . meta . fromSecrets ) ;
129
127
}
130
128
131
129
if ( ! found . meta . fromSecrets ) {
130
+ // arrays that are "secret" don't need to be secret themselves, just the items in that array do
132
131
return false ;
133
132
}
134
133
}
You can’t perform that action at this time.
0 commit comments