File: ds_unselect_rules.sh

package info (click to toggle)
scap-security-guide 0.1.76-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 110,644 kB
  • sloc: xml: 241,883; sh: 73,777; python: 32,527; makefile: 27
file content (22 lines) | stat: -rwxr-xr-x 687 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/bash

if [ ! -f "$1" ] || [ ! -f "$2" ]; then
	printf "Usage: $(basename $0) <DATASTREAM> <UNSELECT_LIST_FILE>
Copies the DATASTREAM file to /tmp and unselects the rules listed
in the UNSELECT_LIST_FILE from the /tmp/DATASTREAM file.\n"
	exit 1
fi
DS=$1
UNSELECT_LIST=$2


printf 'Copying %s file to /tmp\n' "$DS"
cp $DS /tmp || exit 1
DS="/tmp/$(basename $DS)"

printf 'Unselecting rules listed in the %s from the %s\n' "$UNSELECT_LIST" "$DS"
for rule in $(cat $UNSELECT_LIST); do
	sed -i "/<.*Rule.*id=\"$rule/s/selected=\"true\"/selected=\"false\"/g" $DS || exit 1
	sed -i "/<.*select.*idref=\"$rule/s/selected=\"true\"/selected=\"false\"/g" $DS || exit 1
done
printf "Done\n"