Scalpel icon indicating copy to clipboard operation
Scalpel copied to clipboard

Inquiry about the plan to release DefUseChain module

Open Jacob-yen opened this issue 2 years ago • 9 comments

Hi~ First of all, thank you for sharing such an awesome static analysis tool like Scalpel. It has been incredibly useful in my work.

I notice that there is a module named DefUseChain in SSA, but it seems that it is not implemented yet. Do you have any plan to implement and release it?

Thanks :)

Jacob-yen avatar Jul 03 '23 03:07 Jacob-yen

Hi,

Thank you for your interest. Yes, this work is in progress, and we will have a major release in coming months. Please feel free to share your ideas and contribute.

Jarvx avatar Jul 03 '23 06:07 Jarvx

There is an existing implementation of Def-Use chains, it's pretty well-tested.

https://github.com/serge-sans-paille/beniget

I think it would be easy to adjust it work with ast nodes (it works with gast, wich is compatibility layer on top of ast, but it's mainly the same except for deprecated nodes and except handlers.)

Adjusting that module would be the path of least resistance in term of implementation, I've already done it once.

tristanlatr avatar Sep 07 '23 17:09 tristanlatr

I have used beniget successfully with HeaderGen on top of PyCG. It is pretty useful. We are currently working towards integrating beniget directly into PyCG.

ashwinprasadme avatar Sep 08 '23 07:09 ashwinprasadme

There is an existing implementation of Def-Use chains, it's pretty well-tested.

https://github.com/serge-sans-paille/beniget

I think it would be easy to adjust it work with ast nodes (it works with gast, wich is compatibility layer on top of ast, but it's mainly the same except for deprecated nodes and except handlers.)

Adjusting that module would be the path of least resistance in term of implementation, I've already done it once.

Thanks for this point. Sure, I will look into the project and see how we can appropriately integrate this tool into Scalpel.

Jarvx avatar Sep 09 '23 10:09 Jarvx

Also, DUC is under development at https://github.com/SMAT-Lab/Scalpel/blob/scalpel-base-dev/src/scalpel/duc.py

Jarvx avatar Sep 09 '23 10:09 Jarvx

Please don't forget to include the tests if your forking beniget! :)

I’ve personally worked hard for the latest beniget improvements.

tristanlatr avatar Sep 12 '23 22:09 tristanlatr

Probably you won't have to fork and maintain this code since we are looking fixing the compatibility with the standard ast module: https://github.com/serge-sans-paille/beniget/pull/94

Scalpel will be able to use beniget directly when this is merged.

I suspect that the code you included in scalpel is not passing the tests... This is because this code was written to work with gast and not the standard ast.

tristanlatr avatar May 07 '24 15:05 tristanlatr

Probably you won't have to fork and maintain this code since we are looking fixing the compatibility with the standard ast module: serge-sans-paille/beniget#94

Scalpel will be able to use beniget directly when this is merged.

I suspect that the code you included in scalpel is not passing the tests... This is because this code was written to work with gast and not the standard ast.

Thanks for letting me know this. Yeah, I initially want to built the one adapted from beniget using standard ast. Sure, will be very happy to directly use beniget.

Jarvx avatar May 08 '24 11:05 Jarvx

Hello, just an update to mention that the upstream (yet unreleased) implementation now support the standard library nodes. So no need to fork the code, just use https://github.com/serge-sans-paille/beniget directly

tristanlatr avatar Nov 26 '24 19:11 tristanlatr