Skip to content

Commit 7800061

Browse files
committed
initial version of enterprise log script
1 parent deeb1ca commit 7800061

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
if [ -z "$2" ]; then
4+
echo "Usage: $0 <enterprise> <org> <optional: actor>"
5+
exit 1
6+
fi
7+
8+
enterprise="$1"
9+
org="$2"
10+
actor="$3" # this is optional, but adding it can really filter down results
11+
12+
if [ -z "$actor" ]; then
13+
actor_field="-f \"phrase=actor:$actor\""
14+
fi
15+
16+
# we are using JQ to look for when things have specifically been enable[d] or disable[d] at the organization level
17+
gh api -X GET "/enterprises/$enterprise/audit-log" $actor_field -f per_page=100 | jq --arg org "$org" '.[] | select(.org == $org) | select(.action | test("disable[d]?|enable[d]?")) | {action, actor, org, "@timestamp"} | .["@timestamp"] /= 1000 | .["@timestamp"] |= strftime("%Y-%m-%d %H:%M:%S")'

0 commit comments

Comments
 (0)