Skip to content

Instantly share code, notes, and snippets.

@jondb
Last active May 19, 2016 20:59
Show Gist options
  • Save jondb/236ebec6efc4b80f518563ae61c2d91f to your computer and use it in GitHub Desktop.
Save jondb/236ebec6efc4b80f518563ae61c2d91f to your computer and use it in GitHub Desktop.

1) get the column names:

head -n 1 status_reports_2016-05-19T18-50-57+00-00.csv | pbcopy

2) import the csv into sqlite3

create table foo( <paste column names from #1> );
.mode csv
.import status_reports_2016-05-19T18-50-57+00-00.csv foo

3) run command to find unused keys/inactive users

select user from foo where (access_key_1_active = 'true' and date(access_key_1_last_used_date) < date('now', 'start of month', '-1 month')) or (access_key_2_active = 'true' and date(access_key_2_last_used_date) < date('now', 'start of month', '-1 month'))  ;

4) keys assigned to console users

select user from foo where password_enabled = 'true' and (access_key_1_active = 'true' or access_key_2_active = 'true');

5) all users with passwords are recently active

select user from foo where password_last_used < date('now', '-1 month');

6) Look at keys or passwords that are greater than 1 year old

select user from foo where (access_key_1_active = 'true' and date(access_key_1_last_used_date) < date('now', 'start of month', '-1 month')) or (access_key_2_active = 'true' and date(access_key_2_last_used_date) < date('now', 'start of month', '-1 month'))  ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment