@@ -99,6 +99,7 @@ type AuditCollector = {
9999 findings : SecretsAuditFinding [ ] ;
100100 refAssignments : RefAssignment [ ] ;
101101 configProviderRefPaths : Map < string , string [ ] > ;
102+ sourceManagedModelsJsonApiKeyMarkers : Map < string , Set < string > > ;
102103 authProviderState : Map < string , ProviderAuthState > ;
103104 filesScanned : Set < string > ;
104105} ;
@@ -123,6 +124,26 @@ function collectProviderRefPath(
123124 collector . configProviderRefPaths . set ( key , [ configPath ] ) ;
124125}
125126
127+ function collectSourceManagedModelsJsonApiKeyMarker ( params : {
128+ collector : AuditCollector ;
129+ providerId : string ;
130+ ref : SecretRef ;
131+ } ) : void {
132+ const { collector, providerId, ref } = params ;
133+ if ( ref . source !== "env" ) {
134+ return ;
135+ }
136+ const marker = ref . id . trim ( ) ;
137+ if ( ! marker ) {
138+ return ;
139+ }
140+ const providerKey = normalizeProviderId ( providerId ) ;
141+ const markers =
142+ collector . sourceManagedModelsJsonApiKeyMarkers . get ( providerKey ) ?? new Set < string > ( ) ;
143+ markers . add ( marker ) ;
144+ collector . sourceManagedModelsJsonApiKeyMarkers . set ( providerKey , markers ) ;
145+ }
146+
126147function trackAuthProviderState (
127148 collector : AuditCollector ,
128149 provider : string ,
@@ -198,6 +219,13 @@ function collectConfigSecrets(params: {
198219 if ( target . entry . trackProviderShadowing && target . providerId ) {
199220 collectProviderRefPath ( params . collector , target . providerId , target . path ) ;
200221 }
222+ if ( target . entry . id === "models.providers.*.apiKey" && target . providerId ) {
223+ collectSourceManagedModelsJsonApiKeyMarker ( {
224+ collector : params . collector ,
225+ providerId : target . providerId ,
226+ ref,
227+ } ) ;
228+ }
201229 continue ;
202230 }
203231
@@ -379,6 +407,12 @@ function collectModelsJsonSecrets(params: {
379407 provider : providerId ,
380408 } ) ;
381409 } else if ( isNonEmptyString ( apiKey ) && ! isNonSecretApiKeyMarker ( apiKey ) ) {
410+ const sourceManagedMarker = params . collector . sourceManagedModelsJsonApiKeyMarkers
411+ . get ( normalizeProviderId ( providerId ) )
412+ ?. has ( apiKey . trim ( ) ) ;
413+ if ( sourceManagedMarker ) {
414+ continue ;
415+ }
382416 addFinding ( params . collector , {
383417 code : "PLAINTEXT_FOUND" ,
384418 severity : "warn" ,
@@ -623,6 +657,7 @@ export async function runSecretsAudit(
623657 findings : [ ] ,
624658 refAssignments : [ ] ,
625659 configProviderRefPaths : new Map ( ) ,
660+ sourceManagedModelsJsonApiKeyMarkers : new Map ( ) ,
626661 authProviderState : new Map ( ) ,
627662 filesScanned : new Set ( [ configPath ] ) ,
628663 } ;
0 commit comments