Hello PCAP,
Group configuration is designed to share a common configuration across the multiple objects of same type.
Hence all the examples would typically include one or more wildcard characters.
In your case, groups configuration is an exact statement and has no variable. IMHO, this is not a correct usage of group.
Also as others have highighted, the group configuration always gets added at the end of the context , therefore, group policy will be placed after the configured deny policy.
Adding to my observation, the deny policy within the policy context appears to be present to log all denied packets.
My suggestion is to reverse your policies in the following way:-
1. Configure the allow policy in the exact context.
Spoilerset security policies from-zone trust to-zone untrust policy basic-permit match source-address any
set security policies from-zone trust to-zone untrust policy basic-permit match destination-address any
set security policies from-zone trust to-zone untrust policy basic-permit match application junos-icmp-ping
set security policies from-zone trust to-zone untrust policy basic-permit then permit
set security policies from-zone trust to-zone untrust policy basic-permit then log session-init
2. Create a generic group policy to deny & log.
Spoilerset groups lab security policies from-zone <*> to-zone <*> policy deny-all-log match source-address any
set groups lab security policies from-zone <*> to-zone <*> policy deny-all-log match destination-address any
set groups lab security policies from-zone <*> to-zone <*> policy deny-all-log match application any
set groups lab security policies from-zone <*> to-zone <*> policy deny-all-log then deny
set groups lab security policies from-zone <*> to-zone <*> policy deny-all-log then log session-init
When written this way, you would now not need to re-arrange the order and also you will not be required to write deny policy to log in each context.
Note that the default policy is anyways denying any unmatched traffic if logging is not needed.
I hope this helps.
Thanks!