77 SettingsDefinitionMap ,
88} from '../src/config'
99import { validator } from '../src/validation/utils'
10+ import { Adapter } from "../src/adapter" ;
11+ import { buildSettingsList } from "../src/util/settings" ;
1012
1113test . afterEach ( async ( ) => {
1214 process . env = { }
@@ -168,7 +170,7 @@ test.serial('Test validate function (scientific notation)', async (t) => {
168170 }
169171} )
170172
171- test ( 'sensitive configuration constants are properly flagged' , ( t ) => {
173+ test . serial ( 'sensitive configuration constants are properly flagged' , ( t ) => {
172174 // Extract all settings that are marked as sensitive
173175 const actualSensitiveSettings = Object . entries ( BaseSettingsDefinition )
174176 . filter ( ( [ _ , setting ] ) => ( setting as { sensitive ?: boolean } ) . sensitive === true )
@@ -187,3 +189,40 @@ test('sensitive configuration constants are properly flagged', (t) => {
187189 // Deep equal comparison
188190 t . deepEqual ( actualSensitiveSettings , expectedSensitiveSettings )
189191} )
192+
193+ test . serial ( 'multiline sensitive configuration constants are properly redacted' , async ( t ) => {
194+ // GIVEN
195+ process . env [ 'PRIVATE_KEY' ] = '-----BEGIN PRIVATE KEY-----\nthis\nis a fake\nprivate key\nused for testing only==\n-----END PRIVATE KEY-----'
196+ const customSettings : SettingsDefinitionMap = {
197+ PRIVATE_KEY : {
198+ description : 'Test custom env var' ,
199+ type : 'string' ,
200+ sensitive : true ,
201+ validate : {
202+ meta : {
203+ details : 'placeholder validation' ,
204+ } ,
205+ fn : ( value ?: string ) => {
206+ return ''
207+ }
208+ }
209+ } ,
210+ }
211+ const config = new AdapterConfig ( customSettings )
212+ config . initialize ( )
213+ config . validate ( )
214+ config . buildCensorList ( )
215+
216+ const adapter = new Adapter ( {
217+ name : "TEST_ADAPTER" ,
218+ endpoints : [ ] ,
219+ config : config ,
220+ } )
221+
222+ const settingsList = buildSettingsList ( adapter )
223+
224+ const settingEntries = settingsList . filter ( ( entry ) => entry . name === 'PRIVATE_KEY' )
225+ t . assert ( settingEntries . length === 1 )
226+ const settingEntry = settingEntries [ 0 ]
227+ t . assert ( settingEntry . value === "[PRIVATE_KEY REDACTED]" )
228+ } )
0 commit comments