@@ -49,26 +49,26 @@ export async function countObjects (obj: BigipConfObj): Promise<ObjStats> {
4949
5050
5151 // GTM stats
52- if ( obj . gtm ) {
52+ if ( obj ? .gtm ) {
5353 // here we return/assign the value
5454 stats . gtm = await countGSLB ( obj ) ;
5555 }
5656
57- if ( obj . apm ) {
57+ if ( obj ? .apm ) {
5858 // here we pass in the main stats object and add stats in the function
5959 await countAPM ( obj , stats )
6060 }
6161
6262 // asm policies are refenced by local traffic policies on each vs
63- if ( obj . asm ?. policy ) {
63+ if ( obj ? .asm ?. policy ) {
6464 stats . asmPolicies = Object . keys ( obj . asm . policy ) . length ;
6565 }
6666
67- if ( obj . security [ 'bot-defense' ] ) {
67+ if ( obj ? .security ?. [ 'bot-defense' ] ) {
6868 stats . botProfiles = Object . keys ( obj . security [ 'bot-defense' ] ) . length ;
6969 }
7070
71- if ( obj . security . dos ) {
71+ if ( obj ? .security ? .dos ) {
7272 stats . dosProfiles = Object . keys ( obj . security . dos ) . length ;
7373 }
7474
@@ -82,13 +82,13 @@ export async function countAPM(obj: BigipConfObj, stats: ObjStats): Promise<void
8282
8383 // count access policies
8484 // apm policy access-policy <name> <details>
85- if ( obj . apm . policy ?. [ 'access-policy' ] ) {
85+ if ( obj ? .apm ? .policy ?. [ 'access-policy' ] ) {
8686 stats . apmPolicies = Object . keys ( obj . apm . policy [ 'access-policy' ] ) . length ;
8787 }
8888
8989 // count access profiles
9090 // apm profile access <name> <details
91- if ( obj . apm . profile ?. access ) {
91+ if ( obj ? .apm ? .profile ?. access ) {
9292 stats . apmProfiles = Object . keys ( obj . apm . profile . access ) . length ;
9393 }
9494
@@ -112,7 +112,7 @@ export async function countGSLB(obj: BigipConfObj): Promise<GslbStats> {
112112 parents . forEach ( p => {
113113
114114 // if parent found in obj.gtm object
115- if ( obj . gtm [ p ] ) {
115+ if ( obj ? .gtm ?. [ p ] ) {
116116 // count the keys
117117 gtmStats [ `${ p } s` ] = Object . keys ( obj . gtm [ p ] ) . length ;
118118 }
@@ -122,7 +122,7 @@ export async function countGSLB(obj: BigipConfObj): Promise<GslbStats> {
122122 // pools and wideips have named children object for the different record types
123123 // so we need to dig a bit deeper into each one
124124
125- if ( obj . gtm . pool ) {
125+ if ( obj ? .gtm ? .pool ) {
126126
127127 // we have some gslb pools so, create the param and set the initial value
128128 gtmStats . pools = 0
@@ -142,7 +142,7 @@ export async function countGSLB(obj: BigipConfObj): Promise<GslbStats> {
142142 } )
143143 }
144144
145- if ( obj . gtm . wideip ) {
145+ if ( obj ? .gtm ? .wideip ) {
146146
147147 gtmStats . wideips = 0 ;
148148
0 commit comments