Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect jQuery file #3566

Open
witchcraze opened this issue Jan 6, 2025 · 3 comments
Open

detect jQuery file #3566

witchcraze opened this issue Jan 6, 2025 · 3 comments
Labels

Comments

@witchcraze
Copy link
Contributor

What would you like to be added:

Detect jQuery file which is not managed by any package manager.
jquery-x.y.z.min.js
jquery-x.y.z.js
jquery-x.y.z.slim.min.js

Why is this needed:

To remove old jQuery files.

Additional context:

I think this will be solved with cataloger which is refffered in #2658
jQuery on CDN will be used widely, but I can not judge this is scope of Syft.

@witchcraze witchcraze added the enhancement New feature or request label Jan 6, 2025
@kzantow
Copy link
Contributor

kzantow commented Feb 3, 2025

This is an interesting ask! I would instinctively think this could be handled with an approach similar to the binary cataloger, where we determine some set of regular expressions and if matched, validate we found a jQuery file. See if there's some common window = jquery or similar perhaps to key off of.

@kzantow kzantow moved this to Ready in OSS Feb 3, 2025
@westonsteimel
Copy link
Contributor

westonsteimel commented Feb 3, 2025

I like the idea of trying to parse known javascript artifacts from popular CDN strings, though one of the difficulties will be anything using @latest and trying to resolve the actual currently used version. I do think it would be interesting to someday be able to point syft at a website and have it attempt to catalog everything from the html, but I suspect that is very different from anything it currently handles

@mprpic
Copy link
Contributor

mprpic commented Feb 10, 2025

This would be very helpful to discover vendored dependencies as is the case for example with Django:

(venv) ~/temp/django_app > syft .
 ✔ Indexed file system                                                                                                                                                                                                                    .
 ✔ Cataloged contents                                                                                                                                                      cdb4ee2aea69cc6a83331bbe96dc2caa9a299d21329efb0336fc02a82e1839a8
   ├── ✔ Packages                        [4 packages]  
   ├── ✔ File digests                    [11 files]  
   ├── ✔ File metadata                   [11 locations]  
   └── ✔ Executables                     [0 executables]  
[0000]  WARN no explicit name and version provided for directory source, deriving artifact ID from the given path (which is not ideal)
NAME      VERSION  TYPE     
asgiref   3.8.1    python    
django    5.1.6    python    
pip       24.2     python    
sqlparse  0.5.3    python  
(venv) ~/temp/django_app > fd jquery
venv/lib/python3.13/site-packages/django/contrib/admin/static/admin/js/jquery.init.js
venv/lib/python3.13/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/
venv/lib/python3.13/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.js
venv/lib/python3.13/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.min.js

Even if the files don't themselves contain versions in their name, they often come with headers that contain that information:

(venv) ~/temp/django_app > head venv/lib/python3.13/site-packages/django/contrib/admin/static/admin/js/vendor/jquery/jquery.js
/*!
 * jQuery JavaScript Library v3.7.1
 * https://jquery.com/
 *
 * Copyright OpenJS Foundation and other contributors
 * Released under the MIT license
 * https://jquery.org/license
 *
 * Date: 2023-08-28T13:37Z
 */

I imagine this could be generalized into a jsasset cataloger that could include regexes to catch the most common JS libraries (such as jQuery). If a version can't be discovered, it could be left unversioned (I assume that's possible?).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Ready
Development

No branches or pull requests

4 participants