Skip to content

Instantly share code, notes, and snippets.

@HarryCutts
Last active January 16, 2021 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarryCutts/9f8aabebc36dd7e2200e8e942066709e to your computer and use it in GitHub Desktop.
Save HarryCutts/9f8aabebc36dd7e2200e8e942066709e to your computer and use it in GitHub Desktop.
Minijail policy file duplicate checker (https://crrev.com/c/2633956)
fn list-syscalls [file]{
cat $file | eawk [f syscall @rest]{ if (str:has-suffix $syscall ':') { put $syscall[:-1] } }
}
fn find-dups [list]{
map = [&]
for item $list {
if (has-key $map $item) {
put $item
}
map[$item] = $true
}
}
fn check-all [@files]{
for file $files {
dups = [(find-dups [(list-syscalls $file)])]
if (!= 0 (count $dups)) {
echo $file 'has duplicates:' $dups
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment