@@ -367,6 +367,12 @@ fn format_search_results(
367367 if !desc. is_empty ( ) {
368368 out. push_str ( & format ! ( " Description: {desc}\n " ) ) ;
369369 }
370+ if patch. requires_opt_in == Some ( true ) {
371+ if let Some ( note) = & patch. opt_in_note {
372+ let note = crate :: ui:: terminal_text ( note) . replace ( '\n' , "\n " ) ;
373+ out. push_str ( & format ! ( " Opt-in required: {note}\n " ) ) ;
374+ }
375+ }
370376 let mut fixes: Vec < ( String , String ) > = patch
371377 . vulnerabilities
372378 . iter ( )
@@ -1284,6 +1290,15 @@ pub async fn run(args: GetArgs) -> i32 {
12841290 crate :: ui:: stderr_color( ) ,
12851291 )
12861292 ) ;
1293+ if patch. requires_opt_in == Some ( true ) {
1294+ if let Some ( note) = & patch. opt_in_note {
1295+ let note = crate :: ui:: terminal_text ( note) . replace ( '\n' , "\n " ) ;
1296+ println ! (
1297+ "Opt-in required for {}: {note}" ,
1298+ normalize_purl( & patch. purl)
1299+ ) ;
1300+ }
1301+ }
12871302 }
12881303
12891304 // Record the fetch BEFORE the save+apply step so the
@@ -1802,6 +1817,7 @@ pub async fn run(args: GetArgs) -> i32 {
18021817 verbose : args. common . verbose ,
18031818 } ;
18041819 let mut env = new_envelope ( & args. common ) ;
1820+ register_opt_ins ( & mut env, & selected) ;
18051821 // The narrowing skips came first (before any download).
18061822 fold_narrowing_into_result ( & mut env, & narrow_skips, & narrow_warnings) ;
18071823 // The engine records into `env` and never prints it: exactly one JSON
@@ -1904,6 +1920,7 @@ async fn agent_dry_run(
19041920 if args. common . json {
19051921 let mut env = new_envelope ( & args. common ) ;
19061922 env. dry_run = true ;
1923+ register_opt_ins ( & mut env, selected) ;
19071924 fold_narrowing_into_result ( & mut env, narrow_skips, narrow_warnings) ;
19081925 for event in events {
19091926 env. record ( event) ;
@@ -2159,6 +2176,12 @@ async fn save_and_apply_patch(
21592176
21602177 if args. common . json {
21612178 let mut env = new_envelope ( & args. common ) ;
2179+ env. register_opt_in (
2180+ & patch. purl ,
2181+ & patch. uuid ,
2182+ patch. requires_opt_in ,
2183+ patch. opt_in_note . as_deref ( ) ,
2184+ ) ;
21622185 fold_narrowing_into_result ( & mut env, & [ ] , run_warnings) ;
21632186 // The metadata rides only a changed record — an `already_in_manifest`
21642187 // skip means the consumer already saw it last time.
@@ -2206,6 +2229,19 @@ fn search_result_from_response(patch: &PatchResponse) -> PatchSearchResult {
22062229 license : patch. license . clone ( ) ,
22072230 tier : patch. tier . clone ( ) ,
22082231 vulnerabilities : patch. vulnerabilities . clone ( ) ,
2232+ requires_opt_in : patch. requires_opt_in ,
2233+ opt_in_note : patch. opt_in_note . clone ( ) ,
2234+ }
2235+ }
2236+
2237+ fn register_opt_ins ( env : & mut Envelope , patches : & [ PatchSearchResult ] ) {
2238+ for patch in patches {
2239+ env. register_opt_in (
2240+ & patch. purl ,
2241+ & patch. uuid ,
2242+ patch. requires_opt_in ,
2243+ patch. opt_in_note . as_deref ( ) ,
2244+ ) ;
22092245 }
22102246}
22112247
@@ -2254,6 +2290,7 @@ async fn run_get_hosted(
22542290 // common.json (see run_redirect_selected's doc).
22552291 let scan_result = args. common . json . then ( || {
22562292 let mut env = new_envelope ( & args. common ) ;
2293+ register_opt_ins ( & mut env, selected) ;
22572294 fold_narrowing_into_result ( & mut env, narrow_skips, narrow_warnings) ;
22582295 env
22592296 } ) ;
@@ -2305,6 +2342,7 @@ async fn run_get_vendored(
23052342 telemetry : & TelemetryAuth ,
23062343) -> i32 {
23072344 let mut env = new_envelope ( & args. common ) ;
2345+ register_opt_ins ( & mut env, selected) ;
23082346 fold_narrowing_into_result ( & mut env, narrow_skips, narrow_warnings) ;
23092347 // Dry run: ledger-classification preview only (scan's posture) — no
23102348 // download, no vendor step, no writes.
@@ -2568,6 +2606,8 @@ mod tests {
25682606 license : "MIT" . into ( ) ,
25692607 tier : tier. into ( ) ,
25702608 vulnerabilities : HashMap :: < String , VulnerabilityResponse > :: new ( ) ,
2609+ requires_opt_in : None ,
2610+ opt_in_note : None ,
25712611 }
25722612 }
25732613
@@ -2899,6 +2939,8 @@ mod tests {
28992939 description : String :: new ( ) ,
29002940 license : String :: new ( ) ,
29012941 tier : "free" . to_string ( ) ,
2942+ requires_opt_in : None ,
2943+ opt_in_note : None ,
29022944 } ,
29032945 ) ;
29042946 m
@@ -3080,6 +3122,8 @@ mod tests {
30803122 description : "desc" . into ( ) ,
30813123 license : "MIT" . into ( ) ,
30823124 tier : "free" . into ( ) ,
3125+ requires_opt_in : None ,
3126+ opt_in_note : None ,
30833127 } ;
30843128 let meta = patch_event_metadata ( & patch) ;
30853129 assert ! ( meta. as_object( ) . unwrap( ) . get( "severity" ) . is_none( ) ) ;
@@ -3110,6 +3154,8 @@ mod tests {
31103154 description : "Fixes prototype pollution in minimist" . into ( ) ,
31113155 license : "MIT" . into ( ) ,
31123156 tier : "free" . into ( ) ,
3157+ requires_opt_in : None ,
3158+ opt_in_note : None ,
31133159 } ;
31143160 let meta = patch_event_metadata ( & patch) ;
31153161 assert_eq ! ( meta[ "description" ] , "Fixes prototype pollution in minimist" ) ;
@@ -3151,6 +3197,8 @@ mod tests {
31513197 description : String :: new ( ) ,
31523198 license : String :: new ( ) ,
31533199 tier : String :: new ( ) ,
3200+ requires_opt_in : None ,
3201+ opt_in_note : None ,
31543202 } ;
31553203 let meta = patch_event_metadata ( & patch) ;
31563204 let ids: Vec < & str > = meta[ "vulnerabilities" ]
@@ -3173,6 +3221,8 @@ mod tests {
31733221 description : "desc" . into ( ) ,
31743222 license : "MIT" . into ( ) ,
31753223 tier : "free" . into ( ) ,
3224+ requires_opt_in : None ,
3225+ opt_in_note : None ,
31763226 } ;
31773227 let meta = patch_event_metadata ( & patch) ;
31783228 // `severity` is intentionally omitted (not null) when there
@@ -3748,6 +3798,8 @@ mod tests {
37483798 description : "desc" . into ( ) ,
37493799 license : "MIT" . into ( ) ,
37503800 tier : "free" . into ( ) ,
3801+ requires_opt_in : None ,
3802+ opt_in_note : None ,
37513803 }
37523804 }
37533805
0 commit comments