Audit your Google Drive Privacy!

Shelby Jenkins
2 min readMar 18, 2022

--

You never know what the old you was up to. And while you might change, your files never do.

Google provides no way to audit who you are sharing files with or if a file is accessible to the public. You read that right: as a user you have no idea if your private files are public other than manually auditing each file.

So lets audit it ourselves using a quick trick I found on Stackoverflow.

Navigate to google apps script -> https://script.google.com/home

Create a new project and copy and paste this script into it.

function driveSearch() {// Log the name of every file in the user's Drive whose visibility is publicvar files = DriveApp.searchFiles('(visibility = "anyoneWithLink" or visibility = "anyoneCanFind" or visibility = "domainCanFind" or visibility = "domainWithLink" or visibility != "limited") and "me" in owners');while (files.hasNext()) {var file = files.next();Logger.log(file.getName());}}

Hit run, and it will return a list of files that are visible to the public. You may then go into drive and set those files to be private.

Unfortunately, this does not show files that are shared with others! With a second quick script we can look up all files that are shared!

Sadly, this script times out because it runs too slowly. I still don’t have a working solution to this problem.

function myfunction() {var files = DriveApp.searchFiles('"me" in owners');var counter = 0;var counterPrivate = 0;while(files.hasNext()) { var file = files.next();var viewers = file.getViewers();var editors = file.getEditors();counter = counter + 1;if (viewers.length > 0 || editors.length > 0) {counterPrivate = counterPrivate + 1;Logger.log('Filename: %s', file.getName());for (var i = 0; i < editors.length; i++) {Logger.log('Editor: %s', editors[i].getEmail());}for (var i = 0; i < viewers.length; i++) {Logger.log('Viewer: %s', viewers[i].getEmail());}}}Logger.log('Total files audited: %s, Total files not private: %s', counter, counterPrivate);}

--

--

No responses yet