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

Bug: Python Certain Function Calls are not captured #33

Open
JayGhiya opened this issue Dec 21, 2024 · 0 comments
Open

Bug: Python Certain Function Calls are not captured #33

JayGhiya opened this issue Dec 21, 2024 · 0 comments

Comments

@JayGhiya
Copy link

JayGhiya commented Dec 21, 2024

For code:

def process_codebase_summary(self, unoplat_codebase: UnoplatCodebase, codebase_summary: DspyUnoplatCodebaseSummary):
    objective_embedding = self.embedding_generator.generate_embeddings_for_single_text(
        codebase_summary.codebase_objective
    )  # type: ignore
    implementation_embedding = self.embedding_generator.generate_embeddings_for_single_text(
        codebase_summary.codebase_summary
    )  # type: ignore

    codebase_node_dict = [
        {
            "qualified_name": codebase_summary.codebase_name,
            "objective": codebase_summary.codebase_objective,
            "codebase_objective_embedding": objective_embedding,
            "implementation_summary": codebase_summary.codebase_summary,
            "codebase_implementation_summary_embedding": implementation_embedding,
        }
    ]

    ConfluenceCodebase.create_or_update(*codebase_node_dict)

This is not captured.

    ConfluenceCodebase.create_or_update(*codebase_node_dict)

There are other instances as well. As of now i did a experiment using tree sitters -

if node.type == "call":
                call_obj = self.__extract_function_call(node)

    def __extract_function_call(self, call_node: Node) -> Optional[ChapiFunctionCall]:
        func_name, node_name = None, None
        args = []

        arg_list = None
        # Identify function name and arguments
        for child in call_node.children:
            if child.type == "identifier":
                func_name = child.text.decode('utf8')
            elif child.type == "attribute":
                func_name, node_name = self.__extract_attribute_name(child)
            elif child.type == "argument_list":
                arg_list = child

        if arg_list:
            args = self.__extract_call_parameters(arg_list)

        return ChapiFunctionCall(
            NodeName=node_name,
            FunctionName=func_name,
            Parameters=args
        )

This works for all. I am not sure if problem is with Antlr or chapi. Please let me know if more information is needed.
Also if there is less time as of now i can complement this tree sitter parsing with chapi post this fix archguard/archguard#159. thankyou

@JayGhiya JayGhiya changed the title Bug: Certain Function Calls are not captured Bug: Python Certain Function Calls are not captured Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant