5 Replies Latest reply on Feb 12, 2016 3:51 AM by Niranjay Bharati

    How to loop through all values returned by Extended Object without declaring them explicitly in loop body

    Argyris Spinos

      Hello,

       

      I have created below compliance rule to check that only IP’s from specific networks listen on SMTP port 25:

       

      if

         "RPM:sendmail" exists

      then

         foreach "Extended Object Entry:Get SMTP listening interfaces - csv//**"

            (  @"Value1 as String (All OS)"@ = "127.0.0.1"  OR

               @"Value1 as String (All OS)"@ starts with "192.168.2."

            )  AND

            (  @"Value2 as String (All OS)"@ = "127.0.0.1"  OR

               @"Value2 as String (All OS)"@ starts with "192.168.2."

            )  AND

            (  @"Value3 as String (All OS)"@ = "127.0.0.1"  OR

               @"Value3 as String (All OS)"@ = "??TARGET.IP_ADDRESS??"

            )

         end

      end

      My EO is a command that returns all IP’s listening on port 25 in csv format. Can I make above script non-depended on how many values the EO will return. In other words make it like so:

       

      if

      "RPM:sendmail" exists

      then

         foreach "Extended Object Entry:Get SMTP listening interfaces - csv//**"

            (  @"Value* as String (All OS)"@ = "127.0.0.1"  OR

               @"Value* as String (All OS)"@ starts with "192.168.2."

            )

      end

       

      Thanks