Fraunhofer-AISEC / cpg

A library to extract Code Property Graphs from C/C++, Java, Go, Python, Ruby and every other language through LLVM-IR.
https://fraunhofer-aisec.github.io/cpg/
Apache License 2.0
246 stars 59 forks source link

Quantum analysis for qiskit gives the same result as if analysed with the main branch #1530

Closed carlosgpal closed 3 weeks ago

carlosgpal commented 1 month ago

Analysing this file in the quantum branch:

from qiskit import QuantumCircuit
circuito = QuantumCircuit(2)
circuito.h(0)
circuito.cx(0, 1)

With the command:

cpg-neo4j/build/install/cpg-neo4j/bin/cpg-neo4j --host=neo4j --user=neo4j --password=default1 /app/uploads/simpleq.py

It seems that the result is the same as running the parser with the normal python parser from the main branch.

There are no nodes with the QuantumNodes, QuantumBit, QuantumGate tag for example. image

I also attach my gradle.properties (PythonQiskit is enabled) and the log in case it is a bug on my end.

org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -Dkotlin.daemon.jvm.options=-Xmx4g
systemProp.sonar.gradle.skipCompile=true

enableJavaFrontend=true
enableCXXFrontend=true
enableGoFrontend=false
enablePythonFrontend=true
enableOpenQasmFrontend=true
enableLLVMFrontend=false
enableTypeScriptFrontend=false
enablePythonQiskitFrontend=true

enableRubyFrontend=false

simpleq.log

KuechA commented 1 month ago

Hi @carlosgpal, I could confirm the issue and I think the main problem is the way how we meanwhile handle Assignments and Declarations in python. The new handling, however, has not been accounted for by the QiskitPass which identifies the circuits based on variable initializers. I should now have fixed this issue with commit 478dfd1. Could you see if this solves the problem?

carlosgpal commented 1 month ago

Hi @KuechA, I've done a quick check and it doesn't seem to solve the problem. I keep getting the same results and the same logs.

KuechA commented 1 month ago

You're right, I'm sorry, I forgot another adjustment... I tested it with your example this time :) I also added some logging output, so we can hopefully identify this problem more easily in the future

carlosgpal commented 1 month ago

I tested it too, works perfectly. Thanks so much