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

Python: Add tracking steps for class level attributes #16526

Closed

Conversation

naneer
Copy link

@naneer naneer commented May 18, 2024

Adds support for type tracking for class level attributes and default instance variables. For example, to identify missing SQLExecution sinks for the SQLInjection DataFlow Rule. Also supports values inherited from base classes.

These SQLExecution sinks will be found:

from django.views import View
from django.db import connection

class ClassBasedView(View):
  _connection = connection
  def get(self, request):
     ...
     with self._connection.cursor() as cursor:
       cursor.execute("SELECT ... FROM ... WHERE")
     ...
  ...

class ClassBasedViewInit(View):
  def __init__(self, conn = connection):
    self._connection = conn
  ...
  def get(self, request):
    ...
    with self._connection.cursor() as cursor:
       cursor.execute("SELECT ... FROM ... WHERE")
    ...
  ...

// Inherited from base classes

class SubClassBasedView(ClassBasedView):
  def get(self, request):
    ...
    with self._connection.cursor() as cursor:
       cursor.execute("SELECT ... FROM ... WHERE")
    ...
  ...

class SubClassBasedViewInit(ClassBasedViewInit):
  def get(self, request):
    ...
    with self._connection.cursor() as cursor:
       cursor.execute("SELECT ... FROM ... WHERE")
    ...
  ...

@naneer naneer requested a review from a team as a code owner May 18, 2024 20:44
@RasmusWL
Copy link
Member

Thanks for your work on this 💪 I have actually been working on this as well, so I'll have a PR coming up shortly on this. Since most of your code uses points-to analysis that we are moving away from, we wouldn't be able to accept the actual implementation, but I really do appreciate the effort 👍

@naneer
Copy link
Author

naneer commented May 22, 2024

Ok, no problem. Looking forward to it!

@naneer naneer closed this May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants