Search for python2 scripts in Jamf?

ega
Contributor III

So we have a nice tool to looks at packages for scripts that might have deprecated languages in them (see https://github.com/scriptingosx/pkgcheck).  Has anyone created something to look at the first line of all the scripts in the JSS and report ?  I am guessing would have to use the JAMF API, to get <script_contents>, then match on the first line like in pkgcheck.  Anyone working on this?

2 ACCEPTED SOLUTIONS

Nick1403
New Contributor III

found this yesterday: https://github.com/laurentpertois/Search-Scripts-In-Jamf

 

I haven't tested it yet but you can try it πŸ˜…

View solution in original post

ega
Contributor III

@Nick1403 Great find!  works well! I did searches on 1828 scripts and 173 extension attributes for "/usr/bin/python",
"/usr/bin/perl" and "/usr/bin/ruby".  I created a Jamf account that could only read Scripts and Computer Extension Attributes.  One thing to note is that I also found serval scripts that were calling python without the full path (tsk).  Kudos to Lauren for the script!!

View solution in original post

8 REPLIES 8

cbrewer
Valued Contributor II

If you have access to your database you can do this pretty easily with a select statement.

select script_id,file_name from scripts where script_contents like '%python%';

ega
Contributor III

We are cloud hosted so this won't work for us but good tip for on prem. folks

sdagley
Honored Contributor III

@ega It's a little brute force, but my approach for checking python use was to run https://github.com/jamf/JamfMigrator in Save Only mode to make a local copy of all of the Script objects in my JSS, and then searching the directory of exported scripts for 'python'.

SeyhaSoun
New Contributor

Here is what I used to search, it searches both scripts and EA, https://github.com/laurentpertois/Search-Scripts-In-Jamf

Nick1403
New Contributor III

found this yesterday: https://github.com/laurentpertois/Search-Scripts-In-Jamf

 

I haven't tested it yet but you can try it πŸ˜…

I've tested it and it does work. I used https://github.com/laurentpertois/Search-Scripts-In-Jamf/blob/main/searchScriptsAndEAsInJamf.sh to also find any python reference in EAs.

ega
Contributor III

@Nick1403 Great find!  works well! I did searches on 1828 scripts and 173 extension attributes for "/usr/bin/python",
"/usr/bin/perl" and "/usr/bin/ruby".  I created a Jamf account that could only read Scripts and Computer Extension Attributes.  One thing to note is that I also found serval scripts that were calling python without the full path (tsk).  Kudos to Lauren for the script!!

TechSpecialist
Contributor

Nice little script, worked for me flawlessly.

Question tho, is it enough to just disable the Policies/EAs that use Python to get rid of the jamfdeamon alerts? Or do the Scripts/EA's need to be deleted from the JSS alltogether?