File tree Expand file tree Collapse file tree 8 files changed +26
-51
lines changed
registry/npm/@denotest/no-actions-audit/1.0.0
specs/audit/missing_actions_field Expand file tree Collapse file tree 8 files changed +26
-51
lines changed Original file line number Diff line number Diff line change @@ -921,3 +921,29 @@ mod socket_dev {
921921 pub alerts : Vec < FirewallAlert > ,
922922 }
923923}
924+
925+ #[ cfg( test) ]
926+ mod tests {
927+ use super :: npm:: AuditResponse ;
928+ use deno_core:: serde_json;
929+
930+ #[ test]
931+ fn test_audit_response_deserialize_without_actions ( ) {
932+ // Test that AuditResponse can be deserialized when the `actions` field is missing
933+ // This can happen with some npm registry responses
934+ let json = r#"{
935+ "advisories": {},
936+ "metadata": {
937+ "vulnerabilities": {
938+ "low": 0,
939+ "moderate": 0,
940+ "high": 0,
941+ "critical": 0
942+ }
943+ }
944+ }"# ;
945+ let response: AuditResponse = serde_json:: from_str ( json) . unwrap ( ) ;
946+ assert ! ( response. actions. is_empty( ) ) ;
947+ assert ! ( response. advisories. is_empty( ) ) ;
948+ }
949+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -524,29 +524,6 @@ fn process_npm_security_audits_body(
524524
525525 let requires_map = value. get ( "requires" ) ?. as_object ( ) ?;
526526 let requires_map_keys = requires_map. keys ( ) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
527-
528- // Test case for response without `actions` field - simulates real npm registry
529- // behavior where actions field may be omitted
530- if requires_map_keys. contains ( & "@denotest/no-actions-audit" . to_string ( ) ) {
531- return Some ( json ! ( {
532- "advisories" : { } ,
533- "muted" : [ ] ,
534- "metadata" : {
535- "vulnerabilities" : {
536- "info" : 0 ,
537- "low" : 0 ,
538- "moderate" : 0 ,
539- "high" : 0 ,
540- "critical" : 0 ,
541- } ,
542- "dependencies" : 0 ,
543- "devDependencies" : 0 ,
544- "optionalDependencies" : 0 ,
545- "totalDependencies" : 0
546- }
547- } ) ) ;
548- }
549-
550527 if requires_map_keys. contains ( & "@denotest/with-vuln1" . to_string ( ) ) {
551528 actions. push ( get_action_for_with_vuln1 ( ) ) ;
552529 advisories. insert ( 101010 , get_advisory_for_with_vuln1 ( ) ) ;
You can’t perform that action at this time.
0 commit comments