Finding uses of an API with the new GitHub Code Search

The GitHub Code Search beta is really powerful - it allows advanced search - including regular expression matches - against every public repo on GitHub.

It's still in a preview (December 2022) - you can request access here.

Today I used it to figure out who was using a specific internal API from Datasette that I'm considering changing for Datasette 1.0.

The API is the permission_allowed(self, actor, action, resource=None, default=False) method - it's intended to be used by plugins that need to check if a user has permission to perform a specific action.

I use it a lot in my own plugins, but I wanted to see if anyone else was using it for theirs.

After some perusing of their documentation I came up with this:

datasette permission_allowed -user:simonw -path:datasette/** -path:docs/** -path:tests/** language:python

If you have access to the beta you can try that search here.

See also my research notes in this issue.

Created 2022-12-08T18:06:02-08:00 · Edit