1*e4a36f41SAndroid Build Coastguard Worker#!/bin/bash 2*e4a36f41SAndroid Build Coastguard Worker 3*e4a36f41SAndroid Build Coastguard Worker# Copyright (C) 2023 The Android Open Source Project 4*e4a36f41SAndroid Build Coastguard Worker# 5*e4a36f41SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 6*e4a36f41SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 7*e4a36f41SAndroid Build Coastguard Worker# You may obtain a copy of the License at 8*e4a36f41SAndroid Build Coastguard Worker# 9*e4a36f41SAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 10*e4a36f41SAndroid Build Coastguard Worker# 11*e4a36f41SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 12*e4a36f41SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 13*e4a36f41SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14*e4a36f41SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 15*e4a36f41SAndroid Build Coastguard Worker# limitations under the License. 16*e4a36f41SAndroid Build Coastguard Worker 17*e4a36f41SAndroid Build Coastguard Workerif [ $# -ne 1 ]; then 18*e4a36f41SAndroid Build Coastguard Worker echo "Usage: $0 <directory>" 19*e4a36f41SAndroid Build Coastguard Worker exit 1 20*e4a36f41SAndroid Build Coastguard Workerfi 21*e4a36f41SAndroid Build Coastguard Worker 22*e4a36f41SAndroid Build Coastguard Workerdirectory=$1 23*e4a36f41SAndroid Build Coastguard Worker 24*e4a36f41SAndroid Build Coastguard Worker# This fixes the Neverallow test involving policy violations of isolated_compute_app 25*e4a36f41SAndroid Build Coastguard Workerfunction fix_isolated_policies 26*e4a36f41SAndroid Build Coastguard Worker{ 27*e4a36f41SAndroid Build Coastguard Worker # Replace make sure we don't wrongly replace the existing occurrence 28*e4a36f41SAndroid Build Coastguard Worker find "$directory" -name "*.te" -print0 | xargs -0 sed -i 's/-\s*isolated_app_all/-isolated_app/g' 29*e4a36f41SAndroid Build Coastguard Worker 30*e4a36f41SAndroid Build Coastguard Worker # Replacement 31*e4a36f41SAndroid Build Coastguard Worker find "$directory" -name "*.te" -print0 | xargs -0 sed -i 's/-\s*isolated_app/-isolated_app_all/g' 32*e4a36f41SAndroid Build Coastguard Worker 33*e4a36f41SAndroid Build Coastguard Worker echo "Successfully replaced all occurrences of '-isolated_app' to '-isolated_app_all'!" 34*e4a36f41SAndroid Build Coastguard Worker} 35*e4a36f41SAndroid Build Coastguard Worker 36*e4a36f41SAndroid Build Coastguard Workerfix_isolated_policies 37