policychecker: modified 'Unconstrained allow' rule 15/186815/3
authorAdrian Szyndela <adrian.s@samsung.com>
Tue, 14 Aug 2018 13:54:50 +0000 (15:54 +0200)
committerAdrian Szyndela <adrian.s@samsung.com>
Mon, 20 Aug 2018 09:39:23 +0000 (11:39 +0200)
Unconstrained allow rule was reporting any allow in context default
or mandatory.
Now, it reports those rules in both contexts that:
- allow send_type='method_call' but do not specify destination and interface;
- allow send_path but do not specify destination;
- allow receive_type='method_call' but do not specify sender and interface;
- allow receive_path but do not specify sender.
Additionally, in user and group context send_destination is required
when send_type="method_call" or send_path is present, and receive_sender
is required when receive_type="method_call" or receive_path is present.

Change-Id: Icd822bf4b3e2f105a07e80ca61415410faaeb00a

policychecker/rules.xsl

index f159b6f20c802ed03f1af1fac6241555fec45b58..8a8d3f455a0203feb8baeb2b38d88f637f587dbf 100644 (file)
        </sch:pattern>
 
        <sch:pattern name="Unconstrained allow in default context (or mandatory)">
-               <!-- use true() to issue an error for each allow and not only once per policy -->
-               <sch:rule context="policy[@context = 'default']/allow | policy[@context = 'mandatory']/allow">
-                       <sch:report test="true()">Unconstrained allows are not allowed in context default and context mandatory.</sch:report>
+               <!-- policy[@context] means that it applies to both default and mandatory contexts -->
+               <sch:rule context="policy[@context]/allow[@send_type='method_call']">
+                       <sch:assert test="@send_destination">Unconstrained allows are not allowed in context default and context mandatory: missing send_destination, but send_type="method_call" is present.</sch:assert>
+                       <sch:assert test="@send_interface">Unconstrained allows are not allowed in context default and context mandatory: missing send_interface, but send_type="method_call" is present.</sch:assert>
+               </sch:rule>
+               <sch:rule context="policy[@context]/allow[@send_path]">
+                       <sch:assert test="@send_destination">Unconstrained allows are not allowed in context default and context mandatory: missing send_destination, but send_path is present.</sch:assert>
+               </sch:rule>
+               <sch:rule context="policy[@context]/allow[@receive_type='method_call']">
+                       <sch:assert test="@receive_sender">Unconstrained allows are not allowed in context default and context mandatory: missing receive_sender, but receive_type="method_call" is present.</sch:assert>
+                       <sch:assert test="@receive_interface">Unconstrained allows are not allowed in context default and context mandatory: missing receive_interface, but receive_type="method_call" is present.</sch:assert>
+               </sch:rule>
+               <sch:rule context="policy[@context]/allow[@receive_path]">
+                       <sch:assert test="@receive_sender">Unconstrained allows are not allowed in context default and context mandatory: missing receive_sender, but receive_path is present.</sch:assert>
+               </sch:rule>
+               <!-- user and group contexts need at least send_destination -->
+               <sch:rule context="policy[@user]/allow[@send_type='method_call'] | policy[@group]/allow[@send_type='method_call']">
+                       <sch:assert test="@send_destination">Unconstrained allows are not allowed in user or group context: missing send_destination, but send_type="method_call" is present.</sch:assert>
+               </sch:rule>
+               <sch:rule context="policy[@user]/allow[@send_path] | policy[@group]/allow[@send_path]">
+                       <sch:assert test="@send_destination">Unconstrained allows are not allowed in user or group context: missing send_destination, but send_path is present.</sch:assert>
+               </sch:rule>
+               <sch:rule context="policy[@user]/allow[@receive_type='method_call'] | policy[@group]/allow[@receive_type='method_call']">
+                       <sch:assert test="@receive_sender">Unconstrained allows are not allowed in user or group context: missing receive_sender, but receive_type="method_call" is present.</sch:assert>
+               </sch:rule>
+               <sch:rule context="policy[@user]/allow[@receive_path] | policy[@group]/allow[@receive_path]">
+                       <sch:assert test="@receive_sender">Unconstrained allows are not allowed in user or group context: missing receive_sender, but receive_path is present.</sch:assert>
                </sch:rule>
        </sch:pattern>
        <!-- additional rule -->