I'm working on a script to audit Github. so in that process im trying to find a way to know if the GitHub user in my organization has changed their profile picture from the default profile picture.
Im working with the go-github
package to access Github. https://github.com/google/go-github/blob/ababee01b03f69965d0ec370e65b61ec7967be34/github/users.go
Currently, I can get the list of users from ListMembers
method and GetAvatarURL
gets organization users profile image. But I can't get any differentiation from default github image and the user changed image.
Following is the default image ima talking about.
I get the AvatarURL like
https://avatars0.githubusercontent.com/u/XXXXXX?v=4
This is the same for default and for images uploaded by the users. only change is the host server of the images like avatars1
, avatars2
, avatars3
& avatars4
.
Is there any other way to find the difference?
One way to do this is to get some information about the images using tools like ImageMagick
After checking the Github auto-generated identicons, there are 2 check that would be interesting :
check that the image has 2 unique colors :
output:
one of this color is grey-ish F0F0F0
output:
identify and convert tools are part of ImageMagick
The following code use go-github to fetch 50 members of an organization and check each
avatarURL
with the 2 checks above :Note: In order to pass URL to the tools instead of regular files, I had to edit the file under
/etc/ImageMagick-6/policy.xml
commenting https policy but you can modify the code to download the avatar image yourself if needed