forked from SigmaHQ/sigma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchgrep.sh
More file actions
executable file
·41 lines (35 loc) · 1.03 KB
/
Copy pathmatchgrep.sh
File metadata and controls
executable file
·41 lines (35 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
infile=$1
fps=$2
if [[ -z ${infile} || -z ${fps} ]]; then
>&2 echo "usage: $0 [json-file] [FPs.csv]"
exit 1
fi
if [[ ! -f ${infile} || ! -r ${infile} ]]; then
>&2 echo "${infile} is not a valid, readable file"
exit 2
fi
if [[ ! -f ${fps} || ! -r ${fps} ]]; then
>&2 echo "${fps} is not a valid, readable file"
exit 2
fi
# Exclude all rules with level "low"
findings=$(grep -v '"RuleLevel":"low"' ${infile})
{
read # Skip CSV header
while IFS=\; read -r id name fpstring; do
findings=$(echo "${findings}" | grep -iEv "\"RuleId\":\"${id}\".*${fpstring}")
done
} < ${fps}
if [[ -z ${findings} ]]; then
echo "No matches found."
else
>&2 echo "Found matches:"
echo "${findings}"
>&2 echo
>&2 echo "Match overview:"
echo ${findings} | jq -c '. | {RuleId, RuleTitle, RuleLevel}' | sort | uniq -c | sort -nr >&2
>&2 echo
>&2 echo "You either need to tune your rule(s) for false positives or add a false positive filter to .github/workflows/known-FPs.csv"
exit 3
fi