-
Notifications
You must be signed in to change notification settings - Fork 39
/
ripgrep_required_reason_api_text_scanner.sh
executable file
·84 lines (72 loc) · 2.53 KB
/
ripgrep_required_reason_api_text_scanner.sh
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
excluded_dirs=() # e.g. ("Pods" "3rdparty")
search_string=(
# File timestamp APIs
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api#4278393
"creationDate"
"creationDateKey"
"modificationDate"
"fileModificationDate"
"contentModificationDateKey"
"creationDateKey"
"getattrlist\("
"getattrlistbulk\("
"fgetattrlist\("
"stat\("
"stat.st_" # see https://developer.apple.com/documentation/kernel/stat
"fstat\("
"fstatat\("
"lstat\("
"getattrlistat\("
"NSFileCreationDate"
"NSFileModificationDate"
"NSURLContentModificationDateKey"
"NSURLCreationDateKey"
# System boot time APIs
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api#4278394
"systemUptime"
"mach_absolute_time\(\)"
# Disk space APIs
"volumeAvailableCapacityKey"
"volumeAvailableCapacityForImportantUsageKey"
"volumeAvailableCapacityForOpportunisticUsageKey"
"volumeTotalCapacityKey"
"systemFreeSize"
"systemSize"
"statfs\("
"statvfs\("
"fstatfs\("
"fstatvfs\("
"getattrlist\("
"fgetattrlist\("
"getattrlistat\("
"NSFileSystemFreeSize"
"NSFileSystemSize"
"NSURLVolumeAvailableCapacityForImportantUsageKey"
"NSURLVolumeAvailableCapacityForOpportunisticUsageKey"
"NSURLVolumeAvailableCapacityKey"
"NSURLVolumeTotalCapacityKey"
# Active keyboard APIs
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api#4278400
"activeInputModes"
# User defaults APIs
# https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api#4278401
"^UserDefaults"
"NSUserDefaults"
)
# Match whole words only
rg_opts='--line-number'
# A single -u/--unrestricted flag is equivalent to --no-ignore.
# Two -u/--unrestricted flags is equivalent to --no-ignore -./--hidden.
# Three -u/--unrestricted flags is equivalent to --no-ignore -./--hidden/--binary
rg_opts+=' -uu'
rg_opts+=" --type swift --type objcpp --type objc"
for dir in "${excluded_dirs[@]}"; do
rg_opts+=" --glob '!$dir/*'"
done
for string in "${search_string[@]}"; do
rg_opts+=" -e '$string'"
done
echo "Searching for use of required reason API"
echo "See https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api"
eval "rg $rg_opts $1"